byte[] (@Nullable TypePath path) { TypeInfo curType = myTypeInfo; int depth = curType.innerDepth(); if (path == null) { if (depth == 0) { return ArrayUtil.EMPTY_BYTE_ARRAY; } byte[] result = new byte[depth]; Arrays.fill(result, TypeAnnotationContainer.Collector.ENCLOSING_CLASS); return result; } ByteArrayOutputStream result = new ByteArrayOutputStream(); int length = path.getLength(); for (int i = 0; i < length; i++) { byte step = (byte)path.getStep(i); if (step == TypePath.INNER_TYPE) { if (depth == 0) return null; depth--; continue; } while (depth-- > 0) { result.write(TypeAnnotationContainer.Collector.ENCLOSING_CLASS); if (!(curType instanceof TypeInfo.RefTypeInfo)) return null; curType = ((TypeInfo.RefTypeInfo)curType).outerType(); } switch (step) { case TypePath.ARRAY_ELEMENT: if (!(curType instanceof TypeInfo.DerivedTypeInfo) || (curType.getKind() != TypeInfo.TypeKind.ARRAY && curType.getKind() != TypeInfo.TypeKind.ELLIPSIS)) { return null; } curType = ((TypeInfo.DerivedTypeInfo)curType).child(); result.write(TypeAnnotationContainer.Collector.ARRAY_ELEMENT); break; case TypePath.WILDCARD_BOUND: if (!(curType instanceof TypeInfo.DerivedTypeInfo) || (curType.getKind() != TypeInfo.TypeKind.EXTENDS && curType.getKind() != TypeInfo.TypeKind.SUPER)) { return null; } curType = ((TypeInfo.DerivedTypeInfo)curType).child(); result.write(TypeAnnotationContainer.Collector.WILDCARD_BOUND); break; case TypePath.TYPE_ARGUMENT: int argumentIndex = path.getStepArgument(i); if (!(curType instanceof TypeInfo.RefTypeInfo)) return null; curType = ((TypeInfo.RefTypeInfo)curType).genericComponent(argumentIndex); result.write(TypeAnnotationContainer.Collector.TYPE_ARGUMENT); result.write(argumentIndex); break; default: return null; } if (curType == null) return null; depth = curType.innerDepth(); } while (depth-- > 0) { result.write(TypeAnnotationContainer.Collector.ENCLOSING_CLASS); } return result.toByteArray(); }