Example usage for org.objectweb.asm Opcodes V11

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

Introduction

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

Prototype

int V11

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

Click Source Link

Usage

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

License:Open Source License

/**
 * Creates a suitable strategy instance for the class described by the given
 * reader. Created instance must be used only to process a class or
 * interface for which it has been created and must be used only once.
 *
 * @param classId//from   w w w.j a v a2s .c  om
 *            class identifier
 * @param reader
 *            reader to get information about the class
 * @param accessorGenerator
 *            accessor to the coverage runtime
 * @return strategy instance
 */
public static IProbeArrayStrategy createFor(final long classId, final ClassReader reader,
        final IExecutionDataAccessorGenerator accessorGenerator) {

    final String className = reader.getClassName();
    final int version = InstrSupport.getMajorVersion(reader);

    if (isInterfaceOrModule(reader)) {
        final ProbeCounter counter = getProbeCounter(reader);
        if (counter.getCount() == 0) {
            return new NoneProbeArrayStrategy();
        }
        if (version >= Opcodes.V11 && counter.hasMethods()) {
            return new CondyProbeArrayStrategy(className, true, classId, accessorGenerator);
        }
        if (version >= Opcodes.V1_8 && counter.hasMethods()) {
            return new InterfaceFieldProbeArrayStrategy(className, classId, counter.getCount(),
                    accessorGenerator);
        } else {
            return new LocalProbeArrayStrategy(className, classId, counter.getCount(), accessorGenerator);
        }
    } else {
        if (version >= Opcodes.V11) {
            return new CondyProbeArrayStrategy(className, false, classId, accessorGenerator);
        }
        return new ClassFieldProbeArrayStrategy(className, classId, InstrSupport.needsFrames(version),
                accessorGenerator);
    }
}

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

License:Open Source License

@Test
public void test_java11_class() {
    final IProbeArrayStrategy strategy = test(Opcodes.V11, 0, true, true, true);

    assertEquals(CondyProbeArrayStrategy.class, strategy.getClass());
    assertNoDataField();/* w  w w .j  ava 2 s  . c  o  m*/
    assertCondyBootstrapMethod();
}

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

License:Open Source License

@Test
public void test_java11_interface_with_clinit_and_methods() {
    final IProbeArrayStrategy strategy = test(Opcodes.V11, Opcodes.ACC_INTERFACE, true, true, true);

    assertEquals(CondyProbeArrayStrategy.class, strategy.getClass());
    assertNoDataField();/*from w w  w  .  ja  v a 2  s. co  m*/
    assertCondyBootstrapMethod();
}

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

License:Open Source License

@Test
public void test_java11_interface_with_clinit() {
    final IProbeArrayStrategy strategy = test(Opcodes.V11, Opcodes.ACC_INTERFACE, true, false, true);

    assertEquals(LocalProbeArrayStrategy.class, strategy.getClass());
    assertNoDataField();//from ww w.  j a  v a 2 s.c  om
    assertNoInitMethod();
}

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

License:Open Source License

@Test
public void test_java11_interface_without_code() {
    final IProbeArrayStrategy strategy = test(Opcodes.V11, Opcodes.ACC_INTERFACE, false, false, true);

    assertEquals(NoneProbeArrayStrategy.class, strategy.getClass());
    assertNoDataField();//from   ww w. j a v a 2  s. c o m
    assertNoInitMethod();
}

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

License:Open Source License

@Test
public void test_java11_module() {
    final IProbeArrayStrategy strategy = createForModule(Opcodes.V11);
    assertEquals(NoneProbeArrayStrategy.class, strategy.getClass());
}

From source file:org.sonar.java.bytecode.loader.SquidClassLoaderTest.java

License:Open Source License

@Test
public void test_loading_java11_class() throws Exception {
    SquidClassLoader classLoader = new SquidClassLoader(
            Collections.singletonList(new File("src/test/files/bytecode/java11/bin")));
    byte[] bytes = classLoader.getBytesForClass("org.foo.A");
    assertThat(bytes).isNotNull();//  w w  w.j a va  2s.  co m
    ClassReader cr = new ClassReader(bytes);
    ClassNode classNode = new ClassNode();
    cr.accept(classNode, 0);
    assertThat(classNode.version).isEqualTo(Opcodes.V11);
    classLoader.close();
}

From source file:se.eris.asm.AsmUtilsTest.java

License:Apache License

@Test
void asmOpcodeToJavaVersion() {
    assertEquals(1, AsmUtils.asmOpcodeToJavaVersion(Opcodes.V1_1));
    assertEquals(5, AsmUtils.asmOpcodeToJavaVersion(Opcodes.V1_5));
    assertEquals(6, AsmUtils.asmOpcodeToJavaVersion(Opcodes.V1_6));
    assertEquals(7, AsmUtils.asmOpcodeToJavaVersion(Opcodes.V1_7));
    assertEquals(8, AsmUtils.asmOpcodeToJavaVersion(Opcodes.V1_8));

    assertEquals(9, AsmUtils.asmOpcodeToJavaVersion(Opcodes.V9));
    assertEquals(10, AsmUtils.asmOpcodeToJavaVersion(Opcodes.V10));
    assertEquals(11, AsmUtils.asmOpcodeToJavaVersion(Opcodes.V11));
}