Bug: no line number for invokedynamic

Vladimir Parfinenko vparfinenko at excelsior-usa.com
Wed Feb 14 08:16:29 UTC 2018


Hi all,

I think I have found a minor bug. There is no line number information
for invokedynamic instructions generated for method handle or lambda
function.

The problem can be reproduced using the example below and running it
like this:

  $ javac Test.java
  $ rm A.class
  $ java Test
  Exception in thread "main" java.lang.NoClassDefFoundError: A
          at Test.main(Test.java:6)
  Caused by: java.lang.ClassNotFoundException: A
          ...

The correct line number for this stack trace element would be 7.

The line number table is missing an entry for invokedynamic:

    Code:
      stack=2, locals=2, args_size=1
         0: invokestatic  #2                  // Method fortyTwo:()I
         3: invokedynamic #3,  0              // InvokeDynamic
#0:apply:()Ljava/util/function/Function;
         8: invokestatic  #4                  // Method
foo:(ILjava/util/function/Function;)Ljava/lang/Object;
        11: astore_1
        12: return
      LineNumberTable:
        line 6: 0
        line 5: 8
        line 9: 12


Regards,
Vladimir Parfinenko



-- Test.java

// line 1
public class Test {
    public static void main(String[] args) {
        Object res =
            foo(
                    fortyTwo(), // line 6
                    A::sqr      // line 7
            );
    }

    public static Object foo(int x, java.util.function.Function<Integer,
Integer> f) {
        return null;
    }

    public static int fortyTwo() {
        return 42;
    }
}

class A {
    public static int sqr(int x) {
        return x * x;
    }
}




More information about the compiler-dev mailing list