JDK-8272065 : jcmd cannot rely on the old core reflection implementation which will be changed after JEP 416
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 18
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-08-06
  • Updated: 2021-11-11
  • Resolved: 2021-11-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.
JDK 18
18 b23Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
jcmd VM.metaspace and VM.classloaders and VM.class_hierarchy implementation relies on the internals of the old core reflection implementation to find out the class name of the target reflected member.

It will no longer work with the new core reflection implementation by JEP 416.  

test/hotspot/jtreg/serviceability/dcmd/vm/ShowReflectionTargetTest.java is temporarily changed to run with the old core reflection.  This test should be changed to take out ` -Djdk.reflect.useDirectMethodHandle=false` to run with the new implementation.
Comments
Changeset: 7281861e Author: Thomas Stuefe <stuefe@openjdk.org> Date: 2021-11-05 05:15:53 +0000 URL: https://git.openjdk.java.net/jdk/commit/7281861e0662e6c51507066a1f12673a236c7491
05-11-2021

[~mchung] I saw your commit. No more DelegatingClassLoaders, this is great! I'll modify the commands.
04-11-2021

[~stuefe] JEP 416 has been integrated and will be in jdk-18+22 promoted build. Would you have cycle to work on this for 18? The new core reflection implementation no longer spins any class loaders. The jcmd functionality that inspects the generated accessor classes are no longer needed.
03-11-2021

The `GeneratedConstructorAccessor*` method are generated by the old core reflection implementation. They will no longer exist in the new implementation.
20-09-2021

JDK-8203343 prints out information like this jdk.internal.reflect.GeneratedConstructorAccessor18/0x00007f9ee8350c10 (invokes: org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorRegistrar::<init> ()V) This is done by assuming that in a hard-coded CP index of GeneratedConstructorAccessor18, it contains a UTF8 string "org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorRegistrar::<init> ()V" Apparently, this hard-coded CP index no longer works after JEP 416. A better solution would be for the generator of "GeneratedConstructorAccessor18" to mark its invocation target using a properly formed annotation.
30-08-2021

Added two more attachments. stdout-org.txt : without the patch for JEP 416. stdout-with-prop.txt : with the patch for JEP 416 and the -Djdk.reflect.useDirectMethodHandle=false property. Both output contain the same ShowReflectionTargetTest entries except for the differences in the address. The ShowReflectionTargetTest entries in the stdout-org.txt: |--ShowReflectionTargetTest$Dummy/0x00007fa654256960 | | |--jdk.internal.reflect.GeneratedConstructorAccessor25/0x00007fa5904ab460 (invokes: ShowReflectionTargetTest$Dummy::<init> (I)V) | | |--jdk.internal.reflect.GeneratedConstructorAccessor12/0x00007fa5903760a0 (invokes: ShowReflectionTargetTest::<init> ()V) | | |--jdk.internal.reflect.GeneratedMethodAccessor9/0x00007fa5904ab0a0 (invokes: ShowReflectionTargetTest$Dummy::get_i ()I) | | |--jdk.internal.reflect.GeneratedMethodAccessor6/0x00007fa5903cb5b0 (invokes: ShowReflectionTargetTest::jmx ()V) |--ShowReflectionTargetTest/0x00007fa654256960
27-08-2021

Without the -Djdk.reflect.useDirectMethodHandle=false property, the failure is as follows: test ShowReflectionTargetTest.jmx(): failure java.lang.RuntimeException: '.*jdk.internal.reflect.GeneratedConstructorAccessor.*invokes.*ShowReflectionTargetTest\\$Dummy::<init>.*' missing from stdout/stderr Attaching the stdout portion of the .jtr file.
27-08-2021