Example usage for org.objectweb.asm Opcodes V1_3

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

Introduction

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

Prototype

int V1_3

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

Click Source Link

Usage

From source file:br.usp.each.saeg.badua.core.internal.ContentTypeDetector.java

License:Open Source License

private static int determineType(final InputStream in) throws IOException {
    final int header = readInt(in);
    switch (header) {
    case ZIPFILE:
        return ZIPFILE;
    case PACK200FILE:
        return PACK200FILE;
    case CLASSFILE:
        // also verify version to distinguish from Mach Object files:
        switch (readInt(in)) {
        case Opcodes.V1_1:
        case Opcodes.V1_2:
        case Opcodes.V1_3:
        case Opcodes.V1_4:
        case Opcodes.V1_5:
        case Opcodes.V1_6:
        case Opcodes.V1_7:
        case Opcodes.V1_8:
            return CLASSFILE;
        }/*  w w  w . j a v a  2  s .  c o  m*/
    }
    if ((header & 0xffff0000) == GZFILE) {
        return GZFILE;
    }
    return UNKNOWN;
}

From source file:com.android.build.gradle.shrinker.parser.ProguardFlags.java

License:Apache License

public void target(@NonNull String target) {
    int version;/*from  ww w. j av  a2s  . co  m*/
    switch (target) {
    case "8":
    case "1.8":
        version = Opcodes.V1_8;
        break;
    case "7":
    case "1.7":
        version = Opcodes.V1_7;
        break;
    case "6":
    case "1.6":
        version = Opcodes.V1_6;
        break;
    case "5":
    case "1.5":
        version = Opcodes.V1_5;
        break;
    case "1.4":
        version = Opcodes.V1_4;
        break;
    case "1.3":
        version = Opcodes.V1_3;
        break;
    case "1.2":
        version = Opcodes.V1_2;
        break;
    case "1.1":
        version = Opcodes.V1_1;
        break;
    default:
        throw new AssertionError("Unknown target " + target);
    }

    this.bytecodeVersion = new BytecodeVersion(version);
}

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

License:Apache License

/** Gets the class file version corresponding to the given source version constant. */
private static int sourceVersionToClassFileVersion(SourceVersion version) {
    switch (version) {
    case RELEASE_0:
        return Opcodes.V1_1; // JVMS8 4.1: 1.0 and 1.1 both support version 45.3 (Opcodes.V1_1)
    case RELEASE_1:
        return Opcodes.V1_1;
    case RELEASE_2:
        return Opcodes.V1_2;
    case RELEASE_3:
        return Opcodes.V1_3;
    case RELEASE_4:
        return Opcodes.V1_4;
    case RELEASE_5:
        return Opcodes.V1_5;
    case RELEASE_6:
        return Opcodes.V1_6;
    case RELEASE_7:
        return Opcodes.V1_7;
    case RELEASE_8:
        return Opcodes.V1_8;
    default:/*from  www.j a  v a2 s  .  co  m*/
        throw new IllegalArgumentException(String.format("Unexpected source version: %s", version));
    }
}

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

License:Apache License

/** Gets the class file version corresponding to the given source version constant. */
public static int sourceVersionToClassFileVersion(SourceVersion version) {
    switch (version) {
    case RELEASE_0:
        return Opcodes.V1_1; // JVMS8 4.1: 1.0 and 1.1 both support version 45.3 (Opcodes.V1_1)
    case RELEASE_1:
        return Opcodes.V1_1;
    case RELEASE_2:
        return Opcodes.V1_2;
    case RELEASE_3:
        return Opcodes.V1_3;
    case RELEASE_4:
        return Opcodes.V1_4;
    case RELEASE_5:
        return Opcodes.V1_5;
    case RELEASE_6:
        return Opcodes.V1_6;
    case RELEASE_7:
        return Opcodes.V1_7;
    case RELEASE_8:
        return Opcodes.V1_8;
    default://w ww .ja v  a2 s .co m
        throw new IllegalArgumentException(String.format("Unexpected source version: %s", version));
    }
}

From source file:fr.liglab.adele.cilia.dependency.ProxyGenerator.java

License:Apache License

/**
 * Generates a proxy class./*from   w w w .  j  a va2s.  c om*/
 *
 * @param spec the proxied service specification
 * @return the byte[] for the generated proxy class.
 */
public static byte[] dumpProxy(Class spec) {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    String internalClassName = Type.getInternalName(spec); // Specification class internal name.
    String[] itfs = new String[0];
    String parent = "java/lang/Object";
    if (spec.isInterface()) {
        itfs = new String[] { internalClassName }; // Implemented interface.
    } else {
        parent = internalClassName;
    }
    String className = internalClassName + "$$Proxy"; // Unique name.

    // Turn around the VM changes (FELIX-2716) about java.* classes.
    if (className.startsWith("java/")) {
        className = "$" + className;
    }

    Method[] methods = spec.getMethods(); // Method to delegate

    cw.visit(Opcodes.V1_3, Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, className, null, parent, itfs);
    addDependencyField(cw);

    // We try to call super() on the parent, however this should not be used as proxing does work only for interface.
    generateConstructor(cw, className, parent);

    // For each method, create the delegator code.
    for (int i = 0; i < methods.length; i++) {
        if ((methods[i].getModifiers() & (Modifier.STATIC | Modifier.FINAL)) == 0) {
            generateDelegator(cw, methods[i], className, internalClassName);
        }
    }

    cw.visitEnd();

    return cw.toByteArray();

}

From source file:org.apache.felix.ipojo.handler.temporal.ProxyGenerator.java

License:Apache License

/**
 * Generates a proxy class.//  ww  w .j  a  v a2 s  .  c  om
 * @param spec the proxied service specification
 * @return the byte[] for the generated proxy class.
 */
public static byte[] dumpProxy(Class spec) {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    String internalClassName = Type.getInternalName(spec); // Specification class internal name.
    String[] itfs = new String[] { internalClassName }; // Implemented interface.
    String className = internalClassName + "$$Proxy"; // Unique name.
    Method[] methods = spec.getMethods(); // Method to delegate

    cw.visit(Opcodes.V1_3, Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, className, null, "java/lang/Object", itfs);
    addDependencyField(cw);
    generateConstructor(cw, className);

    // For each method, create the delegator code.
    for (int i = 0; i < methods.length; i++) {
        if ((methods[i].getModifiers() & (Modifier.STATIC | Modifier.FINAL)) == 0) {
            generateDelegator(cw, methods[i], className, internalClassName);
        }
    }

    cw.visitEnd();

    return cw.toByteArray();

}

From source file:org.codehaus.groovy.classgen.DummyClassGenerator.java

License:Apache License

public void visitClass(ClassNode classNode) {
    try {/*from w w  w  .j ava 2  s  . com*/
        this.classNode = classNode;
        this.internalClassName = BytecodeHelper.getClassInternalName(classNode);

        //System.out.println("Generating class: " + classNode.getName());

        this.internalBaseClassName = BytecodeHelper.getClassInternalName(classNode.getSuperClass());

        cv.visit(Opcodes.V1_3, classNode.getModifiers(), internalClassName, (String) null,
                internalBaseClassName, BytecodeHelper.getClassInternalNames(classNode.getInterfaces()));

        classNode.visitContents(this);

        for (ClassNode innerClass : innerClasses) {
            ClassNode innerClassType = innerClass;
            String innerClassInternalName = BytecodeHelper.getClassInternalName(innerClassType);
            String outerClassName = internalClassName; // default for inner classes
            MethodNode enclosingMethod = innerClass.getEnclosingMethod();
            if (enclosingMethod != null) {
                // local inner classes do not specify the outer class name
                outerClassName = null;
            }
            cv.visitInnerClass(innerClassInternalName, outerClassName, innerClassType.getName(),
                    innerClass.getModifiers());
        }
        cv.visitEnd();
    } catch (GroovyRuntimeException e) {
        e.setModule(classNode.getModule());
        throw e;
    }
}

From source file:org.jacoco.core.internal.analysis.ContentTypeDetector.java

License:Open Source License

private static int determineType(final InputStream in) throws IOException {
    switch (readInt(in)) {
    case ZIPFILE:
        return ZIPFILE;
    case CLASSFILE:
        // also verify version to distinguish from Mach Object files:
        switch (readInt(in)) {
        case Opcodes.V1_1:
        case Opcodes.V1_2:
        case Opcodes.V1_3:
        case Opcodes.V1_4:
        case Opcodes.V1_5:
        case Opcodes.V1_6:
        case Opcodes.V1_7:
            return CLASSFILE;
        }/*ww w  .  j av a2  s . c  om*/
    }
    return UNKNOWN;
}

From source file:org.jacoco.core.internal.ContentTypeDetector.java

License:Open Source License

private static int determineType(final InputStream in) throws IOException {
    final int header = readInt(in);
    switch (header) {
    case ZIPFILE:
        return ZIPFILE;
    case PACK200FILE:
        return PACK200FILE;
    case CLASSFILE:
        // also verify version to distinguish from Mach Object files:
        switch (readInt(in)) {
        case Opcodes.V1_1:
        case Opcodes.V1_2:
        case Opcodes.V1_3:
        case Opcodes.V1_4:
        case Opcodes.V1_5:
        case Opcodes.V1_6:
        case Opcodes.V1_7:
            return CLASSFILE;
        }//from  w ww  .ja  v a 2  s .c  om
    }
    if ((header & 0xffff0000) == GZFILE) {
        return GZFILE;
    }
    return UNKNOWN;
}

From source file:org.jacoco.core.internal.instr.ProbeArrayStrategyFactoryTest.java

License:Open Source License

@Test
public void testClass3() {
    final IProbeArrayStrategy strategy = test(Opcodes.V1_3, 0, false, true, true);
    assertEquals(ClassFieldProbeArrayStrategy.class, strategy.getClass());
    assertDataField(InstrSupport.DATAFIELD_ACC);
    assertInitMethod(false);//from   ww  w.  j av  a2 s. com
}