JDK-8350714 : Test vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009/TestDescription.java fails with --enable-preview
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 25
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2025-02-26
  • Updated: 2025-05-05
  • Resolved: 2025-05-05
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.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Test vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009/TestDescription.java
fails with --enable-preview.

Sooner or later the preview features are going to be integrated and test start failing. 
The log says wrong exception is thrown:
22:16:43.765] binder> Launching debugee
[22:16:43.922] binder> Waiting for VM initialized
[22:16:43.923] Initial VMStartEvent received: VMStartEvent in thread main
[22:16:44.307] created breakpoint request nsk.jdi.ClassType.invokeMethod.invokemethod009t:57 (disabled)
	for class nsk.jdi.ClassType.invokeMethod.invokemethod009t (loaded by instance of jdk.internal.loader.ClassLoaders$AppClassLoader(id=741)) ; line=57
[22:16:44.318] 
Starting potential timed out section:
	waiting 5 minute(s) for JDI Breakpoint event ...

[22:16:44.321] expected Breakpoint event occured: BreakpointEvent@nsk.jdi.ClassType.invokeMethod.invokemethod009t:57 in thread invokemethod009tThr
[22:16:44.321] 
Potential timed out section successfully passed

[22:16:44.528] 
1) Trying to invoke the method "dummyMeth (Lnsk/jdi/ClassType/invokeMethod/invokemethod009tDummyType;)V"
	got from reference type "class nsk.jdi.ClassType.invokeMethod.invokemethod009t (loaded by instance of jdk.internal.loader.ClassLoaders$AppClassLoader(id=741))"
	using the debuggee class "class nsk.jdi.ClassType.invokeMethod.invokemethod009t (loaded by instance of jdk.internal.loader.ClassLoaders$AppClassLoader(id=741))" ...
[22:16:44.687] # ERROR: TEST FAILED: ClassType.invokeMethod(): caught unexpected java.lang.ClassCastException: class nsk.share.jdi.MockReferenceType cannot be cast to class com.sun.tools.jdi.ReferenceTypeImpl (nsk.share.jdi.MockReferenceType is in unnamed module of loader java.net.URLClassLoader @146044d7; com.sun.tools.jdi.ReferenceTypeImpl is in module jdk.jdi of loader 'app')
[22:16:44.687] # ERROR: 	instead of expected ClassNotLoadedException
[22:16:44.687] # ERROR: 	when attempted to invoke the method "dummyMeth (Lnsk/jdi/ClassType/invokeMethod/invokemethod009tDummyType;)V"
[22:16:44.687] # ERROR: 	got from reference type "class nsk.jdi.ClassType.invokeMethod.invokemethod009t (loaded by instance of jdk.internal.loader.ClassLoaders$AppClassLoader(id=741))"
[22:16:44.687] # ERROR: 	using the debuggee class "class nsk.jdi.ClassType.invokeMethod.invokemethod009t (loaded by instance of jdk.internal.loader.ClassLoaders$AppClassLoader(id=741))"
The following stacktrace is for failure analysis.
nsk.share.TestFailure: TEST FAILED: ClassType.invokeMethod(): caught unexpected java.lang.ClassCastException: class nsk.share.jdi.MockReferenceType cannot be cast to class com.sun.tools.jdi.ReferenceTypeImpl (nsk.share.jdi.MockReferenceType is in unnamed module of loader java.net.URLClassLoader @146044d7; com.sun.tools.jdi.ReferenceTypeImpl is in module jdk.jdi of loader 'app')  instead of expected ClassNotLoadedException
	at nsk.share.Log.logExceptionForFailureAnalysis(Log.java:309)
	at nsk.share.Log.complain(Log.java:280)
	at nsk.jdi.ClassType.invokeMethod.invokemethod009.runIt(invokemethod009.java:174)
	at nsk.jdi.ClassType.invokeMethod.invokemethod009.run(invokemethod009.java:93)
	at nsk.jdi.ClassType.invokeMethod.invokemethod009.main(invokemethod009.java:86)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:335)
	at java.base/java.lang.Thread.run(Thread.java:1447)
[22:16:44.691] 
2) Trying to invoke the method "finDummyMeth (Lnsk/jdi/ClassType/invokeMethod/invokemethod009tFinDummyType;)J"
	got from reference type "class nsk.jdi.ClassType.invokeMethod.invokemethod009t (loaded by instance of jdk.internal.loader.ClassLoaders$AppClassLoader(id=741))"
	using the debuggee class "class nsk.jdi.ClassType.invokeMethod.invokemethod009t (loaded by instance of jdk.internal.loader.ClassLoaders$AppClassLoader(id=741))" ...
[22:16:44.697] # ERROR: TEST FAILED: ClassType.invokeMethod(): caught unexpected java.lang.ClassCastException: class nsk.share.jdi.MockReferenceType cannot be cast to class com.sun.tools.jdi.ReferenceTypeImpl (nsk.share.jdi.MockReferenceType is in unnamed module of loader java.net.URLClassLoader @146044d7; com.sun.tools.jdi.ReferenceTypeImpl is in module jdk.jdi of loader 'app')
[22:16:44.697] # ERROR: 	instead of expected ClassNotLoadedException
[22:16:44.697] # ERROR: 	when attempted to invoke the method "finDummyMeth (Lnsk/jdi/ClassType/invokeMethod/invokemethod009tFinDummyType;)J"
[22:16:44.697] # ERROR: 	got from reference type "class nsk.jdi.ClassType.invokeMethod.invokemethod009t (loaded by instance of jdk.internal.loader.ClassLoaders$AppClassLoader(id=741))"
[22:16:44.697] # ERROR: 	using the debuggee class "class nsk.jdi.ClassType.invokeMethod.invokemethod009t (loaded by instance of jdk.internal.loader.ClassLoaders$AppClassLoader(id=741))"
[22:16:45.67] 
Debuggee process finished with the status: 95
Comments
I think it is a dup of https://bugs.openjdk.org/browse/JDK-8351188
29-04-2025

See https://bugs.openjdk.org/browse/JDK-8351188 Might be no need to fix test.
04-03-2025

That does seem like the same issue. The tests description says: * The test checks that the JDI method * <code>com.sun.jdi.ClassType.invokeMethod()</code> * properly throws <i>ClassNotLoadedException</i> - if any argument type * has not yet been loaded through the appropriate class loader.<p> So it is dealing with a class that is not suppose to be loaded. I think even if there was no java.lang.ClassCastException, the test would later fail because the class was loaded, and the test will think JDI triggered the class loading. The test might be invalid for its current purposes because I'm not so sure it is within the spec to rely on a class not being loaded simply because it never gets referenced in the execution path. However, I think in both this test case and JDK-8350685, the test should be able to rely on not getting unexpected exceptions due to trying to the jvm loading a class it that the test didn't request to be loaded.
26-02-2025

Might be it is main() validation which tries to load/resolve dependencies for method main() earlier. See https://bugs.openjdk.org/browse/JDK-8350685
26-02-2025

It looks like the java.lang.ClassCastException is not expected: java.lang.ClassCastException: class nsk.share.jdi.MockReferenceType cannot be cast to class com.sun.tools.jdi.ReferenceTypeImpl (nsk.share.jdi.MockReferenceType is in unnamed module of loader java.net.URLClassLoader @146044d7; com.sun.tools.jdi.ReferenceTypeImpl is in module jdk.jdi of loader 'app') What new features is --enable-preview enabling?
26-02-2025