--- old/src/hotspot/share/classfile/systemDictionary.cpp 2018-02-27 08:50:10.516525119 -0800 +++ new/src/hotspot/share/classfile/systemDictionary.cpp 2018-02-27 08:50:10.293504110 -0800 @@ -1059,12 +1059,19 @@ #if INCLUDE_CDS ResourceMark rm(THREAD); if (DumpSharedSpaces && !class_loader.is_null() && - !UseAppCDS && strcmp(class_name->as_C_string(), "Unnamed") != 0) { - // If AppCDS is not enabled, don't define the class at dump time (except for the "Unnamed" - // class, which is used by MethodHandles). + !UseAppCDS && (strcmp(class_name->as_C_string(), "Unnamed") != 0) + // If AppCDS is not enabled, don't define the class at dump time (except for the "Unnamed" + // class, which is used by MethodHandles). +#if INCLUDE_JVMCI + // Need to define the class if force initialization of JVMCI runtime. Otherwise the of the + // JVMCI class will result in ClassNotFoundException. + && !Arguments::is_force_init_jvmci_runtime()) { +#else + ) { +#endif // INCLUDE_JVMCI THROW_MSG_NULL(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string()); } -#endif +#endif // INCLUDE_CDS HandleMark hm(THREAD); --- old/src/hotspot/share/jvmci/jvmciRuntime.cpp 2018-02-27 08:50:11.209590405 -0800 +++ new/src/hotspot/share/jvmci/jvmciRuntime.cpp 2018-02-27 08:50:10.978568643 -0800 @@ -596,6 +596,7 @@ JRT_END void JVMCIRuntime::force_initialization(TRAPS) { + Arguments::set_force_init_jvmci_runtime(true); JVMCIRuntime::initialize_well_known_classes(CHECK); ResourceMark rm; @@ -604,6 +605,7 @@ Handle jvmciRuntime = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK); JavaValue result(T_OBJECT); JavaCalls::call_virtual(&result, jvmciRuntime, HotSpotJVMCIRuntime::klass(), getCompiler, sig, CHECK); + Arguments::set_force_init_jvmci_runtime(false); } // private static JVMCIRuntime JVMCI.initializeRuntime() --- old/src/hotspot/share/runtime/arguments.cpp 2018-02-27 08:50:11.893654844 -0800 +++ new/src/hotspot/share/runtime/arguments.cpp 2018-02-27 08:50:11.650631951 -0800 @@ -118,6 +118,10 @@ char* Arguments::_ext_dirs = NULL; +#if INCLUDE_JVMCI +bool Arguments::_force_init_jvmci_runtime = false; +#endif + bool PathString::set_value(const char *value) { if (_value != NULL) { FreeHeap(_value); --- old/src/hotspot/share/runtime/arguments.hpp 2018-02-27 08:50:12.613722675 -0800 +++ new/src/hotspot/share/runtime/arguments.hpp 2018-02-27 08:50:12.378700535 -0800 @@ -541,6 +541,9 @@ static void set_gc_specific_flags(); #if INCLUDE_JVMCI + static bool _force_init_jvmci_runtime; + static void set_force_init_jvmci_runtime(bool force_init) {_force_init_jvmci_runtime = force_init; } + static bool is_force_init_jvmci_runtime() { return _force_init_jvmci_runtime; } // Check consistency of jvmci vm argument settings. static bool check_jvmci_args_consistency(); static void set_jvmci_specific_flags();