Bug: no line number for invokedynamic
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Feb 14 20:47:46 UTC 2018
This comes from here:
https://bugs.openjdk.java.net/browse/JDK-8010404
Back when developing JDK 8 - we had a feeling that having the debugger
stop at lambda capture sites would be confusing - and so we disabled it.
I agree that in the stack trace case this decision seems to backfire a bit.
Maurizio
On 14/02/18 15:26, B. Blaser wrote:
> The line number is deliberately not emitted for dynamic callsites (but
> I don't know why?), see below.
> I hope this helps,
> Bernard
>
> diff -r b3a833c9c6e9
> src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
> --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
> Mon Feb 12 09:12:41 2018 +0100
> +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
> Wed Feb 14 16:14:17 2018 +0100
> @@ -1649,9 +1649,9 @@
> MethodSymbol msym = (MethodSymbol)TreeInfo.symbol(tree.meth);
> genArgs(tree.args,
> msym.externalType(types).getParameterTypes());
> - if (!msym.isDynamic()) {
> +// if (!msym.isDynamic()) {
> code.statBegin(tree.pos);
> - }
> +// }
> result = m.invoke();
> }
>
>
> On 14 February 2018 at 09:16, Vladimir Parfinenko
> <vparfinenko at excelsior-usa.com> wrote:
>> 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