The javadoc for Byte Buddy's JavaConstant.MethodHandle says:

Note that constant MethodHandles cannot be represented within the constant pool of a Java class

But section 4.4.8 from the Java Virtual Machine Specification, which is talking about a Java class' constant pool, says:

The CONSTANT_MethodHandle_info structure is used to represent a method handle

What is Byte Buddy's documentation trying to say?

2

There are 2 best solutions below

0
Laird Nelson On BEST ANSWER

How embarrassing; it looks like the documentation is trying to tell me something about a state of affairs that I actually fixed. See: If I have a JavaConstant.MethodHandle and I want to somehow pass it to MethodCall.invoke() is there a way to do it?

I think this means this documentation is now simply incorrect, since in fact Byte Buddy representations of constant method handles can be stored in the constant pool.

0
Louis Wasserman On

It might be referring to the fact that not all MethodHandles can be so represented. From j.lang.invoke.MH's Javadoc:

...method handles that correspond to accessible fields, methods, and constructors can also be represented directly in a class file's constant pool as constants to be loaded by ldc bytecodes.

It might also be referring specifically to JavaConstant.MethodHandle instead of e.g. java.lang.invoke.MethodHandle.