@Override public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String descriptor, boolean visible) { TypeReference typeReference = new TypeReference(typeRef); switch (typeReference.getSort()) { case TypeReference.METHOD_FORMAL_PARAMETER: return visitParameterAnnotation(typeReference.getFormalParameterIndex(), descriptor, visible); case TypeReference.METHOD_RETURN: return visitAnnotation(descriptor, visible); default: // Corner case, limitation: the case METHOD_TYPE_PARAMETER is not yet supported. It happens when an annotation // is set on a type parameter. e.g.: <@Annotation T> Object method() return null; } }
@Override public MethodVisitor visitMethod(int flags, String name, String desc, @Nullable String signature, @Nullable String[] exceptions) { Preconditions.checkNotNull(name); Preconditions.checkNotNull(desc); if (!BytecodeCompleter.isSynthetic(flags)) { Preconditions.checkState((flags & Opcodes.ACC_BRIDGE) == 0, "bridge method not marked as synthetic in class " + className); // TODO(Godin): according to JVMS 4.7.24 - parameter can be marked as synthetic JavaType.MethodJavaType type = new JavaType.MethodJavaType( convertAsmTypes(org.objectweb.asm.Type.getArgumentTypes(desc)), convertAsmType(org.objectweb.asm.Type.getReturnType(desc)), getCompletedClassSymbolsType(exceptions), classSymbol ); final JavaSymbol.MethodJavaSymbol methodSymbol = new JavaSymbol.MethodJavaSymbol(bytecodeCompleter.filterBytecodeFlags(flags), name, type, classSymbol); classSymbol.members.enter(methodSymbol); if (signature != null) { new SignatureReader(signature).accept(new ReadMethodSignature(methodSymbol)); } methodSymbol.parameters = new OrderedScope(methodSymbol); for (int i = 0; i < type.argTypes.size(); i += 1) { methodSymbol.parameters.enter(new JavaSymbol.VariableJavaSymbol(0, "arg" + i, methodSymbol)); } // checks for annotations on the method and its parameters return new BytecodeMethodVisitor(methodSymbol, this); } return null; }
@Override public MethodVisitor visitMethod(int flags, String name, String desc, @Nullable String signature, @Nullable String[] exceptions) { Preconditions.checkNotNull(name); Preconditions.checkNotNull(desc); if (!BytecodeCompleter.isSynthetic(flags)) { Preconditions.checkState((flags & Opcodes.ACC_BRIDGE) == 0, "bridge method not marked as synthetic in class " + className); // TODO(Godin): according to JVMS 4.7.24 - parameter can be marked as synthetic JavaType.MethodJavaType type = new JavaType.MethodJavaType( convertAsmTypes(org.objectweb.asm.Type.getArgumentTypes(desc)), convertAsmType(org.objectweb.asm.Type.getReturnType(desc)), getCompletedClassSymbolsType(exceptions), classSymbol ); final JavaSymbol.MethodJavaSymbol methodSymbol = new JavaSymbol.MethodJavaSymbol(bytecodeCompleter.filterBytecodeFlags(flags), name, type, classSymbol); classSymbol.members.enter(methodSymbol); if (signature != null) { SignatureReader signatureReader = new SignatureReader(signature); signatureReader.accept(new TypeParameterDeclaration(methodSymbol)); signatureReader.accept(new ReadMethodSignature(methodSymbol)); } methodSymbol.parameters = new Scope(methodSymbol); for (int i = 0; i < type.argTypes.size(); i += 1) { methodSymbol.parameters.enter(new JavaSymbol.VariableJavaSymbol(0, "arg" + i, methodSymbol)); } // checks for annotations on the method and its parameters return new BytecodeMethodVisitor(methodSymbol, this); } return null; }
return new BytecodeMethodVisitor(methodSymbol, this);
@Override public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String descriptor, boolean visible) { TypeReference typeReference = new TypeReference(typeRef); switch (typeReference.getSort()) { case TypeReference.METHOD_FORMAL_PARAMETER: return visitParameterAnnotation(typeReference.getFormalParameterIndex(), descriptor, visible); case TypeReference.METHOD_RETURN: return visitAnnotation(descriptor, visible); default: // Corner case, limitation: the case METHOD_TYPE_PARAMETER is not yet supported. It happens when an annotation // is set on a type parameter. e.g.: <@Annotation T> Object method() return null; } }
return new BytecodeMethodVisitor(methodSymbol, this);