Example usage for org.objectweb.asm Opcodes ACC_PUBLIC

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

Introduction

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

Prototype

int ACC_PUBLIC

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

Click Source Link

Usage

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

License:Apache License

@Test
public void testNotConfusedByOtherMethodAccessFlagsIncluding() {
    testIncludesMethodWithAccess(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT | Opcodes.ACC_SYNCHRONIZED);
}

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

License:Apache License

@Test
public void testIncludesInnerClassEntryForClassItself() {
    visitClass(mockVisitor, "Foo$Inner");
    mockVisitor.visitInnerClass("Foo$Inner", "Foo", "Inner", Opcodes.ACC_PUBLIC);
    replay(mockVisitor);// ww w . j a  v a 2 s. com

    visitClass(filteringVisitor, "Foo$Inner");
    filteringVisitor.visitInnerClass("Foo$Inner", "Foo", "Inner", Opcodes.ACC_PUBLIC);
    verify(mockVisitor);
}

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

License:Apache License

@Test
public void testIncludesInnerClassEntryForInnerClass() {
    visitClass(mockVisitor, "Foo");
    mockVisitor.visitInnerClass("Foo$Inner", "Foo", "Inner", Opcodes.ACC_PUBLIC);
    replay(mockVisitor);/*  w w w . j  av a2  s. com*/

    visitClass(filteringVisitor, "Foo");
    filteringVisitor.visitInnerClass("Foo$Inner", "Foo", "Inner", Opcodes.ACC_PUBLIC);
    verify(mockVisitor);
}

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

License:Apache License

@Test
public void testIncludesInnerClassEntryForReferencedOtherClassInnerClass() {
    filteringVisitor = new AbiFilteringClassVisitor(mockVisitor, ImmutableSet.of("Bar$Inner"));

    visitClass(mockVisitor, "Foo");
    mockVisitor.visitInnerClass("Bar$Inner", "Bar", "Inner", Opcodes.ACC_PUBLIC);
    replay(mockVisitor);/*from   w w w  . j av  a 2 s  .c  o m*/

    visitClass(filteringVisitor, "Foo");
    filteringVisitor.visitInnerClass("Bar$Inner", "Bar", "Inner", Opcodes.ACC_PUBLIC);
    verify(mockVisitor);
}

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

License:Apache License

@Test
public void testExcludesInnerClassEntryForUnreferencedOtherClassInnerClass() {
    visitClass(mockVisitor, "Foo");
    replay(mockVisitor);/*from   www . j  ava2 s. com*/

    visitClass(filteringVisitor, "Foo");
    filteringVisitor.visitInnerClass("Bar$Inner", "Bar", "Inner", Opcodes.ACC_PUBLIC);
    verify(mockVisitor);
}

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

License:Apache License

@Test
public void testExcludesSyntheticInnerClasses() {
    visitClass(mockVisitor, "Foo");
    replay(mockVisitor);/*ww  w.  j  a  va  2s .co m*/

    visitClass(filteringVisitor, "Foo");
    filteringVisitor.visitInnerClass("Foo$Inner", "Foo", "Inner", Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC);
    verify(mockVisitor);
}

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

License:Apache License

private static void visitClass(ClassVisitor cv, String name) {
    cv.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, name, null, "java/lang/Object", null);
}

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

License:Apache License

/**
 * Gets the class access flags (see JVMS8 4.1) for the given type element as they should appear in
 * the ClassNode of a class file. Inner-class specific flags are not allowed in that node,
 * presumably for compatibility reasons.
 *//*  w  w w.j  a v a2s . com*/
public int getAccessFlagsForClassNode(TypeElement e) {
    // Static never makes it into the file for classes
    int accessFlags = getAccessFlags(e) & ~Opcodes.ACC_STATIC;
    if (e.getNestingKind() != NestingKind.TOP_LEVEL) {
        if (e.getModifiers().contains(Modifier.PROTECTED)) {
            // It looks like inner classes with protected visibility get marked as public, and then
            // their InnerClasses attributes override that more specifically
            accessFlags = (accessFlags & ~Opcodes.ACC_PROTECTED) | Opcodes.ACC_PUBLIC;
        } else if (e.getModifiers().contains(Modifier.PRIVATE)) {
            // It looks like inner classes with private visibility get marked as package, and then
            // their InnerClasses attributes override that more specifically
            accessFlags = (accessFlags & ~Opcodes.ACC_PRIVATE);
        }
    }

    return accessFlags;
}

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

License:Apache License

/** Gets the access flag (see JVMS8 4.1, 4.5, 4.6) corresponding to the given modifier. */
private static int modifierToAccessFlag(Modifier modifier) {
    switch (modifier) {
    case PUBLIC:/*from   w  w  w . j a  va 2 s . c  om*/
        return Opcodes.ACC_PUBLIC;
    case PROTECTED:
        return Opcodes.ACC_PROTECTED;
    case PRIVATE:
        return Opcodes.ACC_PRIVATE;
    case ABSTRACT:
        return Opcodes.ACC_ABSTRACT;
    case DEFAULT:
        return 0;
    case STATIC:
        return Opcodes.ACC_STATIC;
    case FINAL:
        return Opcodes.ACC_FINAL;
    case TRANSIENT:
        return Opcodes.ACC_TRANSIENT;
    case VOLATILE:
        return Opcodes.ACC_VOLATILE;
    case SYNCHRONIZED:
        return Opcodes.ACC_SYNCHRONIZED;
    case NATIVE:
        return Opcodes.ACC_NATIVE;
    case STRICTFP:
        return Opcodes.ACC_STRICT;
    default:
        throw new IllegalArgumentException(String.format("Unexpected modifier: %s", modifier));
    }
}

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

License:Apache License

@Test
public void testPublicFlagOnField() throws IOException {
    testFieldFlags("public", Opcodes.ACC_PUBLIC);
}