RFR: 8357987: [JVMCI] Add Support for Retrieving All Non-Static Methods of a ResolvedJavaType.

Doug Simon dnsimon at openjdk.org
Fri May 30 15:06:08 UTC 2025


On Wed, 28 May 2025 15:55:39 GMT, Tom Shull <duke at openjdk.org> wrote:

> Currently from ResolvedJavaType one can retrieve all declared methods, static methods, and constructors of the given type. However, internally in HotSpot there are also VM-internal methods, such as overpass methods, associated with a given type which we cannot access via the API.
> 
> To correct this, we should add a new method which enables VM-internal methods, such as overpass methods, to be accessed.

I also updated the title of https://bugs.openjdk.org/browse/JDK-8357987 to Not Be All Capitalized so you'll need to fix the title of this PR.

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp line 580:

> 578: C2V_END
> 579: 
> 580: C2V_VMENTRY_0(jboolean, isOverpass,(JNIEnv* env, jobject, ARGUMENT_PAIR(method)))

Delete this method - it's no longer used.

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp line 3315:

> 3313:   {CC "setNotInlinableOrCompilable",                  CC "(" HS_METHOD2 ")V",                                                               FN_PTR(setNotInlinableOrCompilable)},
> 3314:   {CC "isCompilable",                                 CC "(" HS_METHOD2 ")Z",                                                               FN_PTR(isCompilable)},
> 3315:   {CC "isOverpass",                                   CC "(" HS_METHOD2 ")Z",                                                               FN_PTR(isOverpass)},

delete

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerToVM.java line 179:

> 177:     private native boolean isCompilable(HotSpotResolvedJavaMethodImpl method, long methodPointer);
> 178: 
> 179:     /**

Delete this method - it's no longer used.

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerToVM.java line 1162:

> 1160: 
> 1161:     /**
> 1162:      * Gets the {@link ResolvedJavaMethod}s for all non-overpass instance methods of {@code klass}.

all non-overpass and non-constructor

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerToVM.java line 1171:

> 1169: 
> 1170:     /**
> 1171:      * Gets the {@link ResolvedJavaMethod}s for all instance methods of {@code klass}.

instance -> non-static
Instance -> NonStatic

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java line 583:

> 581:     @Override
> 582:     public boolean isDeclared() {
> 583:         if (isConstructor() || isStatic()) {

`isStatic()` -> `isClassInitializer()`

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java line 586:

> 584:             return false;
> 585:         }
> 586:         return !compilerToVM().isOverpass(this);

I think you can do this with a direct flag check:

boolean isOverpass = (getConstMethodFlags() & config().constMethodIsOverpass) != 0;
return isOverpass;

See #20256 as an example of the other changes needed for this.

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaMethod.java line 118:

> 116: 
> 117:     /**
> 118:      * Returns {@code true} if this method would be contained in the array returned by

`would be` -> `is`

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaType.java line 370:

> 368: 
> 369:     /**
> 370:      * Returns a list containing all the non-static methods present within this type.

Point out that the returned list is unmodifiable (like the API for `Stream.toList()` does).

test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java line 1027:

> 1025:             ResolvedJavaType type = metaAccess.lookupJavaType(c);
> 1026:             Set<ResolvedJavaMethod> allMethods = new HashSet<>(type.getAllMethods(true));
> 1027:             boolean included = Arrays.stream(type.getDeclaredMethods()).allMatch(m -> allMethods.contains(m));

You can produce a more helpful error message by collecting the entries from getDeclaredMethods, getDeclaredConstructors and the class initialized that are *not* in `allMethods`.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/25498#issuecomment-2921656256
PR Review Comment: https://git.openjdk.org/jdk/pull/25498#discussion_r2113593898
PR Review Comment: https://git.openjdk.org/jdk/pull/25498#discussion_r2113594155
PR Review Comment: https://git.openjdk.org/jdk/pull/25498#discussion_r2113593301
PR Review Comment: https://git.openjdk.org/jdk/pull/25498#discussion_r2112455015
PR Review Comment: https://git.openjdk.org/jdk/pull/25498#discussion_r2112455704
PR Review Comment: https://git.openjdk.org/jdk/pull/25498#discussion_r2112434269
PR Review Comment: https://git.openjdk.org/jdk/pull/25498#discussion_r2112449433
PR Review Comment: https://git.openjdk.org/jdk/pull/25498#discussion_r2112420844
PR Review Comment: https://git.openjdk.org/jdk/pull/25498#discussion_r2112451810
PR Review Comment: https://git.openjdk.org/jdk/pull/25498#discussion_r2115430479


More information about the graal-dev mailing list