JDK-8138743 : [JVMCI] a javadoc for CompilerToVM::getResolvedJavaMethod doesn't match method logic
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-10-02
  • Updated: 2015-10-02
  • Resolved: 2015-10-02
Related Reports
Duplicate :  
Duplicate :  
Description
Currently, a CompilerToVM::getResolvedJavaMethod javadoc states:

    /**
     * Read a value representing a metaspace Method* and return the
     * {@link HotSpotResolvedJavaMethodImpl} wrapping it. This method does no checking that the
     * location actually contains a valid Method*. If the {@code base} object is a
     * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or
     * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object
     * and used as the base. Otherwise the object itself is used as the base.
     *
     * @param base an object to read from or null
     * @param displacement
     * @return null or the resolved method for this location
     */

however, in fact, only MemberName(it's long field at  provided offset) and HotSpotResolvedJavaMethodImpl(a metaspaceMethod field) are supported by c++ code, throwing IllegalArgumentException for other non-null base parameters(but javadoc states that an object itself is used as a base in that case)
Comments
http://hg.openjdk.java.net/graal/graal-jvmci-8/rev/cefe66df3455 http://hg.openjdk.java.net/graal/graal-jvmci-8/rev/a2af5a344c65 expanded javadoc to be more explicit about everything. The final version reads as /** * Read a HotSpot Method* value from the memory location described by {@code base} plus * {@code displacement} and return the {@link HotSpotResolvedJavaMethodImpl} wrapping it. This * method does no checking that the memory location actually contains a valid pointer and may * crash the VM if an invalid location is provided. If the {@code base} is null then * {@code displacement} is used by itself. If {@code base} is a * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object * and added to {@code displacement}. Any other non-null object type causes an * {@link IllegalArgumentException} to be thrown. * * @param base an object to read from or null * @param displacement * @return null or the resolved method for this location */
02-10-2015

Also, the very same issue is true for CompilerToVM::getResolvedJavaType
02-10-2015