Example usage for org.objectweb.asm Opcodes ACC_INTERFACE

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

Introduction

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

Prototype

int ACC_INTERFACE

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

Click Source Link

Usage

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

License:Apache License

@Test
public void testInterfaceTypeFlags() throws IOException {
    testTypeFlags("interface Foo { }", "Foo", Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT);
}

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

License:Open Source License

@Override
public void visit(final int version, final int access, final String name, final String signature,
        final String superName, final String[] interfaces) {
    final int major = version & 0xFFFF;
    final int minor = version >>> 16;

    currentClassName = name;//from  w w  w  . j  av a  2 s  . c  om

    final StringBuilder sb = new StringBuilder();
    sb.append("// class version ").append(major).append('.').append(minor).append(" (").append(version)
            .append(")\n");

    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append("// DEPRECATED\n");
    }

    sb.append("// access flags 0x"). //TODO TRANSLATE TO WHAT THEY MEAN
            append(Integer.toHexString(access).toUpperCase()).append('\n');

    appendDescriptor(sb, CLASS_SIGNATURE, signature);
    if (signature != null) {
        final TraceSignatureVisitor sv = new TraceSignatureVisitor(access);
        final SignatureReader r = new SignatureReader(signature);
        r.accept(sv);
        sb.append("// declaration: ").append(name).append(sv.getDeclaration()).append('\n');
    }

    appendAccess(sb, access & ~Opcodes.ACC_SUPER);
    if ((access & Opcodes.ACC_ANNOTATION) != 0) {
        sb.append("@interface ");
    } else if ((access & Opcodes.ACC_INTERFACE) != 0) {
        sb.append("interface ");
    } else if ((access & Opcodes.ACC_ENUM) == 0) {
        sb.append("class ");
    }
    appendDescriptor(sb, INTERNAL_NAME, name);

    if (superName != null && !"java/lang/Object".equals(superName)) {
        sb.append(" extends ");
        appendDescriptor(sb, INTERNAL_NAME, superName);
        sb.append(' ');
    }
    if (interfaces != null && interfaces.length > 0) {
        sb.append(" implements ");
        for (final String interface1 : interfaces) {
            appendDescriptor(sb, INTERNAL_NAME, interface1);
            sb.append(' ');
        }
    }
    sb.append(" {\n");

    addText(sb);
}

From source file:com.geeksaga.light.profiler.asm.ClassNodeWrapper.java

License:Apache License

public boolean isInterface() {
    return ((access & Opcodes.ACC_INTERFACE) != 0);
}

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;//  ww  w . j a  v  a2  s .c o m
    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;
}

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

License:Open Source License

@Override
public void transform(Map<String, ClassNode> classMap) {
    stringList = new ArrayList<>();
    do {/*from w w w . j  a  v  a 2s. c  o  m*/
        unscrambleClass = (ClassNode) classMap.values().toArray()[new Random().nextInt(classMap.size())];
    } while ((unscrambleClass.access & Opcodes.ACC_INTERFACE) != 0);
    // Build string list
    log.debug("Building string list");
    classMap.values().stream().flatMap(cn -> cn.methods.stream()).forEach(this::buildStringList);
    Collections.shuffle(stringList);
    // Replace LDC constants with calls to unscramble
    log.debug("Scrambling LDC constants");
    classMap.values().forEach(cn -> cn.methods.forEach(mn -> scramble(cn, mn)));
    // Add unscrambling handler
    log.debug("Creating {} field containing {} strings", FIELD_NAME, stringList.size());
    unscrambleClass.visitField(ACC_PUBLIC | ACC_STATIC, FIELD_NAME, "[Ljava/lang/String;", null, null);
    log.debug("Adding unscramble method to {}.{}{}", unscrambleClass.name, CALL_NAME, CALL_DESC);
    createUnscramble();
    try {
        createStaticConstructor(unscrambleClass);
    } catch (Exception ex) {
        log.warn("Failed to transform strings", ex);
    }
}

From source file:com.github.nfalco79.junit4osgi.registry.internal.asm.BundleTestClassVisitor.java

License:Apache License

private boolean isInterface(int access) {
    return (access & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE;
}

From source file:com.google.code.jtracert.instrument.impl.asm.JTracertClassAdapter.java

License:Open Source License

/**
 * @param version/*  w w w . j a  v  a2 s  .co  m*/
 * @param access
 * @param name
 * @param signature
 * @param superName
 * @param interfaces
 */
@Override
public void visit(int version, int access, String name, String signature, String superName,
        String[] interfaces) {

    isInterface = 0 != (access & Opcodes.ACC_INTERFACE);

    setClassName(ClassUtils.getFullyQualifiedName(name));
    setParentClassName(superName);

    super.visit(version, access, name, signature, superName, interfaces);

}

From source file:com.google.devtools.build.android.desugar.BitFlags.java

License:Open Source License

public static boolean isInterface(int access) {
    return isSet(access, Opcodes.ACC_INTERFACE);
}

From source file:com.google.devtools.build.android.desugar.DefaultMethodClassFixer.java

License:Open Source License

@Override
public void visit(int version, int access, String name, String signature, String superName,
        String[] interfaces) {//ww  w.  j  ava 2  s  . c  o m
    checkState(this.directInterfaces == null);
    isInterface = BitFlags.isSet(access, Opcodes.ACC_INTERFACE);
    internalName = name;
    checkArgument(superName != null || "java/lang/Object".equals(name), // ASM promises this
            "Type without superclass: %s", name);
    this.directInterfaces = ImmutableList.copyOf(interfaces);
    this.superName = superName;
    super.visit(version, access, name, signature, superName, interfaces);
}

From source file:com.google.devtools.build.android.desugar.InterfaceDesugaring.java

License:Open Source License

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    MethodVisitor result;//from   w w w .j  a  va  2s  . c om
    if (BitFlags.isSet(accessFlags, Opcodes.ACC_INTERFACE)
            && BitFlags.noneSet(access, Opcodes.ACC_ABSTRACT | Opcodes.ACC_BRIDGE)
            && !"<clinit>".equals(name)) {
        checkArgument(BitFlags.noneSet(access, Opcodes.ACC_NATIVE), "Forbidden per JLS ch 9.4");

        boolean isLambdaBody = name.startsWith("lambda$") && BitFlags.isSet(access, Opcodes.ACC_SYNTHETIC);
        if (isLambdaBody) {
            access &= ~Opcodes.ACC_PUBLIC; // undo visibility change from LambdaDesugaring
            // Rename lambda method to reflect the new owner.  Not doing so confuses LambdaDesugaring
            // if it's run over this class again.
            name += COMPANION_SUFFIX;
        }
        if (BitFlags.isSet(access, Opcodes.ACC_STATIC)) {
            // Completely move static interface methods, which requires rewriting call sites
            result = companion().visitMethod(access & ~Opcodes.ACC_PRIVATE, name, desc, signature, exceptions);
        } else {
            MethodVisitor abstractDest;
            if (isLambdaBody) {
                // Completely move lambda bodies, which requires rewriting call sites
                access &= ~Opcodes.ACC_PRIVATE;
                abstractDest = null;
            } else {
                // Make default methods abstract but move their implementation into a static method with
                // corresponding signature.  Doesn't require callsite rewriting but implementing classes
                // may need to implement default methods explicitly.
                checkArgument(BitFlags.noneSet(access, Opcodes.ACC_PRIVATE),
                        "Unexpected private interface method %s.%s : %s", name, internalName, desc);
                abstractDest = super.visitMethod(access | Opcodes.ACC_ABSTRACT, name, desc, signature,
                        exceptions);
            }

            // TODO(b/37110951): adjust signature with explicit receiver type, which may be generic
            MethodVisitor codeDest = companion().visitMethod(access | Opcodes.ACC_STATIC, name,
                    companionDefaultMethodDescriptor(internalName, desc), (String) null, // drop signature, since given one doesn't include the new param
                    exceptions);

            result = abstractDest != null ? new MultiplexAnnotations(codeDest, abstractDest) : codeDest;
        }
    } else {
        result = super.visitMethod(access, name, desc, signature, exceptions);
    }
    return result != null ? new InterfaceInvocationRewriter(result) : null;
}