JDK-8137083 : [JVMCI] CompilerToVM methods "resolveConstantInPool" and "resolvePossiblyCachedConstantInPool" have poor javadoc
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2015-09-24
  • Updated: 2015-09-24
  • Resolved: 2015-09-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Related Reports
Relates :  
Description
The jdk.internal.jvmci.hotspot.CompilerToVM methods "resolveConstantInPool" and "resolvePossiblyCachedConstantInPool" have poor documentation.

Javadoc says only "The behavior of this method is undefined if cpi does not denote an entry that can be resolved to an object."

So there is no information about what exact constant pool types from the JVM spec (https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4-140) are supported by each method and what limitations exist for each of the constant pool types.

What entries of what types can be resolved to an object?

For example method "resolveConstantInPool" does not work (returns null) if applied to CONSTANT_String of CONSTANT_Utf8 entry.

Method "resolvePossiblyCachedConstantInPool" does not work (returns null) if applied to CONSTANT_Utf8 entry, but works with CONSTANT_String.
Comments
http://hg.openjdk.java.net/graal/graal-jvmci-9/hotspot/rev/d45365af5c89
24-09-2015

Yes, it will be sufficient.
24-09-2015

As with other methods in CompilerToVM, these methods are simply interfaces to the (often poorly documented) methods in the HotSpot ConstantPool C++ class. However, you can see the only usages are in jdk.internal.jvmci.hotspot.HotSpotConstantPool.lookupConstant(int). These usages show that "resolveConstantInPool" is only called for JVM_CONSTANT_MethodHandle, JVM_CONSTANT_MethodHandleInError, JVM_CONSTANT_MethodType and JVM_CONSTANT_MethodTypeInError and "resolvePossiblyCachedConstantInPool" is only called for JVM_CONSTANT_String. Would it be sufficient to have the javadoc simply state these accepted entry types?
24-09-2015

Detailed information about supported constant pool types and about usage limitations should be added to javadoc of these two methods.
24-09-2015

http://hg.openjdk.java.net/graal/graal-jvmci-8/rev/5baefb241788
24-09-2015