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:com.microsoft.applicationinsights.agent.internal.agent.ByteCodeUtilsTest.java

License:Open Source License

@Test
public void testIsAbstract() throws Exception {
    assertTrue(ByteCodeUtils.isAbstract(Opcodes.ACC_ABSTRACT));
}

From source file:com.microsoft.applicationinsights.agent.internal.agent.ByteCodeUtilsTest.java

License:Open Source License

@Test
public void testNotIsAbstract() throws Exception {
    assertFalse(ByteCodeUtils.isAbstract(~Opcodes.ACC_ABSTRACT));
}

From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodNodeAdapter.java

License:Apache License

public boolean isAbstract() {
    return (this.methodNode.access & Opcodes.ACC_ABSTRACT) != 0;
}

From source file:com.poolik.classfinder.info.ClassInfo.java

License:BSD License

/**
 * Convert an ASM access mask to a reflection Modifier mask.
 *
 * @param asmAccessMask the ASM access mask
 * @return the Modifier mask//w  ww  .  jav a2s  .  c  o m
 */
private int convertAccessMaskToModifierMask(int asmAccessMask) {
    int modifier = 0;

    // Convert the ASM access info into Reflection API modifiers.

    if ((asmAccessMask & Opcodes.ACC_FINAL) != 0)
        modifier |= Modifier.FINAL;

    if ((asmAccessMask & Opcodes.ACC_NATIVE) != 0)
        modifier |= Modifier.NATIVE;

    if ((asmAccessMask & Opcodes.ACC_INTERFACE) != 0)
        modifier |= Modifier.INTERFACE;

    if ((asmAccessMask & Opcodes.ACC_ABSTRACT) != 0)
        modifier |= Modifier.ABSTRACT;

    if ((asmAccessMask & Opcodes.ACC_PRIVATE) != 0)
        modifier |= Modifier.PRIVATE;

    if ((asmAccessMask & Opcodes.ACC_PROTECTED) != 0)
        modifier |= Modifier.PROTECTED;

    if ((asmAccessMask & Opcodes.ACC_PUBLIC) != 0)
        modifier |= Modifier.PUBLIC;

    if ((asmAccessMask & Opcodes.ACC_STATIC) != 0)
        modifier |= Modifier.STATIC;

    if ((asmAccessMask & Opcodes.ACC_STRICT) != 0)
        modifier |= Modifier.STRICT;

    if ((asmAccessMask & Opcodes.ACC_SYNCHRONIZED) != 0)
        modifier |= Modifier.SYNCHRONIZED;

    if ((asmAccessMask & Opcodes.ACC_TRANSIENT) != 0)
        modifier |= Modifier.TRANSIENT;

    if ((asmAccessMask & Opcodes.ACC_VOLATILE) != 0)
        modifier |= Modifier.VOLATILE;

    return modifier;
}

From source file:com.sun.fortress.compiler.asmbytecodeoptimizer.ByteCodeMethodVisitor.java

License:Open Source License

public boolean isAbstractMethod() {
    return ((access & Opcodes.ACC_ABSTRACT) > 0);
}

From source file:com.sun.fortress.compiler.codegen.ManglingMethodVisitor.java

License:Open Source License

@Override
public void visitEnd() {

    // Special case here for abstract methods
    if (mv instanceof TraceMethodVisitor && 0 != (access & Opcodes.ACC_ABSTRACT)) {
        System.out.println(name + desc + " " + Integer.toHexString(access));
        List t = ((TraceMethodVisitor) mv).getText();
        for (Object s : t)
            System.out.print(s);//from w  w w .ja  v  a2 s. c o  m
    }

    super.visitEnd();
}

From source file:com.sun.fortress.runtimeSystem.InstantiatingClassloader.java

License:Open Source License

private static byte[] instantiateAnyTuple(String dename, List<String> parameters) {
    /*/*from   w  w  w  .j a va2 s  . c  o  m*/
     * Single parameter, N, which is the arity of the tuple.
     * 
     * implements Ljava/util/List;
     * implements Lfortress/AnyType$Any;
     * abstract methods o1 ... oN (or 0 ... N-1, depending on tuple origin)
     */
    int n = Integer.parseInt(parameters.get(0));

    ManglingClassWriter cw = new ManglingClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    String[] superInterfaces = {
            //        "java/util/List",
            "fortress/AnyType$Any" };
    cw.visit(JVM_BYTECODE_VERSION, Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT | Opcodes.ACC_INTERFACE, dename,
            null, "java/lang/Object", superInterfaces);

    for (int i = 0; i < n; i++) {
        String m = TUPLE_OBJECT_ELT_PFX + (i + Naming.TUPLE_ORIGIN);
        String sig = UNTYPED_GETTER_SIG;
        interfaceMethod(cw, m, sig);
    }

    cw.visitEnd();
    return cw.toByteArray();
}

From source file:com.sun.fortress.runtimeSystem.InstantiatingClassloader.java

License:Open Source License

private static byte[] instantiateAnyConcreteTuple(String dename, List<String> parameters) {
    /*//from   w  ww  . ja  va2 s .com
     * Single parameter, N, which is the arity of the tuple.
     * 
     * extends Ljava/util/AbstractList;
     * implements LAnyTuple[\N\];
     * int size() { return N; }
     * Object get(int n) {
     *    if (n >= N || n < 0) {
     *       throw new IndexOutOfBoundsException();
     *    } else {
     *      // binary search tree returning o1 ... oN
     *    }
     * }
     */

    ManglingClassWriter cw = new ManglingClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    final String super_type = "java/lang/Object";

    final int n = Integer.parseInt(parameters.get(0));
    final String any_tuple_n = ANY_TUPLE + Naming.LEFT_OXFORD + n + Naming.RIGHT_OXFORD;
    String[] superInterfaces = { any_tuple_n };
    cw.visit(JVM_BYTECODE_VERSION, Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT, dename, null, super_type,
            superInterfaces);

    simpleInitMethod(cw, super_type);

    { // size method
        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "size", "()I", null, null);
        mv.visitCode();
        mv.visitIntInsn(BIPUSH, n);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }

    { // get method  
        final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "get", "(I)Ljava/lang/Object;", null, null);
        mv.visitCode();
        mv.visitVarInsn(ILOAD, 1);
        mv.visitIntInsn(BIPUSH, n);
        Label l1 = new Label();
        mv.visitJumpInsn(IF_ICMPGE, l1);
        mv.visitVarInsn(ILOAD, 1);
        Label l2 = new Label();
        mv.visitJumpInsn(IFGE, l2);
        mv.visitLabel(l1);
        mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
        mv.visitTypeInsn(NEW, "java/lang/IndexOutOfBoundsException");
        mv.visitInsn(DUP);
        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/IndexOutOfBoundsException", "<init>", "()V");
        mv.visitInsn(ATHROW);

        FnVoidVoid geti = new FnVoidVoid() {

            @Override
            public void apply() {
                mv.visitVarInsn(ILOAD, 1);
            }

        };

        FnVoid<Integer> leaf = new FnVoid<Integer>() {

            @Override
            public void apply(Integer x) {
                mv.visitVarInsn(ALOAD, 0);
                mv.visitMethodInsn(INVOKEINTERFACE, any_tuple_n,
                        TUPLE_OBJECT_ELT_PFX + (Naming.TUPLE_ORIGIN + x), UNTYPED_GETTER_SIG);
                mv.visitInsn(ARETURN);
            }

        };

        visitBinaryTree(mv, 0, n - 1, l2, geti, leaf);

        mv.visitMaxs(2, 2);
        mv.visitEnd();

    }

    cw.visitEnd();
    return cw.toByteArray();
}

From source file:com.sun.tdk.jcov.instrument.DataClass.java

License:Open Source License

/**
 * Checks whether this class has 'abstract' modifier
 *
 * @return true if class is abstract/*from  www .j ava2s.  co  m*/
 */
public boolean hasAbstractModifier() {
    return (access & Opcodes.ACC_ABSTRACT) != 0;
}

From source file:com.sun.tdk.jcov.instrument.DataClass.java

License:Open Source License

/**
 * XML Generation. Not supposed to use outside.
 *//*from  ww w .j av  a  2 s. c o  m*/
@Override
void xmlGen(XmlContext ctx) {

    if ((!ctx.skipNotCoveredClasses || wasHit() && methods.size() > 0)) {

        // check abstract on
        if (ctx.showAbstract) {
            super.xmlGen(ctx);
        } else if ((access & Opcodes.ACC_INTERFACE) == 0) {
            super.xmlGen(ctx);
        } else {
            // cheking interface
            // find default methods even when abstract off
            List<DataMethod> onlyDefaultMethods = new ArrayList<DataMethod>();
            for (DataMethod method : methods) {
                if ((method.getAccess() & Opcodes.ACC_ABSTRACT) == 0) {
                    onlyDefaultMethods.add(method);
                }
            }
            this.methods.retainAll(onlyDefaultMethods);

            if (methods.size() > 0) {
                super.xmlGen(ctx);
            }
        }
    }

}