Example usage for org.objectweb.asm Opcodes ACC_FINAL

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

Introduction

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

Prototype

int ACC_FINAL

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

Click Source Link

Usage

From source file:com.facebook.buck.jvm.java.abi.AccessFlagsTest.java

License:Apache License

@Test
public void testFinalFlagOnMethod() throws IOException {
    testMethodFlags("final", Opcodes.ACC_FINAL);
}

From source file:com.facebook.buck.jvm.java.abi.AccessFlagsTest.java

License:Apache License

@Test
public void testFinalFlagOnClass() throws IOException {
    testClassFlags("final", Opcodes.ACC_FINAL);
}

From source file:com.facebook.buck.jvm.java.abi.AccessFlagsTest.java

License:Apache License

@Test
public void testEnumTypeFlags() throws IOException {
    testTypeFlags("enum Foo { Item }", "Foo", Opcodes.ACC_ENUM | Opcodes.ACC_SUPER | Opcodes.ACC_FINAL);
}

From source file:com.facebook.buck.jvm.java.abi.AccessFlagsTest.java

License:Apache License

@Test
public void testEnumVarFlags() throws IOException {
    compile("enum Foo { Item }");
    assertEquals(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_ENUM,
            accessFlags.getAccessFlags(findField("Item", elements.getTypeElement("Foo"))));
}

From source file:com.facebook.buck.tools.dxanalysis.MutabilityAnalyzer.java

License:Apache License

private boolean classIsDefinitelyMutable(ClassNode klass) {
    if (superClassIsDefinitelyMutable(klass.superName)) {
        log.add("Mutable parent: " + klass.name + " < " + klass.superName);
        return true;
    }/*from www .  ja  v  a  2 s  . c  om*/

    for (FieldNode field : klass.fields) {
        if ((field.access & Opcodes.ACC_STATIC) != 0) {
            continue;
        }
        if ((field.access & Opcodes.ACC_FINAL) == 0) {
            log.add("Non-final field: " + klass.name + "#" + field.name + ":" + field.desc);
            return true;
        }
        if (field.name.contains("$")) {
            // Generated fields are assumed to be effectively immutable.
            // This could, in principle, miss an issue like a static reference to a
            // seemingly-immutable inner class object that maintains a hidden reference
            // to its mutable outer object, but that seems unlikely.
            continue;
        }

        Type type = Type.getType(field.desc);

        if (IMMUTABLE_TYPE_SORTS.contains(type.getSort())) {
            continue;
        }

        if (type.getSort() != Type.OBJECT) {
            log.add("Odd sort: " + klass.name + "#" + field.name + ":" + field.desc);
            return true;
        }

        if (allClasses.keySet().contains(type.getInternalName())) {
            if (classesWithMutableDescendents.contains(type.getInternalName())) {
                log.add("Internal mutable field: " + klass.name + "#" + field.name + ":" + field.desc);
                return true;
            }
        } else {
            if (!EXTERNAL_IMMUTABLE_CLASSES.contains(type.getInternalName())) {
                log.add("External mutable field: " + klass.name + "#" + field.name + ":" + field.desc);
                return true;
            }
        }
    }

    return false;
}

From source file:com.facebook.buck.tools.dxanalysis.StaticStateAnalyzer.java

License:Apache License

private boolean isClassSafe(ClassNode klass) {
    boolean isSafe = true;

    // Look for mutable static fields.
    for (FieldNode field : klass.fields) {
        if ((field.access & Opcodes.ACC_STATIC) == 0) {
            continue;
        }//w w  w  .  j a  v  a2s  .  co m
        if ((field.access & Opcodes.ACC_FINAL) == 0) {
            log.add("Non-final static field: " + describe(klass, field));
            isSafe = false;
            continue;
        }
        if (!mutabilityAnalyzer.isTypeImmutable(field.desc)) {
            log.add("Mut-final static field: " + describe(klass, field));
            isSafe = false;
            continue;
        }
    }

    // Look for static synchronized methods.
    for (MethodNode method : klass.methods) {
        if ((method.access & Opcodes.ACC_STATIC) == 0) {
            continue;
        }

        if ((method.access & Opcodes.ACC_SYNCHRONIZED) != 0) {
            log.add("Synchronized static method: " + describe(klass, method));
            isSafe = false;
            continue;
        }
    }

    return isSafe;
}

From source file:com.gargoylesoftware.js.nashorn.internal.ir.debug.NashornTextifier.java

License:Open Source License

private static void appendAccess(final StringBuilder sb, final int access) {
    if ((access & Opcodes.ACC_PUBLIC) != 0) {
        sb.append("public ");
    }//from w  ww  .j  av a2s. c om
    if ((access & Opcodes.ACC_PRIVATE) != 0) {
        sb.append("private ");
    }
    if ((access & Opcodes.ACC_PROTECTED) != 0) {
        sb.append("protected ");
    }
    if ((access & Opcodes.ACC_FINAL) != 0) {
        sb.append("final ");
    }
    if ((access & Opcodes.ACC_STATIC) != 0) {
        sb.append("static ");
    }
    if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) {
        sb.append("synchronized ");
    }
    if ((access & Opcodes.ACC_VOLATILE) != 0) {
        sb.append("volatile ");
    }
    if ((access & Opcodes.ACC_TRANSIENT) != 0) {
        sb.append("transient ");
    }
    if ((access & Opcodes.ACC_ABSTRACT) != 0) {
        sb.append("abstract ");
    }
    if ((access & Opcodes.ACC_STRICT) != 0) {
        sb.append("strictfp ");
    }
    if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
        sb.append("synthetic ");
    }
    if ((access & Opcodes.ACC_MANDATED) != 0) {
        sb.append("mandated ");
    }
    if ((access & Opcodes.ACC_ENUM) != 0) {
        sb.append("enum ");
    }
}

From source file:com.gargoylesoftware.js.nashorn.internal.tools.nasgen.MemberInfo.java

License:Open Source License

boolean isFinal() {
    return (javaAccess & Opcodes.ACC_FINAL) != 0;
}

From source file:com.github.anba.es6draft.compiler.assembler.Code.java

License:Open Source License

/**
 * Adds a new class./*from w w  w.j a  v a2 s  .  c o  m*/
 * 
 * @param constantPool
 *            the constant pool instance to use
 * @return the class code instance which represents the new class
 */
ClassCode newClass(ConstantPool constantPool) {
    int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL;
    String className = mainClass.className + '~' + classes.size();
    ClassCode classCode = newClass(constantPool, access, className);
    classes.add(classCode);
    return classCode;
}

From source file:com.github.jasmo.obfuscate.FullAccessFlags.java

License:Open Source License

private int access(int access) {
    int a = Opcodes.ACC_PUBLIC;
    if ((access & Opcodes.ACC_NATIVE) != 0)
        a |= Opcodes.ACC_NATIVE;//from  www  .j  a  va  2 s.c om
    if ((access & Opcodes.ACC_ABSTRACT) != 0)
        a |= Opcodes.ACC_ABSTRACT;
    if ((access & Opcodes.ACC_ANNOTATION) != 0)
        a |= Opcodes.ACC_ANNOTATION;
    if ((access & Opcodes.ACC_BRIDGE) != 0)
        a |= Opcodes.ACC_BRIDGE;
    //if ((access & Opcodes.ACC_DEPRECATED) != 0) a |= Opcodes.ACC_DEPRECATED;
    if ((access & Opcodes.ACC_ENUM) != 0)
        a |= Opcodes.ACC_ENUM;
    if ((access & Opcodes.ACC_FINAL) != 0)
        a |= Opcodes.ACC_FINAL;
    if ((access & Opcodes.ACC_INTERFACE) != 0)
        a |= Opcodes.ACC_INTERFACE;
    if ((access & Opcodes.ACC_MANDATED) != 0)
        a |= Opcodes.ACC_MANDATED;
    if ((access & Opcodes.ACC_MODULE) != 0)
        a |= Opcodes.ACC_MODULE;
    if ((access & Opcodes.ACC_OPEN) != 0)
        a |= Opcodes.ACC_OPEN;
    if ((access & Opcodes.ACC_STATIC) != 0)
        a |= Opcodes.ACC_STATIC;
    if ((access & Opcodes.ACC_STATIC_PHASE) != 0)
        a |= Opcodes.ACC_STATIC_PHASE;
    if ((access & Opcodes.ACC_STRICT) != 0)
        a |= Opcodes.ACC_STRICT;
    if ((access & Opcodes.ACC_SUPER) != 0)
        a |= Opcodes.ACC_SUPER;
    if ((access & Opcodes.ACC_SYNCHRONIZED) != 0)
        a |= Opcodes.ACC_SYNCHRONIZED;
    if ((access & Opcodes.ACC_SYNTHETIC) != 0)
        a |= Opcodes.ACC_SYNTHETIC;
    if ((access & Opcodes.ACC_TRANSIENT) != 0)
        a |= Opcodes.ACC_TRANSIENT;
    if ((access & Opcodes.ACC_TRANSITIVE) != 0)
        a |= Opcodes.ACC_TRANSITIVE;
    if ((access & Opcodes.ACC_VARARGS) != 0)
        a |= Opcodes.ACC_VARARGS;
    if ((access & Opcodes.ACC_VOLATILE) != 0)
        a |= Opcodes.ACC_VOLATILE;
    return a;
}