Example usage for org.objectweb.asm Opcodes ACC_ABSTRACT

List of usage examples for org.objectweb.asm Opcodes ACC_ABSTRACT

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes ACC_ABSTRACT.

Prototype

int ACC_ABSTRACT

To view the source code for org.objectweb.asm Opcodes ACC_ABSTRACT.

Click Source Link

Usage

From source file:org.springframework.migrationanalyzer.contributions.bytecode.AsmUtils.java

License:Apache License

/**
 * Converts the given bitwise ORed <code>modifiers</code> into a {@link String}.
 * //from   w  w w.  ja va  2  s.  com
 * <p/>
 * 
 * The returned String should reflect the ordering recommended in the JLS:
 * 
 * <ul>
 * <li>Classes: <code>public protected private abstract static final strictfp</code></li>
 * <li>Fields: <code>public protected private static final transient volatile</code></li>
 * <li>Constructors: <code>public protected private</code></li>
 * <li>Methods: <code>public protected private abstract static final synchronized native strictfp</code></li>
 * </ul>
 * 
 * @param modifiers the modifiers
 * 
 * @return The String representation of the modifiers
 * 
 * @see Opcodes
 */
// CHECKSTYLE:OFF
static final String modifiersToString(int modifiers) {
    StringBuilder accessBuilder = new StringBuilder();

    if ((modifiers & Opcodes.ACC_PUBLIC) == Opcodes.ACC_PUBLIC) {
        accessBuilder.append("public ");
    }
    if ((modifiers & Opcodes.ACC_PROTECTED) == Opcodes.ACC_PROTECTED) {
        accessBuilder.append("protected ");
    }
    if ((modifiers & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE) {
        accessBuilder.append("private ");
    }
    if ((modifiers & Opcodes.ACC_ABSTRACT) == Opcodes.ACC_ABSTRACT) {
        accessBuilder.append("abstract ");
    }
    if ((modifiers & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC) {
        accessBuilder.append("static ");
    }
    if ((modifiers & Opcodes.ACC_FINAL) == Opcodes.ACC_FINAL) {
        accessBuilder.append("final ");
    }
    if ((modifiers & Opcodes.ACC_SYNCHRONIZED) == Opcodes.ACC_SYNCHRONIZED) {
        accessBuilder.append("synchronized ");
    }
    if ((modifiers & Opcodes.ACC_NATIVE) == Opcodes.ACC_NATIVE) {
        accessBuilder.append("native ");
    }
    if ((modifiers & Opcodes.ACC_TRANSIENT) == Opcodes.ACC_TRANSIENT) {
        accessBuilder.append("transient ");
    }
    if ((modifiers & Opcodes.ACC_VOLATILE) == Opcodes.ACC_VOLATILE) {
        accessBuilder.append("volatile ");
    }
    if ((modifiers & Opcodes.ACC_STRICT) == Opcodes.ACC_STRICT) {
        accessBuilder.append("strictfp ");
    }

    return accessBuilder.toString().trim();
}

From source file:org.springframework.migrationanalyzer.contributions.bytecode.AsmUtilsTests.java

License:Apache License

@Test
public void abstractAccess() {
    assertEquals("abstract", AsmUtils.modifiersToString(Opcodes.ACC_ABSTRACT));
}

From source file:org.springframework.migrationanalyzer.contributions.bytecode.AsmUtilsTests.java

License:Apache License

@Test
public void classAccessOrdering() {
    assertEquals("public protected private abstract static final strictfp",
            AsmUtils.modifiersToString(Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE
                    | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_STRICT));
}

From source file:org.springframework.migrationanalyzer.contributions.bytecode.AsmUtilsTests.java

License:Apache License

@Test
public void methodAccessOrdering() {
    assertEquals("public protected private abstract static final synchronized native strictfp",
            AsmUtils.modifiersToString(Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE
                    | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED
                    | Opcodes.ACC_NATIVE | Opcodes.ACC_STRICT));
}

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 ");
    }//from w ww . j  av a 2s  . c  om
    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.springsource.loaded.test.infra.ClassPrinter.java

License:Apache License

public static String toAccessForMember(int flags) {
    StringBuilder sb = new StringBuilder();
    if ((flags & Opcodes.ACC_PUBLIC) != 0) {
        sb.append("public ");
    }/*from   ww  w  .  j av a  2  s.c  o m*/
    if ((flags & Opcodes.ACC_PRIVATE) != 0) {
        sb.append("private ");
    }
    if ((flags & Opcodes.ACC_STATIC) != 0) {
        sb.append("static ");
    }
    if ((flags & Opcodes.ACC_PROTECTED) != 0) {
        sb.append("protected ");
    }
    if ((flags & Opcodes.ACC_FINAL) != 0) {
        sb.append("final ");
    }
    if ((flags & Opcodes.ACC_SUPER) != 0) {
        sb.append("super ");
    }
    if ((flags & Opcodes.ACC_INTERFACE) != 0) {
        sb.append("interface ");
    }
    if ((flags & Opcodes.ACC_ABSTRACT) != 0) {
        sb.append("abstract ");
    }
    if ((flags & Opcodes.ACC_SYNTHETIC) != 0) {
        sb.append("synthetic ");
    }
    if ((flags & Opcodes.ACC_ANNOTATION) != 0) {
        sb.append("annotation ");
    }
    if ((flags & Opcodes.ACC_ENUM) != 0) {
        sb.append("enum ");
    }
    if ((flags & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append("deprecated ");
    }
    return sb.toString().trim();
}

From source file:org.teavm.classlib.impl.report.JCLComparisonVisitor.java

License:Apache License

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    if (classReader == null || (access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) == 0) {
        return null;
    }//ww  w  .  ja  v  a  2s . c  om

    JCLItem item = new JCLItem(JCLItemType.METHOD, name + desc);
    MethodReader method = findMethod(classReader, MethodDescriptor.parse(name + desc));
    if (method == null) {
        item.status = JCLStatus.MISSING;
    } else {
        if ((access & Opcodes.ACC_ABSTRACT) == 0 && method.hasModifier(ElementModifier.ABSTRACT)) {
            item.status = JCLStatus.MISSING;
        } else {
            item.status = method.getOwnerName().equals(classReader.getName()) ? JCLStatus.FOUND
                    : JCLStatus.PARTIAL;
        }
    }
    item.visibility = (access & Opcodes.ACC_PROTECTED) != 0 ? JCLVisibility.PROTECTED : JCLVisibility.PUBLIC;
    jclClass.items.add(item);
    if (item.status == JCLStatus.MISSING) {
        jclClass.status = JCLStatus.PARTIAL;
    }
    return null;
}

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 v a2 s  . c  om

    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:pl.clareo.coroutines.core.ClassAnalyzer.java

License:Apache License

@SuppressWarnings("unchecked")
void analyze() {//from w w  w .ja v  a 2s.com
    List<MethodNode> methods = classNode.methods;
    for (MethodNode methodNode : methods) {
        List<AnnotationNode> annotations = methodNode.invisibleAnnotations;
        if (annotations != null) {
            int accessFlags = methodNode.access;
            for (AnnotationNode annotationNode : annotations) {
                if (annotationNode.desc.equals(COROUTINE_DESCRIPTOR)) {
                    boolean isAbstract = (accessFlags & Opcodes.ACC_ABSTRACT) != 0;
                    boolean isStatic = (accessFlags & Opcodes.ACC_STATIC) != 0;
                    boolean isConstructor = methodNode.name.equals(isStatic ? "<clinit>" : "<init>");
                    boolean returnsCoIterator = Type.getReturnType(methodNode.desc).getDescriptor()
                            .equals(CO_ITERATOR_DESCRIPTOR);
                    boolean isCorrect = !isAbstract & returnsCoIterator & !isConstructor;
                    if (isAbstract) {
                        logger.warning("Abstract method " + methodNode.name + " annotated as coroutine");
                    }
                    if (!returnsCoIterator) {
                        logger.warning("Method " + methodNode.name + " does not return CoIterator");
                    }
                    if (isConstructor) {
                        logger.warning("Cannot make a coroutine from constructor");
                    }
                    if (isCorrect) {
                        coroutineMethods.add(methodNode);
                    }
                }
            }
        }
    }
}

From source file:serianalyzer.SerianalyzerClassMethodVisitor.java

License:Open Source License

/**
 * {@inheritDoc}//  www.  ja v a  2 s .co m
 *
 * @see org.objectweb.asm.ClassVisitor#visitMethod(int, java.lang.String, java.lang.String, java.lang.String,
 *      java.lang.String[])
 */
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    if (this.ref.getMethod().equals(name) && this.ref.getSignature().equals(desc)) {
        if (this.log.isTraceEnabled()) {
            this.log.trace(
                    String.format("Found %s::%s with signature %s", this.ref.getTypeNameString(), name, desc)); //$NON-NLS-1$
        }
        if ((access & Opcodes.ACC_ABSTRACT) != 0) {
            return super.visitMethod(access, name, desc, signature, exceptions);
        }
        this.found = true;
        if ((access & Opcodes.ACC_NATIVE) != 0) {
            this.analyzer.getState().reportCall(this.ref);
            return super.visitMethod(access, name, desc, signature, exceptions);
        }

        return new SerianalyzerMethodVisitor(this, this.ref, this.actualType);
    }

    if (this.log.isTraceEnabled()) {
        this.log.trace(String.format("Mismatch %s %s %s vs. %s", name, desc, signature, this.ref)); //$NON-NLS-1$
    }

    return super.visitMethod(access, name, desc, signature, exceptions);
}