JDK-8243290 : Improve diagnostic messages for class verification and redefinition failures
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-21
  • Updated: 2021-03-01
  • Resolved: 2020-06-12
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 13 JDK 16 JDK 8
11.0.10-oracleFixed 13.0.6Fixed 16 b02Fixed 8u291Fixed
Description
During the class redefinition process, if a class verification fails because it could not find a class referenced in the class being redefined, the printed NoClassDefFoundError error message is not clear. It does not print the class for which NoClassDefFoundError was encountered.

For example, in the verification and redefinition logs from a test program below, the class being redefined is Log4JLogger, and the logs seem to imply that it is Log4JLogger class for which NoClassDefFoundError exception was thrown.

Verification log:

     [java] [11.040s][info][verification] Verifying class org.apache.commons.logging.impl.Jdk14Logger with old format
     [java] [11.040s][info][verification] End class verification for: org.apache.commons.logging.impl.Jdk14Logger
     [java] [11.040s][info][verification] Verifying class org.apache.commons.logging.impl.Log4JLogger with old format
     [java] [11.041s][info][verification] Verification for org.apache.commons.logging.impl.Log4JLogger has exception pending java.lang.NoClassDefFoundError 
     [java] [11.041s][info][verification] End class verification for: org.apache.commons.logging.impl.Log4JLogger
     [java] Exception in thread "main" java.lang.InternalError
     [java] 	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
     [java] Java Result: 1


redefine log:

     [java] [2.268s][debug][redefine,class,load        ] loaded name=org.apache.commons.logging.impl.Jdk14Logger (avail_mem=501232K)
     [java] [2.268s][debug][redefine,class,load        ] loading name=org.apache.commons.logging.impl.Log4JLogger kind=101 (avail_mem=501232K)
     [java] [2.270s][info ][redefine,class,load,exceptions] link_class exception: 'java/lang/NoClassDefFoundError'
     [java] Exception in thread "main" java.lang.InternalError
     [java] 	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
     [java] 	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:167)
     [java] 	at Main.main(Unknown Source)
     [java] Java Result: 1


A more detailed level logging prints the actual class name for which NoClassDefFoundError was thrown.

[java] 433 Initializing 'java/lang/NoClassDefFoundError'(no method) (0x00000007c0004948)
[java] RESOLVE java.lang.NoClassDefFoundError java.lang.LinkageError NoClassDefFoundError.java:59
[java] JVM JVM_FillInStackTrace
[java] Exception <a 'java/lang/NoClassDefFoundError': org/apache/log4j/Priority> (0x000000076af8ce58)
[java] thrown [/Users/java_re/workspace/8-2-build-macosx-x86_64/jdk8u151/9699/hotspot/src/share/vm/classfile/systemDictionary.cpp, line 199]
[java] for thread 0x00007fc9f9002800
[java] JVM JVM_GetClassNameUTF
-------

The objective of this enhancement is to print the exception message along with the exception name during a class verification and redefinition failure.

Comments
Fix request (13u) Requesting backport to 13u for parity with 11u. The patch applies cleanly. Tested with tier1.
28-01-2021

Fix request (11u) -- will label after testing completed. I would like to downport this for parity with 11.0.10-oracle. Applies clean.
01-09-2020

Fix Request (11u) This improves diagnostics and keeps codebases in sync (I see 11.0.10-oracle). Patch applies cleanly to 11u, passes tier{1,2,3}.
01-09-2020

Changeset: ac460314 Author: Poonam Bajaj <poonam@openjdk.org> Date: 2020-06-12 12:51:32 +0000 URL: https://git.openjdk.java.net/lanai/commit/ac460314
02-07-2020

Changeset: ac460314 Author: Poonam Bajaj <poonam@openjdk.org> Date: 2020-06-12 12:51:32 +0000 URL: https://git.openjdk.java.net/panama-foreign/commit/ac460314
02-07-2020

Changeset: ac460314 Author: Poonam Bajaj <poonam@openjdk.org> Date: 2020-06-12 12:51:32 +0000 URL: https://git.openjdk.java.net/amber/commit/ac460314
02-07-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/51eadbcf9371 User: poonam Date: 2020-06-12 13:04:38 +0000
12-06-2020