groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andres Almiray <aalmi...@gmail.com>
Subject Groovy 2.5.4 generates dead code
Date Wed, 21 Nov 2018 10:19:34 GMT
Hello everyone,

Evgeny Mandrikov (from JaCoCo) sent me a message regarding dead code
produced by Groovy 2.5.4 (see
https://github.com/jacoco/jacoco/pull/733#issuecomment-440030323 in
context).

Reproducing full message:

@aalmiray <https://github.com/aalmiray> while playing further with Groovy,
I noticed that groovyc 2.5.4 generates dead bytecode for the following
Example.groovy

Closure closure = {
  println("Hello,")
  println("World!")
}
closure()

here is corresponding part from javap -v -p Example\$_run_closure1 output

  public java.lang.Object doCall(java.lang.Object);
    descriptor: (Ljava/lang/Object;)Ljava/lang/Object;
    flags: ACC_PUBLIC
    Code:
      stack=3, locals=3, args_size=2
         0: invokestatic  #22                 // Method
$getCallSiteArray:()[Lorg/codehaus/groovy/runtime/callsite/CallSite;
         3: astore_2
         4: aload_2
         5: ldc           #32                 // int 0
         7: aaload
         8: aload_0
         9: ldc           #34                 // String Hello,
        11: invokeinterface #40,  3           // InterfaceMethod
org/codehaus/groovy/runtime/callsite/CallSite.callCurrent:(Lgroovy/lang/GroovyObject;Ljava/lang/Object;)Ljava/lang/Object;
        16: pop
        17: aload_2
        18: ldc           #41                 // int 1
        20: aaload
        21: aload_0
        22: ldc           #43                 // String World!
        24: invokeinterface #40,  3           // InterfaceMethod
org/codehaus/groovy/runtime/callsite/CallSite.callCurrent:(Lgroovy/lang/GroovyObject;Ljava/lang/Object;)Ljava/lang/Object;
        29: areturn
        30: nop
        31: athrow
      StackMapTable: number_of_entries = 1
        frame_type = 255 /* full_frame */
          offset_delta = 30
          locals = []
          stack = [ class java/lang/Throwable ]
      LineNumberTable:
        line 2: 4
        line 3: 17
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      30     0  this   LExample$_run_closure1;
            0      30     1    it   Ljava/lang/Object;

instructions at offsets 30 and 31 are not reachable, therefore line 3 that
starts at instruction with offset 17 will always be marked as uncovered.
Any ideas on what may be causing this behavior?

Cheers,
Andres

-------------------------------------------
Java Champion; Groovy Enthusiast
JCP EC Associate Seat
http://andresalmiray.com
http://www.linkedin.com/in/aalmiray
--
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and
those who don't.
To understand recursion, we must first understand recursion.

Mime
View raw message