Example usage for org.objectweb.asm Opcodes ACC_NATIVE

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

Introduction

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

Prototype

int ACC_NATIVE

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

Click Source Link

Usage

From source file:com.google.gwt.dev.shell.rewrite.RewriteJsniMethods.java

License:Apache License

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {

    boolean isNative = (access & Opcodes.ACC_NATIVE) != 0;
    access &= ~Opcodes.ACC_NATIVE;//w ww.  j  a  va2  s  . co  m

    MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);

    if (isNative) {
        mv = new MyMethodAdapter(mv, access, name, desc);
    }

    return mv;
}

From source file:com.google.gwt.jvm.asm.NativeMethodDispatchVisitor.java

License:Apache License

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    int nonNativeAccess = access & ~Opcodes.ACC_NATIVE;
    MethodVisitor visitMethod = delegate.visitMethod(nonNativeAccess, name, desc, signature, exceptions);
    if (isOpcode(access, Opcodes.ACC_NATIVE)) {
        boolean isStatic = isOpcode(access, Opcodes.ACC_STATIC);
        return new NativeMethodDelegatingVisitor(visitMethod, className, name, new Descriptor(desc), isStatic);
    } else {/* ww w  .j a v  a2  s . c o  m*/
        //System.out.println(className + "." + name + "(" + desc + ")");
        return new RewriteOverlayMethodDispatch(visitMethod, overlayTypePredicate);
    }
}

From source file:com.google.java.contract.core.agent.SpecificationClassAdapter.java

License:Open Source License

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
    if ((access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) != 0) {
        return mv;
    }// w w w .j a  v a  2  s  .  c o m

    return new SpecificationMethodAdapter(this, mv, access, name, desc);
}

From source file:com.googlecode.dex2jar.ir.ToStringUtil.java

License:Apache License

public static String getAccDes(int acc) {
    StringBuilder sb = new StringBuilder();
    if ((acc & Opcodes.ACC_PUBLIC) != 0) {
        sb.append("public ");
    }/*from  w  w  w  .  j  a v a  2  s.  com*/
    if ((acc & Opcodes.ACC_PROTECTED) != 0) {
        sb.append("protected ");
    }
    if ((acc & Opcodes.ACC_PRIVATE) != 0) {
        sb.append("private ");
    }
    if ((acc & Opcodes.ACC_STATIC) != 0) {
        sb.append("static ");
    }
    if ((acc & Opcodes.ACC_ABSTRACT) != 0 && (acc & Opcodes.ACC_INTERFACE) == 0) {
        sb.append("abstract ");
    }
    if ((acc & Opcodes.ACC_ANNOTATION) != 0) {
        sb.append("annotation ");
    }
    if ((acc & Opcodes.ACC_BRIDGE) != 0) {
        sb.append("bridge ");
    }
    if ((acc & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append("deprecated ");
    }
    if ((acc & Opcodes.ACC_ENUM) != 0) {
        sb.append("enum ");
    }
    if ((acc & Opcodes.ACC_FINAL) != 0) {
        sb.append("final ");
    }
    if ((acc & Opcodes.ACC_INTERFACE) != 0) {
        sb.append("interace ");
    }
    if ((acc & Opcodes.ACC_NATIVE) != 0) {
        sb.append("native ");
    }
    if ((acc & Opcodes.ACC_STRICT) != 0) {
        sb.append("strict ");
    }
    if ((acc & Opcodes.ACC_SYNCHRONIZED) != 0) {
        sb.append("synchronized ");
    }
    if ((acc & Opcodes.ACC_TRANSIENT) != 0) {
        sb.append("transient ");
    }
    if ((acc & Opcodes.ACC_VARARGS) != 0) {
        sb.append("varargs ");
    }
    if ((acc & Opcodes.ACC_VOLATILE) != 0) {
        sb.append("volatile ");
    }
    return sb.toString();
}

From source file:com.googlecode.dex2jar.tools.JarAccessCmd.java

License:Apache License

static int str2acc(String s) {
    if (s == null) {
        return 0;
    }//from  w  w w. j ava2s.  c  o  m
    int result = 0;
    s = s.toLowerCase();
    if (s.contains("public")) {
        result |= Opcodes.ACC_PUBLIC;
    }
    if (s.contains("private")) {
        result |= Opcodes.ACC_PRIVATE;
    }
    if (s.contains("protected")) {
        result |= Opcodes.ACC_PROTECTED;
    }
    if (s.contains("final")) {
        result |= Opcodes.ACC_FINAL;
    }
    if (s.contains("static")) {
        result |= Opcodes.ACC_STATIC;
    }
    if (s.contains("super")) {
        result |= Opcodes.ACC_SUPER;
    }
    if (s.contains("synchronized")) {
        result |= Opcodes.ACC_SYNCHRONIZED;
    }
    if (s.contains("volatile")) {
        result |= Opcodes.ACC_VOLATILE;
    }
    if (s.contains("bridge")) {
        result |= Opcodes.ACC_BRIDGE;
    }
    if (s.contains("transient")) {
        result |= Opcodes.ACC_TRANSIENT;
    }
    if (s.contains("varargs")) {
        result |= Opcodes.ACC_VARARGS;
    }
    if (s.contains("native")) {
        result |= Opcodes.ACC_NATIVE;
    }
    if (s.contains("strict")) {
        result |= Opcodes.ACC_STRICT;
    }
    if (s.contains("interface")) {
        result |= Opcodes.ACC_INTERFACE;
    }
    if (s.contains("abstract")) {
        result |= Opcodes.ACC_ABSTRACT;
    }
    if (s.contains("synthetic")) {
        result |= Opcodes.ACC_SYNTHETIC;
    }
    if (s.contains("annotation")) {
        result |= Opcodes.ACC_ANNOTATION;
    }
    if (s.contains("enum")) {
        result |= Opcodes.ACC_ENUM;
    }
    if (s.contains("deprecated")) {
        result |= Opcodes.ACC_DEPRECATED;
    }
    return result;
}

From source file:com.igormaznitsa.jute.TestClassProcessor.java

License:Apache License

@Override
public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature,
        final String[] exceptions) {
    if (this.inappropriateClass) {
        return null;
    }/*from   ww w .  j  ava  2s  .  com*/

    if (((access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE | Opcodes.ACC_STATIC)) != 0)
            || !desc.equals("()V") || name.startsWith("<")) {
        return null;
    }
    final boolean foundInExcludedList = isTestIncluded(desc);
    final boolean testExcluded = isTestExcluded(desc);

    final String logTestName = this.className + '#' + name;

    if (!foundInExcludedList) {
        this.logger.info("Test method " + logTestName + " is ignored because not presented in include list");
        return null;
    }

    if (testExcluded) {
        this.logger.info("Test " + logTestName + " is ignored because presented in exclude list");
        return null;
    }

    return new MethodVisitor(Opcodes.ASM5) {
        private boolean junitTest;
        private boolean juteTest;
        private boolean junitIgnore;
        private TestContainer detectedMethod;

        @Override
        public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
            if (detectedMethod == null) {
                detectedMethod = new TestContainer(classFilePath, className, name,
                        clazzJuteTestParameters == null ? baseParameters : clazzJuteTestParameters, null);
            }

            AnnotationVisitor result = null;
            if (desc.equals(JuteMojo.ANNO_TEST)) {
                this.junitTest = true;
            } else if (desc.equals(JuteMojo.ANNO_IGNORE)) {
                this.junitIgnore = true;
            } else if (desc.equals(JuteMojo.ANNO_JUTE)) {
                this.juteTest = true;
                result = detectedMethod;
            }
            return result;
        }

        @Override
        public void visitEnd() {
            if (this.detectedMethod == null) {
                this.detectedMethod = new TestContainer(classFilePath, className, name,
                        clazzJuteTestParameters == null ? baseParameters : clazzJuteTestParameters, null);
            }
            this.juteTest = this.juteTest || clazzJuteTestParameters != null;

            this.detectedMethod.setJUnitIgnore(this.junitIgnore);
            this.detectedMethod.setJUnitTest(this.junitTest);
            this.detectedMethod.setJuteTest(this.juteTest);

            if ((this.junitTest || this.juteTest)
                    && Utils.checkClassAndMethodForPattern(juteTestParameter,
                            this.detectedMethod.getClassName(), this.detectedMethod.getMethodName(), false)
                    && isTestCanBeListed(this.detectedMethod)) {
                detectedTestMethodList.add(detectedMethod);
            }
        }
    };
}

From source file:com.mogujie.instantrun.IncrementalChangeVisitor.java

License:Apache License

public IncrementalChangeVisitor(ClassNode classNode, List<ClassNode> parentNodes, ClassVisitor classVisitor) {
    super(classNode, parentNodes, classVisitor);
    methodNodes = classNode.methods;/*from   www .  jav  a  2  s .com*/
    for (int i = 0; i < classNode.methods.size(); i++) {
        MethodNode methodNode = (MethodNode) classNode.methods.get(i);
        if ((methodNode.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_PRIVATE)) == (Opcodes.ACC_NATIVE
                | Opcodes.ACC_PRIVATE)) {
            priNativeMtdSet.add(methodNode.name + "." + methodNode.desc);
            System.out.println("find private native mtd : " + methodNode.name + "." + methodNode.desc);
        }
        if ((methodNode.access & (Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_PRIVATE)) == (Opcodes.ACC_SYNCHRONIZED
                | Opcodes.ACC_PRIVATE)) {
            priSyncMtdSet.add(methodNode.name + "." + methodNode.desc);
            System.out.println("find private sync mtd : " + methodNode.name + "." + methodNode.desc);
        }
    }

}

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

License:Apache License

public boolean isNative() {
    return (this.methodNode.access & Opcodes.ACC_NATIVE) != 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 w  w. jav  a2  s . c om*/
 */
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.tdk.jcov.instrument.DataClass.java

License:Open Source License

void writeObject(DataOutput out) throws IOException {
    super.writeObject(out);
    out.writeUTF(name);/* w  ww.j  a v a2  s  .  com*/
    writeString(out, fullname);
    writeString(out, signature);
    writeString(out, source);
    writeString(out, superName);
    writeString(out, superInterfaces);
    out.writeLong(checksum);
    out.writeInt(access & ACCESS_MASK); // we don't save ALL the codes in XML, we shouldn't save all codes in net
    out.writeByte((differentiateClass ? 1 : 0) + (inner ? 2 : 0) + (anonym ? 4 : 0));

    out.writeShort(fields.size());
    for (DataField f : fields) {
        f.writeObject(out);
    }

    out.writeShort(methods.size());
    for (DataMethod m : methods) {
        if (m instanceof DataMethodEntryOnly) {
            if ((m.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) != 0) {
                out.write(2); // DMI
            } else {
                out.write(1); // DMEO
            }
        } else if (m instanceof DataMethodInvoked) {
            if ((m.access & (Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT)) != 0) {
                out.write(2); // DMI
            } else {
                out.write(1); // DMEO
            }
        } else if (m instanceof DataMethodWithBlocks) {
            out.write(3);
        } else {
            System.out.println("ERROR " + m.getFullName());
            out.write(4);
            throw new IOException(
                    "DataClass.writeObject - Unknown dataMethod class " + m.getClass().getName() + ".");
        }
        m.writeObject(out);
    }
}