JDK-8203911 : Test runtime/modules/getModuleJNI/GetModule fails with -Xcheck:jni
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 11,12
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-05-29
  • Updated: 2020-01-29
  • Resolved: 2018-07-06
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 11 JDK 12
11.0.7Fixed 12 b02Fixed
Description
STDOUT:
FATAL ERROR in native method: Bad global or local ref passed to JNI
        at GetModule.callGetModule(Native Method)
        at GetModule.main(GetModule.java:137)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@11-internal/Native Method)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@11-internal/NativeMethodAccessorImpl.java:62)
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@11-internal/DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(java.base@11-internal/Method.java:566)
        at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:115)
        at java.lang.Thread.run(java.base@11-internal/Thread.java:832)

Comments
Fix Request (11u) This eliminates another test failure from 11u testing pipelines. Patch applies cleanly to 11u. Affected tests fails with -Xcheck:jni without the patch, passes with it. Additionally, tier1 and tier2 pass. Risk is low, as it removes the optional check:jni test.
27-01-2020

The test is actually checking that GetModule(null) throws a NullPointerException, but the checked version of GetModule has: JNI_ENTRY_CHECKED(jobject, checked_jni_GetModule(JNIEnv *env, jclass clazz)) functionEnter(thr); IN_VM( jniCheck::validate_class(thr, clazz, false); ) jobject result = UNCHECKED()->GetModule(env,clazz); functionExit(thr); return result; JNI_END where validate_class will abort if clazz is NULL. But given: jobject Modules::get_module(jclass clazz, TRAPS) { assert(ModuleEntryTable::javabase_defined(), "Attempt to call get_module before " JAVA_BASE_NAME " is defined"); if (clazz == NULL) { THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "class is null", JNI_FALSE); } it seems to me the checked version of GetModule should not be doing the validation.
29-05-2018