--- old/src/hotspot/share/runtime/arguments.cpp 2017-11-28 15:34:51.000000000 -0800 +++ new/src/hotspot/share/runtime/arguments.cpp 2017-11-28 15:34:50.000000000 -0800 @@ -3375,6 +3375,22 @@ #if INCLUDE_JVMCI if (UseJVMCICompiler) { Compilation_mode = CompMode_server; + // Add jdk.internal.vm.compiler module when Graal is used as JIT + // and --limit-modules are spcified. + const char* jvmci_compiler = Arguments::get_property("jvmci.Compiler"); + const char* limit_modules = Arguments::get_property("jdk.module.limitmods"); + if (limit_modules != NULL && + (jvmci_compiler == NULL || strcmp(jvmci_compiler, "graal") == 0)) { + size_t prop_len = strlen(limit_modules) + strlen("jdk.internal.vm.compiler") + 2; + char* new_limit_modules = AllocateHeap(prop_len, mtArguments); + int ret = jio_snprintf(new_limit_modules, prop_len, "%s,jdk.internal.vm.compiler", limit_modules); + if (ret < 0 || ret >= (int)prop_len) { + FreeHeap(new_limit_modules); + return JNI_ENOMEM; + } + PropertyList_unique_add(&_system_properties, "jdk.module.limitmods", new_limit_modules, AddProperty, UnwriteableProperty, InternalProperty); + FreeHeap(new_limit_modules); + } } #endif