-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
For the following Example.scala
object Example {
def exec(task: Runnable) = {
task.run();
}
def main(args: Array[String]) = {
exec(() => {
println("Hello")
})
}
}
execution of
scala-2.13.3/bin/scalac Example.scala
javap -v -p Example\$.class
produces
public static final void $anonfun$main$1();
descriptor: ()V
flags: (0x1019) ACC_PUBLIC, ACC_STATIC, ACC_FINAL, ACC_SYNTHETIC
Code:
stack=2, locals=0, args_size=0
0: getstatic #56 // Field scala/Predef$.MODULE$:Lscala/Predef$;
3: ldc #58 // String Hello
5: invokevirtual #62 // Method scala/Predef$.println:(Ljava/lang/Object;)V
8: return
LineNumberTable:
line 8: 0
whereas execution of
scala3-3.2.2/bin/scalac -d classes3 Example.scala
javap -v -p Example\$.class
produces
private final void main$$anonfun$1();
descriptor: ()V
flags: (0x1012) ACC_PRIVATE, ACC_FINAL, ACC_SYNTHETIC
Code:
stack=2, locals=1, args_size=1
0: getstatic #60 // Field scala/Predef$.MODULE$:Lscala/Predef$;
3: ldc #62 // String Hello
5: invokevirtual #66 // Method scala/Predef$.println:(Ljava/lang/Object;)V
8: return
LineNumberTable:
line 7: 0
line 8: 0
LocalVariableTable:
Start Length Slot Name Signature
0 9 0 this LExample$;
The first one is recognized by #912
jacoco/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/SyntheticFilter.java
Lines 38 to 42 in 8ea9668
| if (isScalaClass(context)) { | |
| if (methodNode.name.startsWith("$anonfun$")) { | |
| return; | |
| } | |
| } |
and won't be filtered out, whereas the second one will be.
marchof