Resolve inconsistency in class loading source paths between normal and AOT class loading

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P3
    • 27
    • Affects Version/s: None
    • Component/s: hotspot
    • None
    • jfr

      0:015> dt utfSource
      Local var @ 0x29c4efdaa8 Type char*
      0x00000029`c4efdb40 "file:/D:/utilities/SPECjbb2005/jbb.jar"


      00 00007ffe`357b4957 : 00000131`69f01b50 00000029`c4efd4f0 0000012f`43eabf00 0003ffff`ffffffff : jvm!JfrClassDefineEvent::on_creation+0x280 [d:\dev\github\jdk_copy4\open\src\hotspot\share\jfr\support\jfrClassDefineEvent.cpp @ 167]
      01 00007ffe`35ab4596 : 00000029`c4efd428 00000029`c4efd4f0 0000012f`43eabf00 0000012f`43eabf00 : jvm!Jfr::on_klass_creation+0x97 [d:\dev\github\jdk_copy4\open\src\hotspot\share\jfr\jfr.cpp @ 90]
      02 00007ffe`35f92185 : 00000029`c4efd990 00000131`706d8690 00000131`6d77e230 00000029`c4efd8d8 : jvm!KlassFactory::create_from_stream+0x3b6 [d:\dev\github\jdk_copy4\open\src\hotspot\share\classfile\klassFactory.cpp @ 219]
      03 00007ffe`35f925a8 : 00000029`c4efd990 00000131`706d8690 0000012f`43ead168 00000029`c4efd8d8 : jvm!SystemDictionary::resolve_class_from_stream+0x145 [d:\dev\github\jdk_copy4\open\src\hotspot\share\classfile\systemDictionary.cpp @ 866]
      04 00007ffe`358cd2b2 : 00000029`c4efd990 00000131`706d8690 0000012f`43ead168 00000029`c4efd8d8 : jvm!SystemDictionary::resolve_from_stream+0x88 [d:\dev\github\jdk_copy4\open\src\hotspot\share\classfile\systemDictionary.cpp @ 904]
      05 00007ffe`358c070e : 00000029`c4efdac0 00000029`c4efe058 00000131`70756ae0 0000012f`000041ef : jvm!jvm_define_class_common+0x282 [d:\dev\github\jdk_copy4\open\src\hotspot\share\prims\jvm.cpp @ 884]
      06 00007ffe`d75f1e07 : 0000012f`43eac398 00000029`c4efdac0 00000029`c4efe058 00000131`70756ae0 : jvm!JVM_DefineClassWithSource+0xae [d:\dev\github\jdk_copy4\open\src\hotspot\share\prims\jvm.cpp @ 1051]
      07 0000012f`5403f682 : 0000012f`43eac398 00000029`c4efe018 00000029`c4efe058 00000029`c4efe050 : java!Java_java_lang_ClassLoader_defineClass1+0x1e7 [d:\dev\github\jdk_copy4\open\src\java.base\share\native\libjava\ClassLoader.c @ 139] <<--- utf8Source
      08 0000012f`43eac398 : 00000029`c4efe018 00000029`c4efe058 00000029`c4efe050 00000029`c4efe048 : 0x0000012f`5403f682
      09 00000029`c4efe018 : 00000029`c4efe058 00000029`c4efe050 00000029`c4efe048 00007ffe`00000000 : 0x0000012f`43eac398
      0a 00000029`c4efe058 : 00000029`c4efe050 00000029`c4efe048 00007ffe`00000000 0000012f`000041ef : 0x00000029`c4efe018
      0b 00000029`c4efe050 : 00000029`c4efe048 00007ffe`00000000 0000012f`000041ef 00000029`c4efe030 : 0x00000029`c4efe058
      0c 00000029`c4efe048 : 00007ffe`00000000 0000012f`000041ef 00000029`c4efe030 00000029`c4efe028 : 0x00000029`c4efe050
      0d 00007ffe`00000000 : 0000012f`000041ef 00000029`c4efe030 00000029`c4efe028 0000012f`54051c97 : 0x00000029`c4efe048
      0e 0000012f`000041ef : 00000029`c4efe030 00000029`c4efe028 0000012f`54051c97 0000012f`5c96c840 : 0x00007ffe`00000000
      0f 00000029`c4efe030 : 00000029`c4efe028 0000012f`54051c97 0000012f`5c96c840 00000131`69121288 : 0x0000012f`000041ef
      10 00000029`c4efe028 : 0000012f`54051c97 0000012f`5c96c840 00000131`69121288 ffffffff`fffffff7 : 0x00000029`c4efe030
      11 0000012f`54051c97 : 0000012f`5c96c840 00000131`69121288 ffffffff`fffffff7 00000000`00000000 : 0x00000029`c4efe028
      12 0000012f`5c96c840 : 00000131`69121288 ffffffff`fffffff7 00000000`00000000 00000000`0000000a : 0x0000012f`54051c97
      13 00000131`69121288 : ffffffff`fffffff7 00000000`00000000 00000000`0000000a 00000131`69197710 : 0x0000012f`5c96c840
      14 ffffffff`fffffff7 : 00000000`00000000 00000000`0000000a 00000131`69197710 00000000`00000000 : 0x00000131`69121288
      15 00000000`00000000 : 00000000`0000000a 00000131`69197710 00000000`00000000 0000012f`5c89bb88 : 0xffffffff`fffffff7



      0:015> dt source
      Local var @ 0x29c4efda90 Type char*
      0x00000029`c4efdb40 "file:/D:/utilities/SPECjbb2005/jbb.jar"


      JVM_ENTRY(jclass, JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source))

        return jvm_define_class_common(name, loader, buf, len, pd, source, THREAD);
      JVM_END


      JNIEXPORT jclass JNICALL
      Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
                                              jclass cls,
                                              jobject loader,
                                              jstring name,
                                              jbyteArray data,
                                              jint offset,
                                              jint length,
                                              jobject pd,
                                              jstring source)
      {
          jbyte *body;
          char *utfName;
          jclass result = 0;
          char buf[128];
          char* utfSource;
          char sourceBuf[1024];

          if (data == NULL) {
              JNU_ThrowNullPointerException(env, 0);
              return NULL;
          }

          /* Work around 4153825. malloc crashes on Solaris when passed a
           * negative size.
           */
          if (length < 0) {
              JNU_ThrowArrayIndexOutOfBoundsException(env, 0);
              return NULL;
          }

          // On AIX malloc(0) returns NULL which looks like an out-of-memory
          // condition; so adjust it to malloc(1)
          #ifdef _AIX
              body = (jbyte *)malloc(length == 0 ? 1 : length);
          #else
              body = (jbyte *)malloc(length);
          #endif

          if (body == NULL) {
              JNU_ThrowOutOfMemoryError(env, 0);
              return NULL;
          }

          (*env)->GetByteArrayRegion(env, data, offset, length, body);

          if ((*env)->ExceptionCheck(env)) {
              goto free_body;
          }

          if (name != NULL) {
              utfName = getUTF(env, name, buf, sizeof(buf));
              if (utfName == NULL) {
                  goto free_body;
              }
              fixClassname(utfName);
          } else {
              utfName = NULL;
          }

          if (source != NULL) {
              utfSource = getUTF(env, source, sourceBuf, sizeof(sourceBuf));
              if (utfSource == NULL) {
                  goto free_utfName;
              }
          } else {
              utfSource = NULL;
          }
          result = JVM_DefineClassWithSource(env, utfName, loader, body, length, pd, utfSource); <--

          if (utfSource && utfSource != sourceBuf)
              free(utfSource);

       free_utfName:
          if (utfName && utfName != buf)
              free(utfName);

       free_body:
          free(body);
          return result;
      }


      java.lang.ClassLoader

          private String defineClassSourceLocation(ProtectionDomain pd) {
              CodeSource cs = pd.getCodeSource();
              String source = null;
              if (cs != null && cs.getLocation() != null) {
                  source = cs.getLocation().toString();
              }
              return source;
          }


          protected final Class<?> defineClass(String name, byte[] b, int off, int len,
                                               ProtectionDomain protectionDomain)
              throws ClassFormatError
          {
              protectionDomain = preDefineClass(name, protectionDomain);
              String source = defineClassSourceLocation(protectionDomain);
              Class<?> c = defineClass1(this, name, b, off, len, protectionDomain, source);
              postDefineClass(c, protectionDomain);
              return c;
          }
          
          
      0:015> dt source
      Local var @ 0x29c4efda90 Type char*
      0x00000029`c4efdb40 0:015> dt utfSource
      Local var @ 0x29c4efdaa8 Type char*
      0x00000029`c4efdb40 "file:/D:/utilities/SPECjbb2005/jbb.jar"


      // Corresponding path resolution for AOT

      0:017> dt path
      Local var @ 0xcb77bfeb18 Type char*
      0x000001dc`1738cff8 "jbb.jar"

       kb
       # RetAddr : Args to Child : Call Site
      00 00007ffe`34ee0ba6 : 000000cb`77bfeb30 000001dc`1517e950 000001dc`15183b10 00007ffe`00000000 : jvm!ClassLocationStream::add_one_path [d:\dev\github\jdk_copy4\open\src\hotspot\share\cds\aotClassLocation.cpp @ 63]
      01 00007ffe`34ee075d : 000000cb`77bfed10 000001dc`1517e950 00000000`00000000 00007ffe`00000000 : jvm!ClassLocationStream::add_paths_in_classpath+0x46 [d:\dev\github\jdk_copy4\open\src\hotspot\share\cds\aotClassLocation.cpp @ 71]
      02 00007ffe`34ee0697 : 000000cb`77bfed10 00007ffe`34ee041a 000000cb`77bfeca0 00000000`00000000 : jvm!AppCpClassLocationStream::AppCpClassLocationStream+0x4d [d:\dev\github\jdk_copy4\open\src\hotspot\share\cds\aotClassLocation.cpp @ 124]
      03 00007ffe`34edd35c : 000000cb`77bfecd0 00000000`00000000 000001de`3bf1f468 00007ffe`35be75f9 : jvm!AllClassLocationStreams::AllClassLocationStreams+0x27 [d:\dev\github\jdk_copy4\open\src\hotspot\share\cds\aotClassLocation.cpp @ 153]
      04 00007ffe`34edeece : 000001de`3bf1f3d0 000001dc`1738c380 000001de`00000000 00000000`0000000a : jvm!AOTClassLocationConfig::dumptime_init_helper+0x4c [d:\dev\github\jdk_copy4\open\src\hotspot\share\cds\aotClassLocation.cpp @ 458]
      05 00007ffe`35f92d32 : 000001dc`1738c380 000001de`3cb4f801 000001de`00000013 000001de`3befb2f0 : jvm!AOTClassLocationConfig::dumptime_init+0x7e [d:\dev\github\jdk_copy4\open\src\hotspot\share\cds\aotClassLocation.cpp @ 444]
      06 00007ffe`36024c06 : 000001dc`1738c380 000001dc`00000000 000001dc`1738c380 000001dc`1738c380 : jvm!SystemDictionary::initialize+0xb2 [d:\dev\github\jdk_copy4\open\src\hotspot\share\classfile\systemDictionary.cpp @ 1618]
      07 00007ffe`36023867 : 000001dc`1738c380 00007ffe`0000000a 00000000`00000000 00007ffe`36ec5b40 : jvm!Universe::genesis+0x496 [d:\dev\github\jdk_copy4\open\src\hotspot\share\memory\universe.cpp @ 450]
      08 00007ffe`3574ba69 : 000001de`3bef50e0 000001de`3bef50e0 00007ffe`36ec5b40 00007ffe`00000000 : jvm!universe2_init+0x27 [d:\dev\github\jdk_copy4\open\src\hotspot\share\memory\universe.cpp @ 1118]
      09 00007ffe`35ff48b5 : 000001de`3bef4fe0 00000000`00000003 00000000`00000000 000000cb`77bff2a4 : jvm!init_globals2+0x9 [d:\dev\github\jdk_copy4\open\src\hotspot\share\runtime\init.cpp @ 174]
      0a 00007ffe`35895b3c : 000000cb`77bffcc8 000000cb`77bffb80 00000000`00000008 00000000`00000000 : jvm!Threads::create_vm+0x515 [d:\dev\github\jdk_copy4\open\src\hotspot\share\runtime\threads.cpp @ 622]
      0b 00007ffe`3587851f : 000000cb`77bffd18 000000cb`77bffd20 000000cb`77bffcc8 00000000`00000009 : jvm!JNI_CreateJavaVM_inner+0x7c [d:\dev\github\jdk_copy4\open\src\hotspot\share\prims\jni.cpp @ 3621]
      *** WARNING: Unable to verify checksum for D:\dev\github\jdk_copy4\build\windows-x86_64-server-slowdebug\images\jdk\bin\jli.dll
      0c 00007ffe`e070bb1c : 000000cb`77bffd18 000000cb`77bffd20 000000cb`77bffcc8 00007ffe`e070ed33 : jvm!JNI_CreateJavaVM+0x2f [d:\dev\github\jdk_copy4\open\src\hotspot\share\prims\jni.cpp @ 3712]
      0d 00007ffe`e0709b96 : 000000cb`77bffd18 000000cb`77bffd20 000000cb`77bffd98 00000000`00000000 : jli!InitializeJVM+0x11c [d:\dev\github\jdk_copy4\open\src\java.base\share\native\libjli\java.c @ 1506]
      0e 00007ffe`e070fd53 : 000000cb`7732f8e8 00007fff`00a53100 00007fff`03cbd3a0 00000000`00000000 : jli!JavaMain+0xd6 [d:\dev\github\jdk_copy4\open\src\java.base\share\native\libjli\java.c @ 494]
      0f 00007fff`03c21bb2 : 000000cb`7732f8e8 00000000`00000000 00000000`00000000 00000000`00000000 : jli!ThreadJavaMain+0x13 [d:\dev\github\jdk_copy4\open\src\java.base\windows\native\libjli\java_md.c @ 633]
      10 00007fff`05567344 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ucrtbase!thread_start<unsigned int (__cdecl*)(void *),1>+0x42
      11 00007fff`064e26b1 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : KERNEL32!BaseThreadInitThunk+0x14
      12 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21

      Summary:

      Normal class loading source = "file:/D:/utilities/SPECjbb2005/jbb.jar"

      AOT class loading source = "jbb.jar"

      Either resolve this inconsistency within AOT or resolve it locally at the location of JfrClassDefineEvent.

            Assignee:
            Unassigned
            Reporter:
            Markus Grönlund
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: