List of usage examples for org.objectweb.asm Opcodes ACC_BRIDGE
int ACC_BRIDGE
To view the source code for org.objectweb.asm Opcodes ACC_BRIDGE.
Click Source Link
From source file:org.mbte.groovypp.compiler.ClassNodeCache.java
License:Apache License
static void addMethods(Map<String, Object> nameMap, Map<String, Object> staticMethodsMap, Map<String, Object> superMethodsMap, List<MethodNode> methods, boolean usePrivate, ClassNode type) { for (MethodNode m : methods) { if ((m.getModifiers() & Opcodes.ACC_BRIDGE) == 0) { if (usePrivate || !m.isPrivate()) { nameMap.put(m.getName(), addMethodToList(nameMap.get(m.getName()), m, type)); if (m.isStatic()) { staticMethodsMap.put(m.getName(), addMethodToList(staticMethodsMap.get(m.getName()), m, type)); if (m.getParameters().length > 0) { if (m.getParameters()[0].getType().equals(m.getDeclaringClass())) { nameMap.put(m.getName(), addMethodToList(nameMap.get(m.getName()), createDGM(m), type)); }/*w w w . j a va 2 s. com*/ } } } } if (m.isPrivate()) continue; if (m instanceof DGM) continue; if (m.getDeclaringClass() == type) continue; if (m.isStatic()) continue; superMethodsMap.put(m.getName(), addMethodToList(superMethodsMap.get(m.getName()), m, type)); } }
From source file:org.mbte.groovypp.compiler.CompileASTTransform.java
License:Apache License
public void visit(ASTNode[] nodes, final SourceUnit source) { if (!(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) { throw new RuntimeException("Internal error: wrong types: $node.class / $parent.class"); }/* w w w . j a va2s. co m*/ AnnotatedNode parent = (AnnotatedNode) nodes[1]; Map<MethodNode, TypePolicy> toProcess = new LinkedHashMap<MethodNode, TypePolicy>(); final ClassNode classNode; if (parent instanceof MethodNode) { TypePolicy classPolicy = getPolicy(parent.getDeclaringClass(), source, TypePolicy.DYNAMIC); TypePolicy methodPolicy = getPolicy(parent, source, classPolicy); classNode = parent.getDeclaringClass(); if (methodPolicy != TypePolicy.DYNAMIC) { final MethodNode mn = (MethodNode) parent; addMethodToProcessingQueue(source, toProcess, methodPolicy, mn, null); } } else if (parent instanceof ClassNode) { classNode = (ClassNode) parent; TypePolicy classPolicy = getPolicy(classNode, source, TypePolicy.DYNAMIC); allMethods(source, toProcess, classNode, classPolicy); } else if (parent instanceof PackageNode) { TypePolicy modulePolicy = getPolicy(parent, source, TypePolicy.DYNAMIC); for (ClassNode clazz : source.getAST().getClasses()) { if (clazz instanceof InnerClassNode) continue; allMethods(source, toProcess, clazz, modulePolicy); } } else { int line = parent.getLineNumber(); int col = parent.getColumnNumber(); source.getErrorCollector() .addError(new SyntaxErrorMessage(new SyntaxException( "@Typed applicable only to classes or methods or package declaration" + '\n', line, col), source), true); return; } final Expression debugMember = ((AnnotationNode) nodes[0]).getMember("debug"); boolean debug = debugMember != null && debugMember instanceof ConstantExpression && ((ConstantExpression) debugMember).getValue().equals(Boolean.TRUE); final Expression fastArraysMember = ((AnnotationNode) nodes[0]).getMember("fastArrays"); boolean fastArrays = fastArraysMember == null || fastArraysMember instanceof ConstantExpression && !((ConstantExpression) fastArraysMember).getValue().equals(Boolean.FALSE); // here we want to improve method types for (Map.Entry<MethodNode, TypePolicy> entry : toProcess.entrySet()) { final MethodNode mn = entry.getKey(); improveMethodTypes(mn); } SourceUnitContext context = new SourceUnitContext(); for (Map.Entry<MethodNode, TypePolicy> entry : toProcess.entrySet()) { MethodNode mn = entry.getKey(); final TypePolicy policy = entry.getValue(); final List<AnnotationNode> anns = mn.getAnnotations(COMPILE_TYPE); boolean localDebug = debug; boolean localFastArrays = fastArrays; if (!anns.isEmpty()) { final AnnotationNode ann = anns.get(0); final Expression localDebugMember = ann.getMember("debug"); if (localDebugMember != null) localDebug = localDebugMember instanceof ConstantExpression && ((ConstantExpression) localDebugMember).getValue().equals(Boolean.TRUE); final Expression localFastArraysMember = ann.getMember("fastArrays"); localFastArrays = localFastArraysMember == null || localFastArraysMember instanceof ConstantExpression && !((ConstantExpression) localFastArraysMember).getValue().equals(Boolean.FALSE); } if ((mn.getModifiers() & Opcodes.ACC_BRIDGE) != 0 || mn.isAbstract()) continue; final Statement code = mn.getCode(); if (!(code instanceof BytecodeSequence)) { if (!mn.getName().equals("$doCall")) { String name = mn.getName().equals("<init>") ? "_init_" : mn.getName().equals("<clinit>") ? "_clinit_" : mn.getName(); StaticMethodBytecode.replaceMethodCode(source, context, mn, new CompilerStack(null), localDebug ? 0 : -1, localFastArrays, policy, mn.getDeclaringClass().getName() + "$" + name); } } } for (MethodNode node : context.generatedFieldGetters.values()) { StaticMethodBytecode.replaceMethodCode(source, context, node, new CompilerStack(null), -1, true, TypePolicy.STATIC, "Neverused"); } for (MethodNode node : context.generatedFieldSetters.values()) { StaticMethodBytecode.replaceMethodCode(source, context, node, new CompilerStack(null), -1, true, TypePolicy.STATIC, "Neverused"); } for (MethodNode node : context.generatedMethodDelegates.values()) { StaticMethodBytecode.replaceMethodCode(source, context, node, new CompilerStack(null), -1, true, TypePolicy.STATIC, "Neverused"); } }
From source file:org.pitest.classinfo.BridgeMethodFilter.java
License:Apache License
private boolean isSynthetic(final Integer access) { return (access & Opcodes.ACC_BRIDGE) == 0; }
From source file:org.revapi.java.compilation.ClassTreeInitializer.java
License:Apache License
private static boolean isAccessible(int access) { return (access & Opcodes.ACC_SYNTHETIC) == 0 && (access & Opcodes.ACC_BRIDGE) == 0 && ((access & Opcodes.ACC_PUBLIC) != 0 || (access & Opcodes.ACC_PROTECTED) != 0); }
From source file:org.sonar.java.resolve.BytecodeVisitor.java
License:Open Source License
@Override public MethodVisitor visitMethod(int flags, String name, String desc, @Nullable String signature, @Nullable String[] exceptions) { Preconditions.checkNotNull(name);//from w w w. ja v a2s .c o m Preconditions.checkNotNull(desc); if (!BytecodeCompleter.isSynthetic(flags)) { if ((flags & Opcodes.ACC_BRIDGE) != 0) { LOG.warn("bridge method {} not marked as synthetic in class {}", name, className); return null; } // TODO(Godin): according to JVMS 4.7.24 - parameter can be marked as synthetic MethodJavaType type = new 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; }
From source file:org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { // Skip bridge methods - we're only interested in original annotation-defining user methods. // On JDK 8, we'd otherwise run into double detection of the same annotated method... if ((access & Opcodes.ACC_BRIDGE) != 0) { return super.visitMethod(access, name, desc, signature, exceptions); }/*from ww w. j a v a2 s.com*/ return new MethodMetadataReadingVisitor(name, access, getClassName(), this.classLoader, this.methodMetadataSet); }
From source file:org.springsource.loaded.test.infra.ClassPrinter.java
License:Apache License
private String toAccessForClass(int flags) { StringBuilder sb = new StringBuilder(); if ((flags & Opcodes.ACC_PUBLIC) != 0) { sb.append("public "); }/* ww w .j av a 2 s . com*/ if ((flags & Opcodes.ACC_PRIVATE) != 0) { sb.append("private "); } if ((flags & Opcodes.ACC_PROTECTED) != 0) { sb.append("protected "); } if ((flags & Opcodes.ACC_STATIC) != 0) { sb.append("static "); } if ((flags & Opcodes.ACC_FINAL) != 0) { sb.append("final "); } if ((flags & Opcodes.ACC_SYNCHRONIZED) != 0) { sb.append("synchronized "); } if ((flags & Opcodes.ACC_BRIDGE) != 0) { sb.append("bridge "); } if ((flags & Opcodes.ACC_VARARGS) != 0) { sb.append("varargs "); } if ((flags & Opcodes.ACC_NATIVE) != 0) { sb.append("native "); } if ((flags & Opcodes.ACC_ABSTRACT) != 0) { sb.append("abstract "); } if ((flags & Opcodes.ACC_SYNTHETIC) != 0) { sb.append("synthetic "); } if ((flags & Opcodes.ACC_DEPRECATED) != 0) { sb.append("deprecated "); } if ((flags & Opcodes.ACC_INTERFACE) != 0) { sb.append("interface "); } return sb.toString().trim(); }
From source file:org.teavm.parsing.Parser.java
License:Apache License
public static void parseModifiers(int access, ElementHolder member) { if ((access & Opcodes.ACC_PRIVATE) != 0) { member.setLevel(AccessLevel.PRIVATE); } else if ((access & Opcodes.ACC_PROTECTED) != 0) { member.setLevel(AccessLevel.PROTECTED); } else if ((access & Opcodes.ACC_PUBLIC) != 0) { member.setLevel(AccessLevel.PUBLIC); }/*from w w w .j a va 2s . c o m*/ if ((access & Opcodes.ACC_ABSTRACT) != 0) { member.getModifiers().add(ElementModifier.ABSTRACT); } if ((access & Opcodes.ACC_ANNOTATION) != 0) { member.getModifiers().add(ElementModifier.ANNOTATION); } if ((access & Opcodes.ACC_BRIDGE) != 0) { member.getModifiers().add(ElementModifier.BRIDGE); } if ((access & Opcodes.ACC_DEPRECATED) != 0) { member.getModifiers().add(ElementModifier.DEPRECATED); } if ((access & Opcodes.ACC_ENUM) != 0) { member.getModifiers().add(ElementModifier.ENUM); } if ((access & Opcodes.ACC_FINAL) != 0) { member.getModifiers().add(ElementModifier.FINAL); } if ((access & Opcodes.ACC_INTERFACE) != 0) { member.getModifiers().add(ElementModifier.INTERFACE); } if ((access & Opcodes.ACC_NATIVE) != 0) { member.getModifiers().add(ElementModifier.NATIVE); } if ((access & Opcodes.ACC_STATIC) != 0) { member.getModifiers().add(ElementModifier.STATIC); } if ((access & Opcodes.ACC_STRICT) != 0) { member.getModifiers().add(ElementModifier.STRICT); } if ((access & Opcodes.ACC_SUPER) != 0) { member.getModifiers().add(ElementModifier.SUPER); } if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) { member.getModifiers().add(ElementModifier.SYNCHRONIZED); } if ((access & Opcodes.ACC_SYNTHETIC) != 0) { member.getModifiers().add(ElementModifier.SYNTHETIC); } if ((access & Opcodes.ACC_TRANSIENT) != 0) { member.getModifiers().add(ElementModifier.TRANSIENT); } if ((access & Opcodes.ACC_VARARGS) != 0) { member.getModifiers().add(ElementModifier.VARARGS); } if ((access & Opcodes.ACC_VOLATILE) != 0) { member.getModifiers().add(ElementModifier.VOLATILE); } }
From source file:the.bytecode.club.bytecodeviewer.decompilers.bytecode.MethodNodeDecompiler.java
License:Open Source License
private static String getAccessString(int access) { // public, protected, private, abstract, static, // final, synchronized, native & strictfp are permitted List<String> tokens = new ArrayList<String>(); if ((access & Opcodes.ACC_PUBLIC) != 0) tokens.add("public"); if ((access & Opcodes.ACC_PRIVATE) != 0) tokens.add("private"); if ((access & Opcodes.ACC_PROTECTED) != 0) tokens.add("protected"); if ((access & Opcodes.ACC_STATIC) != 0) tokens.add("static"); if ((access & Opcodes.ACC_ABSTRACT) != 0) tokens.add("abstract"); if ((access & Opcodes.ACC_FINAL) != 0) tokens.add("final"); if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) tokens.add("synchronized"); if ((access & Opcodes.ACC_NATIVE) != 0) tokens.add("native"); if ((access & Opcodes.ACC_STRICT) != 0) tokens.add("strictfp"); if ((access & Opcodes.ACC_BRIDGE) != 0) tokens.add("bridge"); if ((access & Opcodes.ACC_VARARGS) != 0) tokens.add("varargs"); if (tokens.size() == 0) return ""; // hackery delimeters StringBuilder sb = new StringBuilder(tokens.get(0)); for (int i = 1; i < tokens.size(); i++) { sb.append(" "); sb.append(tokens.get(i));//from w ww . java2 s . c om } return sb.toString(); }