Constant descriptor resolved too soon during constant resolution?

Maurizio Cimadamore maurizio.cimadamore at
Fri Aug 3 10:46:41 UTC 2018

Interesting issue! I will defer to Vicente for a full evaluation. By 
eyeballing at the javap output, I see this:

public static void main(java.lang.String[]) throws java.lang.Throwable;
     descriptor: ([Ljava/lang/String;)V
     flags: (0x0009) ACC_PUBLIC, ACC_STATIC
       stack=2, locals=2, args_size=1
          0: getstatic     #2                  // Field 
*3: ldc           #3                  // Dynamic 
          5: invokevirtual #4                  // Method 
          8: return

This looks good, and the ldc is where all the action happens, of course; 
this is the CP entry for it:

#3 = Dynamic            #0:#32         // 

And this is the BSM entry:

public static final #61= #60 of #67;    // Lookup=class 
java/lang/invoke/MethodHandles$Lookup of class 
   0: #23 REF_invokeStatic 
     Method arguments:
       #24 Ljava/lang/invoke/ConstantBootstraps;
       #25 invoke
       #27 _
       #28 Ljava/lang/Object;
*      #29 REF_invokeVirtual 
       #30 Hello,
       #31 world!

My feeling is that the BSM arg in bold above is wrong. That is a *live* 
method handle constant - e.g. of type MethodHandle, but that is not 
compatible with what the BSM expects (a ConstantDesc):

   #29 = MethodHandle       5:#47          // REF_invokeVirtual 

  I think all BSM args above should be nominal. E.g. there should be a 
MethodHandleDesc there (so, another, nested, dynamic constant), not a 
live MethodHandle.

On 02/08/18 16:36, Jorn Vernee wrote:
> Is there a flag to temporarily turn off folding? I'm not aware of any 
> javac equivalent of `-XX:+PrintFlagsFinal`, so I don't have a way to 
> find out about experimental flags.
Yes, folding can be disabled with the


compiler flag.
> Also, I hope this is the right place to post bug reports, JBS doesn't 
> seem to cover amber, and I've seen a few people reporting bugs on 
> other mailing lists, but I'd expect more people to be doing that, so 
> maybe I'm in the wrong place?
Few months ago we have added a new category in JBS - so if you file a 
JDK bug, under the Affect Version field you can now select 'amber-repo'.

The scheme we're using is also to put a label on the bug/rfe which has 
same name as the branch (so that we can quickly filter), so in this case 
that would be "condy-folding".

But reporting issues here is fine too, thanks for testing!


More information about the amber-dev mailing list