Example usage for org.objectweb.asm Opcodes ACC_SYNTHETIC

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

Introduction

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

Prototype

int ACC_SYNTHETIC

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

Click Source Link

Usage

From source file:org.jacoco.core.internal.analysis.filter.SyntheticFilterTest.java

License:Open Source License

@Test
public void testLambda() {
    final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, Opcodes.ACC_SYNTHETIC, "lambda$1", "()V",
            null, null);/*  ww w  .j ava  2 s  . c om*/
    m.visitInsn(Opcodes.NOP);

    filter.filter(m, context, output);

    assertIgnored();
}

From source file:org.jacoco.core.internal.analysis.filter.SyntheticFilterTest.java

License:Open Source License

@Test
public void should_filter_synthetic_method_with_prefix_anonfun_in_non_Scala_classes() {
    final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, Opcodes.ACC_SYNTHETIC, "$anonfun$main$1",
            "()V", null, null);
    m.visitInsn(Opcodes.RETURN);/*  w  w  w.j  a v a 2s. c  o m*/

    filter.filter(m, context, output);
    assertMethodIgnored(m);
}

From source file:org.jacoco.core.internal.analysis.filter.SyntheticFilterTest.java

License:Open Source License

@Test
public void should_not_filter_synthetic_method_with_prefix_anonfun_in_Scala_classes() {
    final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, Opcodes.ACC_SYNTHETIC, "$anonfun$main$1",
            "()V", null, null);
    m.visitInsn(Opcodes.RETURN);/*from w  w  w.  j  a v  a2s. c o m*/

    context.classAttributes.add("ScalaSig");
    filter.filter(m, context, output);
    assertIgnored();
}

From source file:org.jacoco.core.internal.analysis.filter.SyntheticFilterTest.java

License:Open Source License

@Test
public void should_not_filter_synthetic_method_with_prefix_anonfun_in_Scala_inner_classes() {
    final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, Opcodes.ACC_SYNTHETIC, "$anonfun$main$1",
            "()V", null, null);
    m.visitInsn(Opcodes.RETURN);/* w  w w.ja va  2 s .c  o m*/

    context.classAttributes.add("Scala");
    filter.filter(m, context, output);
    assertIgnored();
}

From source file:org.jacoco.core.internal.analysis.filter.SyntheticFilterTest.java

License:Open Source License

@Test
public void should_not_filter_method_with_suffix_default_in_kotlin_classes() {
    final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION,
            Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE, "example$default",
            "(LTarget;Ljava/lang/String;Ijava/lang/Object;)V", null, null);
    context.classAnnotations.add(KotlinGeneratedFilter.KOTLIN_METADATA_DESC);
    m.visitInsn(Opcodes.NOP);/*w  w  w  .j  av a 2  s  .  c  o m*/

    filter.filter(m, context, output);

    assertIgnored();
}

From source file:org.jacoco.core.internal.analysis.filter.SyntheticFilterTest.java

License:Open Source License

@Test
public void should_filter_synthetic_method_with_suffix_default_in_non_kotlin_classes() {
    final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION,
            Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE, "example$default",
            "(LTarget;Ljava/lang/String;Ijava/lang/Object;)V", null, null);
    m.visitInsn(Opcodes.NOP);/*w  w w  .ja  va 2s  . com*/

    filter.filter(m, context, output);

    assertMethodIgnored(m);
}

From source file:org.jacoco.core.internal.analysis.filter.SyntheticFilterTest.java

License:Open Source License

@Test
public void should_not_filter_synthetic_constructor_containing_default_arguments_in_kotlin_classes() {
    final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, Opcodes.ACC_SYNTHETIC, "<init>",
            "(IILkotlin/jvm/internal/DefaultConstructorMarker;)V", null, null);
    context.classAnnotations.add(KotlinGeneratedFilter.KOTLIN_METADATA_DESC);
    m.visitInsn(Opcodes.NOP);//from  ww  w  .  j  a  v a2  s  .  co m

    filter.filter(m, context, output);

    assertIgnored();
}

From source file:org.jacoco.core.internal.analysis.filter.SyntheticFilterTest.java

License:Open Source License

@Test
public void should_not_filter_synthetic_methods_whose_last_argument_is_kotlin_coroutine_continuation() {
    final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION,
            Opcodes.ACC_SYNTHETIC | Opcodes.ACC_STATIC, "example",
            "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", null, null);
    context.classAnnotations.add(KotlinGeneratedFilter.KOTLIN_METADATA_DESC);
    m.visitInsn(Opcodes.NOP);//from   ww  w  .j a va 2 s.  c o  m

    filter.filter(m, context, output);

    assertIgnored();
}

From source file:org.jacoco.core.internal.analysis.line.ClassAnalyzer.java

License:Open Source License

private boolean isMethodFiltered(final int access, final String name) {
    return (access & Opcodes.ACC_SYNTHETIC) != 0 && !name.startsWith("lambda$");
}

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

License:Open Source License

@Test
public void should_add_bootstrap_method() {
    final ClassNode c = new ClassNode();
    strategy.addMembers(c, 1);//  w w  w.  j  a  v  a 2  s.  c o m

    assertEquals(1, c.methods.size());

    final MethodNode m = c.methods.get(0);
    assertEquals(Opcodes.ACC_SYNTHETIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, m.access);
    assertEquals("$jacocoInit", m.name);
    assertEquals("(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)[Z", m.desc);

    assertEquals(4, m.maxStack);
    assertEquals(3, m.maxLocals);
}