1

I used JAVA_OPTS -Xlog:class+load=debug (inside Tomcat 9 startup.bat), though it is showing the class name but it shows source as source: __JVMDefineClass__. Is there any way I can know the name of Jar, like it showed in JAVA 8?

For e.g

in JAVA 8: [Loaded java.lang.Object from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar], but,

in JAVA 11: com.fasterxml.jackson.databind.util.ClassUtil$Ctor source: __JVM_DefineClass__

Update: I am using TomeePlus.

NiTiN
  • 81
  • 1
  • 9
  • Is the '__JVM_DefineClass__' string showed as source of all other classes or only of this one? – dbaltor Apr 13 '20 at 12:54
  • `__JVM_DefineClass__` is shown for all classes except classes that are loaded from Tomcat lib. For classes that are loaded from tomcat lib folder, it is showing the correct lib name and path. – NiTiN Apr 14 '20 at 03:57
  • I also see that the classes that were loaded by TempClassLoader of Tomee have such source, but classes that were loaded by URLClassLoader contains jar names. – NiTiN Apr 14 '20 at 06:06

1 Answers1

0

I've run some tests using Spring Boot's embedded Tomcat and the __JVM_DefineClass__ string used as class source has nothing to do with the JVM version. It happened on the logs during my tests due to:

  • inner classes such as the one you mention, or
  • dynamic generated classes, for example jdk.internal.reflect.GeneratedConstructorAccessor1

It seems to me that this is due to the source location URL has not been made available to the ClassLoader. You can read below the snippet of the OpenJDK 11 source code responsible for defining the __JVM_DefineClass__ string.

// common code for JVM_DefineClass() and JVM_DefineClassWithSource()
static jclass jvm_define_class_common(JNIEnv *env, const char *name,
                                  jobject loader, const jbyte *buf,
                                  jsize len, jobject pd, const char *source,
                                  TRAPS) {
  if (source == NULL)  source = "__JVM_DefineClass__";
  ...

OpenJDK / jdk / jdk11

dbaltor
  • 2,737
  • 3
  • 24
  • 36
  • Some class path contained extra "/", which was causing them the URL value to be invalid. Just to debug, I modified the TempClassLoader, which I think, might solved my issue. Thanks. – NiTiN Apr 30 '20 at 10:14