diff --git a/compiler/mx.compiler/mx_compiler.py b/compiler/mx.compiler/mx_compiler.py index 5d8a509d808e..4541027e4285 100644 --- a/compiler/mx.compiler/mx_compiler.py +++ b/compiler/mx.compiler/mx_compiler.py @@ -1300,7 +1300,7 @@ def __init__(self): self.truffle_jars = [] self.jars = [] - for component in mx_sdk_vm.graalvm_components(): + for component in mx_sdk_vm_impl.registered_graalvm_components(): if isinstance(component, mx_sdk_vm.GraalVmJvmciComponent): for jar in component.jvmci_jars: d = mx.distribution(jar) @@ -1337,7 +1337,7 @@ def _jvmci_jars(): dir_name='graal', license_files=[], third_party_license_files=[], - dependencies=['Truffle Compiler'], + dependencies=['Truffle Compiler', 'Graal SDK Compiler'], jar_distributions=[ # Dev jars (annotation processors) 'compiler:GRAAL_PROCESSOR', ], diff --git a/compiler/mx.compiler/suite.py b/compiler/mx.compiler/suite.py index b515006d71e3..ebccdbe978df 100644 --- a/compiler/mx.compiler/suite.py +++ b/compiler/mx.compiler/suite.py @@ -162,7 +162,8 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "sdk:GRAAL_SDK", + "sdk:WORD", + "sdk:COLLECTIONS", "truffle:TRUFFLE_COMPILER", ], "requires" : [ @@ -419,6 +420,7 @@ "sourceDirs" : ["src"], "dependencies" : [ "jdk.internal.vm.compiler", + "sdk:COLLECTIONS", ], "checkstyle" : "jdk.internal.vm.compiler", "javaCompliance" : "17+", @@ -526,7 +528,8 @@ "jdk.internal.vm.compiler" ], "distDependencies" : [ - "sdk:GRAAL_SDK", + "sdk:COLLECTIONS", + "sdk:WORD", "truffle:TRUFFLE_COMPILER", ], "allowsJavadocWarnings": True, @@ -610,7 +613,7 @@ "org.graalvm.profdiff", ], "distDependencies" : [ - "sdk:GRAAL_SDK", + "sdk:COLLECTIONS", "GRAAL", ], "maven" : False, diff --git a/compiler/src/jdk.internal.vm.compiler.test/src/org/graalvm/compiler/api/test/ModuleSupport.java b/compiler/src/jdk.internal.vm.compiler.test/src/org/graalvm/compiler/api/test/ModuleSupport.java index 6a05f6abf2f7..0dfe9a96818a 100644 --- a/compiler/src/jdk.internal.vm.compiler.test/src/org/graalvm/compiler/api/test/ModuleSupport.java +++ b/compiler/src/jdk.internal.vm.compiler.test/src/org/graalvm/compiler/api/test/ModuleSupport.java @@ -35,6 +35,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import org.graalvm.compiler.debug.DebugOptions; @@ -71,7 +72,18 @@ public static void exportAllPackagesTo(Class moduleMember, ClassLoader cl) { * Exports and opens all packages in the module named {@code name} to all unnamed modules. */ public static void exportAndOpenAllPackagesToUnnamed(String name) { - Module module = ModuleLayer.boot().findModule(name).orElseThrow(); + exportAndOpenAllPackagesToUnnamed(name, true); + } + + /** + * Exports and opens all packages in the module named {@code name} to all unnamed modules. + */ + public static void exportAndOpenAllPackagesToUnnamed(String name, boolean required) { + Optional maybeModule = ModuleLayer.boot().findModule(name); + Module module = required ? maybeModule.orElseThrow() : maybeModule.orElse(null); + if (module == null) { + return; + } Set packages = module.getPackages(); for (String pkg : packages) { Modules.addExportsToAllUnnamed(module, pkg); diff --git a/compiler/src/jdk.internal.vm.compiler.test/src/org/graalvm/compiler/hotspot/test/CompileTheWorld.java b/compiler/src/jdk.internal.vm.compiler.test/src/org/graalvm/compiler/hotspot/test/CompileTheWorld.java index e3bb85a7c0ff..482cd77c476f 100644 --- a/compiler/src/jdk.internal.vm.compiler.test/src/org/graalvm/compiler/hotspot/test/CompileTheWorld.java +++ b/compiler/src/jdk.internal.vm.compiler.test/src/org/graalvm/compiler/hotspot/test/CompileTheWorld.java @@ -138,9 +138,12 @@ public final class CompileTheWorld { static { + ModuleSupport.exportAndOpenAllPackagesToUnnamed("jdk.internal.vm.ci"); ModuleSupport.exportAndOpenAllPackagesToUnnamed("jdk.internal.vm.compiler"); - ModuleSupport.exportAndOpenAllPackagesToUnnamed("org.graalvm.truffle"); - ModuleSupport.exportAndOpenAllPackagesToUnnamed("org.graalvm.truffle.runtime"); + // Truffle may not be on the module-path + ModuleSupport.exportAndOpenAllPackagesToUnnamed("org.graalvm.truffle", false); + ModuleSupport.exportAndOpenAllPackagesToUnnamed("org.graalvm.truffle.compiler", false); + ModuleSupport.exportAndOpenAllPackagesToUnnamed("org.graalvm.truffle.runtime", false); } /** diff --git a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/options/Option.java b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/options/Option.java index a671f0fe1d4e..2801ac198a6d 100644 --- a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/options/Option.java +++ b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/options/Option.java @@ -29,8 +29,6 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.graalvm.options.OptionDescriptor; - /** * Describes the attributes of an option whose {@link OptionKey value} is in a static field * annotated by this annotation type. diff --git a/espresso/mx.espresso/mx_espresso.py b/espresso/mx.espresso/mx_espresso.py index 71cf78030693..4fc6b3c0e87b 100644 --- a/espresso/mx.espresso/mx_espresso.py +++ b/espresso/mx.espresso/mx_espresso.py @@ -326,17 +326,17 @@ def register_espresso_envs(suite): tools = ['cov', 'dap', 'ins', 'insight', 'insightheap', 'lsp', 'pro', 'truffle-json'] _llvm_toolchain_wrappers = ['bgraalvm-native-clang', 'bgraalvm-native-clang-cl', 'bgraalvm-native-clang++', 'bgraalvm-native-flang', 'bgraalvm-native-ld', 'bgraalvm-native-binutil'] if LLVM_JAVA_HOME: - mx_sdk_vm.register_vm_config('espresso-jvm', ['java', 'ejvm', 'ellvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp', 'antlr4', 'llrc', 'llrn' , 'elau' ] + tools, suite, env_file='jvm-llvm') - mx_sdk_vm.register_vm_config('espresso-jvm-ce', ['java', 'ejvm', 'ellvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp', 'antlr4', 'llrc', 'llrn' , 'svm', 'svmt' , 'svmsl' , 'tflm', 'elau', 'lg', 'bespresso', 'sjavavm', 'spolyglot'] + _llvm_toolchain_wrappers + tools, suite, env_file='jvm-ce-llvm') - mx_sdk_vm.register_vm_config('espresso-jvm-ee', ['java', 'ejvm', 'ellvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc', 'tfle', 'cmp', 'antlr4', 'llrc', 'llrn', 'cmpee', 'svm', 'svmt', 'svmee', 'svmte', 'svmsl', 'tflllm', 'tflm', 'elau', 'lg', 'bespresso', 'sjavavm', 'spolyglot'] + _llvm_toolchain_wrappers + tools, suite, env_file='jvm-ee-llvm') - mx_sdk_vm.register_vm_config('espresso-native-ce', ['java', 'ejvm', 'ellvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp', 'antlr4', 'llrc', 'llrn' , 'svm', 'svmt' , 'svmsl' , 'tflm' , 'spolyglot'] + _llvm_toolchain_wrappers + tools, suite, env_file='native-ce-llvm') - mx_sdk_vm.register_vm_config('espresso-native-ee', ['java', 'ejvm', 'ellvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc', 'tfle', 'cmp', 'antlr4', 'llrc', 'llrn', 'cmpee', 'svm', 'svmt', 'svmsl', 'svmee', 'svmte', 'tflllm', 'tflm' , 'spolyglot'] + _llvm_toolchain_wrappers + tools, suite, env_file='native-ee-llvm') + mx_sdk_vm.register_vm_config('espresso-jvm', ['java', 'ejvm', 'ellvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp', 'antlr4', 'llrc', 'llrn' , 'elau' ] + tools, suite, env_file='jvm-llvm') + mx_sdk_vm.register_vm_config('espresso-jvm-ce', ['java', 'ejvm', 'ellvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp', 'antlr4', 'llrc', 'llrn' , 'svm', 'svmt' , 'svmsl' , 'tflm', 'elau', 'lg', 'bespresso', 'sjavavm', 'spolyglot'] + _llvm_toolchain_wrappers + tools, suite, env_file='jvm-ce-llvm') + mx_sdk_vm.register_vm_config('espresso-jvm-ee', ['java', 'ejvm', 'ellvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'tfle', 'cmp', 'antlr4', 'llrc', 'llrn', 'cmpee', 'svm', 'svmt', 'svmee', 'svmte', 'svmsl', 'tflllm', 'tflm', 'elau', 'lg', 'bespresso', 'sjavavm', 'spolyglot'] + _llvm_toolchain_wrappers + tools, suite, env_file='jvm-ee-llvm') + mx_sdk_vm.register_vm_config('espresso-native-ce', ['java', 'ejvm', 'ellvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp', 'antlr4', 'llrc', 'llrn' , 'svm', 'svmt' , 'svmsl' , 'tflm' , 'spolyglot'] + _llvm_toolchain_wrappers + tools, suite, env_file='native-ce-llvm') + mx_sdk_vm.register_vm_config('espresso-native-ee', ['java', 'ejvm', 'ellvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'tfle', 'cmp', 'antlr4', 'llrc', 'llrn', 'cmpee', 'svm', 'svmt', 'svmsl', 'svmee', 'svmte', 'tflllm', 'tflm' , 'spolyglot'] + _llvm_toolchain_wrappers + tools, suite, env_file='native-ee-llvm') else: - mx_sdk_vm.register_vm_config('espresso-jvm', ['java', 'ejvm' , 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp' , 'elau' ] + tools, suite, env_file='jvm') - mx_sdk_vm.register_vm_config('espresso-jvm-ce', ['java', 'ejvm' , 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp' , 'svm', 'svmt', 'svmsl' , 'tflm', 'elau', 'lg', 'bespresso', 'sjavavm', 'spolyglot' ] + tools, suite, env_file='jvm-ce') - mx_sdk_vm.register_vm_config('espresso-jvm-ee', ['java', 'ejvm' , 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc', 'tfle', 'cmp' , 'cmpee', 'svm', 'svmt', 'svmsl', 'svmee', 'svmte', 'tflllm', 'tflm', 'elau', 'lg', 'bespresso', 'sjavavm', 'spolyglot' ] + tools, suite, env_file='jvm-ee') - mx_sdk_vm.register_vm_config('espresso-native-ce', ['java', 'ejvm' , 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp' , 'svm', 'svmt', 'svmsl' , 'tflm' , 'spolyglot' ] + tools, suite, env_file='native-ce') - mx_sdk_vm.register_vm_config('espresso-native-ee', ['java', 'ejvm' , 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc', 'tfle', 'cmp' , 'cmpee', 'svm', 'svmt', 'svmsl', 'svmee', 'svmte', 'tflllm', 'tflm' , 'spolyglot' ] + tools, suite, env_file='native-ee') + mx_sdk_vm.register_vm_config('espresso-jvm', ['java', 'ejvm' , 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp' , 'elau' ] + tools, suite, env_file='jvm') + mx_sdk_vm.register_vm_config('espresso-jvm-ce', ['java', 'ejvm' , 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp' , 'svm', 'svmt', 'svmsl' , 'tflm', 'elau', 'lg', 'bespresso', 'sjavavm', 'spolyglot' ] + tools, suite, env_file='jvm-ce') + mx_sdk_vm.register_vm_config('espresso-jvm-ee', ['java', 'ejvm' , 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'tfle', 'cmp' , 'cmpee', 'svm', 'svmt', 'svmsl', 'svmee', 'svmte', 'tflllm', 'tflm', 'elau', 'lg', 'bespresso', 'sjavavm', 'spolyglot' ] + tools, suite, env_file='jvm-ee') + mx_sdk_vm.register_vm_config('espresso-native-ce', ['java', 'ejvm' , 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc' , 'cmp' , 'svm', 'svmt', 'svmsl' , 'tflm' , 'spolyglot' ] + tools, suite, env_file='native-ce') + mx_sdk_vm.register_vm_config('espresso-native-ee', ['java', 'ejvm' , 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'tfle', 'cmp' , 'cmpee', 'svm', 'svmt', 'svmsl', 'svmee', 'svmte', 'tflllm', 'tflm' , 'spolyglot' ] + tools, suite, env_file='native-ee') register_espresso_envs(_suite) diff --git a/espresso/mx.espresso/suite.py b/espresso/mx.espresso/suite.py index f42d1ea52caa..97b041282a0b 100644 --- a/espresso/mx.espresso/suite.py +++ b/espresso/mx.espresso/suite.py @@ -147,7 +147,7 @@ "subDir": "src", "sourceDirs": ["src"], "dependencies": [ - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", "sdk:LAUNCHER_COMMON", ], "javaCompliance" : "17+", @@ -158,7 +158,7 @@ "subDir": "src", "sourceDirs": ["src"], "dependencies": [ - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", "sdk:LAUNCHER_COMMON", ], "requires": [ @@ -338,7 +338,7 @@ ], "mainClass": "com.oracle.truffle.espresso.launcher.EspressoLauncher", "distDependencies": [ - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", "sdk:LAUNCHER_COMMON", ], "description": "Espresso launcher using the polyglot API.", @@ -352,7 +352,7 @@ "com.oracle.truffle.espresso.libjavavm", ], "distDependencies": [ - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", "sdk:LAUNCHER_COMMON", ], "description": "provides native espresso entry points", @@ -385,7 +385,7 @@ "dependency:espresso:com.oracle.truffle.espresso.native/", # Copy of libjvm.so, accessible by Sulong via the default Truffle file system. "dependency:espresso:com.oracle.truffle.espresso.mokapot/", - "dependency:espresso:POLYGLOT/*", + "dependency:espresso:ESPRESSO_POLYGLOT/*", "dependency:espresso:HOTSWAP/*", ], }, @@ -403,7 +403,7 @@ "dependency:espresso:com.oracle.truffle.espresso.native/", # Copy of libjvm.so, accessible by Sulong via the default Truffle file system. "dependency:espresso:com.oracle.truffle.espresso.mokapot/", - "dependency:espresso:POLYGLOT/*", + "dependency:espresso:ESPRESSO_POLYGLOT/*", "dependency:espresso:HOTSWAP/*", ], }, @@ -422,7 +422,7 @@ "dependency:espresso:com.oracle.truffle.espresso.native/", # Copy of libjvm.so, accessible by Sulong via the default Truffle file system. "dependency:espresso:com.oracle.truffle.espresso.mokapot/", - "dependency:espresso:POLYGLOT/*", + "dependency:espresso:ESPRESSO_POLYGLOT/*", "dependency:espresso:HOTSWAP/*", ], }, @@ -444,7 +444,7 @@ "maven": False, }, - "POLYGLOT": { + "ESPRESSO_POLYGLOT": { "subDir": "src", "dependencies": [ "com.oracle.truffle.espresso.polyglot" @@ -457,6 +457,9 @@ "exports" : [ "com.oracle.truffle.espresso.polyglot", ] + }, + "maven": { + "artifactId": "polyglot", } }, diff --git a/espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/Native.java b/espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/Native.java index 55386fb67b6c..03df90af8692 100644 --- a/espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/Native.java +++ b/espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/Native.java @@ -24,16 +24,12 @@ package com.oracle.truffle.espresso.libjavavm.arghelper; import static com.oracle.truffle.espresso.libjavavm.Arguments.abort; -import static com.oracle.truffle.espresso.libjavavm.arghelper.ArgumentsHandler.isBooleanOption; -import java.util.EnumSet; -import java.util.Map; +import java.util.Map.Entry; import java.util.SortedMap; import java.util.TreeMap; import org.graalvm.nativeimage.RuntimeOptions; -import org.graalvm.options.OptionDescriptor; -import org.graalvm.options.OptionDescriptors; import com.oracle.truffle.espresso.libjavavm.Arguments; @@ -50,23 +46,6 @@ class Native { private String argPrefix; - private OptionDescriptors compilerOptionDescriptors; - private OptionDescriptors vmOptionDescriptors; - - private OptionDescriptors getCompilerOptions() { - if (compilerOptionDescriptors == null) { - compilerOptionDescriptors = RuntimeOptions.getOptions(EnumSet.of(RuntimeOptions.OptionClass.Compiler)); - } - return compilerOptionDescriptors; - } - - private OptionDescriptors getVMOptions() { - if (vmOptionDescriptors == null) { - vmOptionDescriptors = RuntimeOptions.getOptions(EnumSet.of(RuntimeOptions.OptionClass.VM)); - } - return vmOptionDescriptors; - } - void init(boolean fromXXHandling) { argPrefix = fromXXHandling ? "-" : "--vm."; } @@ -89,19 +68,19 @@ void setNativeOption(String arg) { } } - void printNativeHelp() { + final void printNativeHelp() { handler.printRaw("Native VM options:"); - SortedMap sortedOptions = new TreeMap<>(); - for (OptionDescriptor descriptor : getVMOptions()) { - if (!descriptor.isDeprecated()) { - sortedOptions.put(descriptor.getName(), descriptor); + SortedMap sortedOptions = new TreeMap<>(); + for (RuntimeOptions.Descriptor descriptor : RuntimeOptions.listDescriptors()) { + if (!descriptor.deprecated()) { + sortedOptions.put(descriptor.name(), descriptor); } } - for (Map.Entry entry : sortedOptions.entrySet()) { - OptionDescriptor descriptor = entry.getValue(); - String helpMsg = descriptor.getHelp(); + for (Entry entry : sortedOptions.entrySet()) { + RuntimeOptions.Descriptor descriptor = entry.getValue(); + String helpMsg = descriptor.help(); if (isBooleanOption(descriptor)) { - Boolean val = (Boolean) descriptor.getKey().getDefaultValue(); + Boolean val = (Boolean) descriptor.defaultValue(); if (helpMsg.length() != 0) { helpMsg += ' '; } @@ -112,14 +91,13 @@ void printNativeHelp() { } launcherOption("--vm.XX:\u00b1" + entry.getKey(), helpMsg); } else { - Object def = descriptor.getKey().getDefaultValue(); + Object def = descriptor.defaultValue(); if (def instanceof String) { def = "\"" + def + "\""; } launcherOption("--vm.XX:" + entry.getKey() + "=" + def, helpMsg); } } - printCompilerOptions(); printBasicNativeHelp(); } @@ -145,14 +123,14 @@ private void setGraalStyleRuntimeOption(String arg) { key = arg.substring(0, eqIdx); value = arg.substring(eqIdx + 1); } - OptionDescriptor descriptor = getCompilerOptions().get(key); + RuntimeOptions.Descriptor descriptor = RuntimeOptions.getDescriptor(key); if (descriptor == null) { throw unknownOption(key); } try { - RuntimeOptions.set(key, descriptor.getKey().getType().convert(value)); + RuntimeOptions.set(key, descriptor.convertValue(value)); } catch (IllegalArgumentException iae) { - throw abort("Invalid argument: " + formatArg(arg) + "': " + iae.getMessage()); + throw abort("Invalid argument: " + formatArg(arg) + ": " + iae.getMessage()); } } @@ -170,64 +148,49 @@ private static void setSystemProperty(String arg) { System.setProperty(key, value); } - private void setRuntimeOption(String arg) { + public void setRuntimeOption(String arg) { int eqIdx = arg.indexOf('='); String key; Object value; if (arg.startsWith("+") || arg.startsWith("-")) { key = arg.substring(1); if (eqIdx >= 0) { - throw abort("Invalid argument: " + formatArg(arg) + "': Use either +/- or =, but not both"); + throw abort("Invalid argument: '" + formatArg(arg) + "': Use either +/- or =, but not both"); } - OptionDescriptor descriptor = getVMOptionDescriptor(key); + RuntimeOptions.Descriptor descriptor = getVMOptionDescriptor(key); if (!isBooleanOption(descriptor)) { throw abort("Invalid argument: " + key + " is not a boolean option, set it with " + argPrefix + "XX:" + key + "=."); } value = arg.startsWith("+"); } else if (eqIdx > 0) { key = arg.substring(0, eqIdx); - OptionDescriptor descriptor = getVMOptionDescriptor(key); + RuntimeOptions.Descriptor descriptor = getVMOptionDescriptor(key); if (isBooleanOption(descriptor)) { throw abort("Boolean option '" + key + "' must be set with +/- prefix, not = format."); } try { - value = descriptor.getKey().getType().convert(arg.substring(eqIdx + 1)); + value = descriptor.convertValue(arg.substring(eqIdx + 1)); } catch (IllegalArgumentException iae) { - throw abort("Invalid argument: " + formatArg(arg) + "': " + iae.getMessage()); + throw abort("Invalid argument: '" + formatArg(arg) + "': " + iae.getMessage()); } } else { - throw abort("Invalid argument: " + formatArg(arg) + "'. Prefix boolean options with + or -, suffix other options with ="); + throw abort("Invalid argument: '" + formatArg(arg) + "'. Prefix boolean options with + or -, suffix other options with ="); } RuntimeOptions.set(key, value); } - private OptionDescriptor getVMOptionDescriptor(String key) { - OptionDescriptor descriptor = getVMOptions().get(key); + private static boolean isBooleanOption(RuntimeOptions.Descriptor descriptor) { + return descriptor.valueType() == Boolean.class; + } + + private static RuntimeOptions.Descriptor getVMOptionDescriptor(String key) { + RuntimeOptions.Descriptor descriptor = RuntimeOptions.getDescriptor(key); if (descriptor == null) { throw unknownOption(key); } return descriptor; } - private void printCompilerOptions() { - handler.printRaw("Compiler options:"); - SortedMap sortedOptions = new TreeMap<>(); - for (OptionDescriptor descriptor : getCompilerOptions()) { - if (!descriptor.isDeprecated()) { - sortedOptions.put(descriptor.getName(), descriptor); - } - } - for (Map.Entry entry : sortedOptions.entrySet()) { - OptionDescriptor descriptor = entry.getValue(); - String helpMsg = descriptor.getHelp(); - Object def = descriptor.getKey().getDefaultValue(); - if (def instanceof String) { - def = '"' + (String) def + '"'; - } - launcherOption("--vm.Dgraal." + entry.getKey() + "=" + def, helpMsg); - } - } - private void printBasicNativeHelp() { launcherOption("--vm.D=", "Sets a system property in the host VM."); /* The default values are *copied* from com.oracle.svm.core.genscavenge.HeapPolicy */ diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/ModuleExtension.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/ModuleExtension.java index 1908188fa6b8..95502bae4a9c 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/ModuleExtension.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/ModuleExtension.java @@ -36,7 +36,7 @@ public final class ModuleExtension { private static final ModuleExtension[] ESPRESSO_EXTENSION_MODULES = new ModuleExtension[]{ new ModuleExtension("espresso.hotswap", "hotswap.jar", (context) -> context.getEspressoEnv().JDWPOptions != null), - new ModuleExtension("espresso.polyglot", "polyglot.jar", (context) -> context.getEspressoEnv().Polyglot), + new ModuleExtension("espresso.polyglot", "espresso-polyglot.jar", (context) -> context.getEspressoEnv().Polyglot), }; private static final ModuleExtension[] EMPTY_MODULE_EXTENSION_ARRAY = new ModuleExtension[0]; diff --git a/java-benchmarks/mx.java-benchmarks/mx_java_benchmarks.py b/java-benchmarks/mx.java-benchmarks/mx_java_benchmarks.py index 2bd6a06211c3..b5f63d62b17b 100644 --- a/java-benchmarks/mx.java-benchmarks/mx_java_benchmarks.py +++ b/java-benchmarks/mx.java-benchmarks/mx_java_benchmarks.py @@ -366,7 +366,7 @@ def extra_image_build_argument(self, benchmark, args): '-H:NativeLinkerOption=-no-pie', '-H:-UseServiceLoaderFeature', '-H:+AllowDeprecatedBuilderClassesOnImageClasspath', # needs to be removed once GR-41746 is fixed - '--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED', + '--add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED', '--add-exports=org.graalvm.nativeimage.base/com.oracle.svm.util=ALL-UNNAMED', '--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.configure=ALL-UNNAMED', '--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.localization=ALL-UNNAMED', @@ -535,7 +535,7 @@ def extra_image_build_argument(self, benchmark, args): '--enable-url-protocols=http,https', '-H:-UseServiceLoaderFeature', '-H:+StackTrace', - '-J--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED', + '-J--add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED', '-J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED', '--exclude-config' , 'io\.netty\.netty-codec', @@ -578,7 +578,7 @@ def extra_image_build_argument(self, benchmark, args): return [ '--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED', '--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.configure=ALL-UNNAMED', - '--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED' + '--add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED' ] + super(BaseMicronautBenchmarkSuite,self).extra_image_build_argument(benchmark, args) mx_benchmark.add_bm_suite(BaseMicronautMuShopBenchmark()) diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index 84a782704933..431d652b568c 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -3,6 +3,44 @@ This changelog summarizes major changes between GraalVM SDK versions. The main focus is on APIs exported by GraalVM SDK. ## Version 23.1.0 +* (GR-43819) The GraalVM SDK was split into several more fine-grained modules. The use of the graalvm-sdk module is now deprecated. Please update your Maven and module dependencies accordingly. Note that all APIs remain compatible. The following new modules are available: + * `org.graalvm.nativeimage` A framework that allows to customize native image generation. + * `org.graalvm.polyglot´: A framework that allows to embed polyglot language implementations in Java. + * `org.graalvm.word`: A low-level framework for machine-word-sized values in Java. + * `org.graalvm.collections`: A collections framework for GraalVM components. + Old Maven configuration: + ```xml + + org.graalvm.sdk + graal-sdk + ${graalvm.version} + + ``` + New Maven configuration: + ```xml + + org.graalvm.sdk + nativeimage + ${graalvm.version} + + + org.graalvm.polyglot + polyglot + ${graalvm.version} + + + org.graalvm.word + word + ${graalvm.version} + + + org.graalvm.collections + collections + ${graalvm.version} + + ``` +* (GR-43819) The `org.graalvm.polyglot` package and module is no longer contained in the boot module of a GraalVM JDK. Please depend on `org.graalvm.polyglot:polyglot` using Maven instead. +* (GR-43819) Removed the deprecated APIs in `org.graalvm.nativeimage.RuntimeOptions` and added a new replacement API. * (GR-46556) Provide [documentation and example code](https://www.graalvm.org/latest/reference-manual/embed-languages/#compatibility-with-jsr-223-scriptengine) on how to use Truffle languages via the ScriptEngine API. The example code can be inlined and modified for testing, we still recommend to use the Polyglot API for full control over embeddings. * (GR-45896) JLine3 upgrade from 3.16 to 3.23. The JLine3 bundle that is used is customized and contains only `jline3-reader`, `jline3-terminal`, and `jline3-builtins` JLine3 components. * (GR-44222) Polyglot contexts and engines now print a warning when deprecated options were used. To resolve this migrate the option using the deprecation instructions or set the `engine.WarnOptionDeprecation` to `false` to suppress this warning. It is recommended to prefer migration over suppression whenever possible. diff --git a/sdk/mx.sdk/mx_sdk.py b/sdk/mx.sdk/mx_sdk.py index c5c06c83d94c..3acf510aa709 100644 --- a/sdk/mx.sdk/mx_sdk.py +++ b/sdk/mx.sdk/mx_sdk.py @@ -107,6 +107,7 @@ def upx(args): upx_cmd = [upx_path] + args mx.run(upx_cmd, mx.TeeOutputCapture(mx.OutputCapture()), mx.TeeOutputCapture(mx.OutputCapture())) +# SDK modules included if truffle, compiler and native-image is included mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVmJreComponent( suite=_suite, name='Graal SDK', @@ -114,9 +115,37 @@ def upx(args): dir_name='graalvm', license_files=[], third_party_license_files=[], + dependencies=['sdkni'], + jar_distributions=[], + boot_jars=['sdk:POLYGLOT', 'sdk:GRAAL_SDK'], + stability="supported", +)) + +# SDK modules included the compiler is included +mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVmJreComponent( + suite=_suite, + name='Graal SDK Compiler', + short_name='sdkc', + dir_name='graalvm', + license_files=[], + third_party_license_files=[], dependencies=[], jar_distributions=[], - boot_jars=['sdk:GRAAL_SDK'], + boot_jars=['sdk:WORD', 'sdk:COLLECTIONS'], + stability="supported", +)) + +# SDK modules included if the compiler and native-image is included +mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVmJreComponent( + suite=_suite, + name='Graal SDK Native Image', + short_name='sdkni', + dir_name='graalvm', + license_files=[], + third_party_license_files=[], + dependencies=['sdkc'], + jar_distributions=[], + boot_jars=['sdk:NATIVEIMAGE'], stability="supported", )) diff --git a/sdk/mx.sdk/mx_sdk_vm_impl.py b/sdk/mx.sdk/mx_sdk_vm_impl.py index 8f45f84d6ffc..3bd6b0cdf61d 100644 --- a/sdk/mx.sdk/mx_sdk_vm_impl.py +++ b/sdk/mx.sdk/mx_sdk_vm_impl.py @@ -2175,12 +2175,12 @@ def _get_extra_jvm_args(): if not _jlink_libraries(): if mx.is_windows(): extra_jvm_args = ' '.join([extra_jvm_args, r'--upgrade-module-path "%location%\..\..\jvmci\graal.jar"', - r'--add-modules org.graalvm.truffle,org.graalvm.sdk', - r'--module-path "%location%\..\..\truffle\truffle-api.jar:%location%\..\..\jvmci\graal-sdk.jar"']) + r'--add-modules org.graalvm.polyglot', + r'--module-path "%location%\..\..\truffle\truffle-api.jar:%location%\..\..\jvmci\polyglot.jar"']) else: extra_jvm_args = ' '.join([extra_jvm_args, '--upgrade-module-path "${location}/../../jvmci/graal.jar"', - '--add-modules org.graalvm.truffle,org.graalvm.sdk', - '--module-path "${location}/../../truffle/truffle-api.jar:${location}/../../jvmci/graal-sdk.jar"']) + '--add-modules org.graalvm.polyglot', + '--module-path "${location}/../../truffle/truffle-api.jar:${location}/../../jvmci/polyglot.jar"']) return extra_jvm_args def _get_option_vars(): diff --git a/sdk/mx.sdk/suite.py b/sdk/mx.sdk/suite.py index 80181d94a4ab..7ca35a6bc4be 100644 --- a/sdk/mx.sdk/suite.py +++ b/sdk/mx.sdk/suite.py @@ -229,6 +229,7 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ + "org.graalvm.options", "org.graalvm.collections", "org.graalvm.home", ], @@ -240,6 +241,19 @@ "workingSets" : "API,SDK", }, + "org.graalvm.sdk" : { + "subDir" : "src", + "sourceDirs" : ["src"], + "dependencies" : [ + "sdk:COLLECTIONS", + "sdk:NATIVEIMAGE", + "sdk:POLYGLOT", + "sdk:WORD"], + "checkstyle" : "org.graalvm.word", + "javaCompliance" : "17+", + "workingSets" : "API,SDK", + }, + "org.graalvm.word" : { "subDir" : "src", "sourceDirs" : ["src"], @@ -254,8 +268,7 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "org.graalvm.word", - "org.graalvm.options", + "sdk:WORD", ], "checkstyle" : "org.graalvm.word", "javaCompliance" : "11+", @@ -286,7 +299,7 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "org.graalvm.polyglot", + "sdk:POLYGLOT", "JLINE3", ], "requires" : [ @@ -314,7 +327,7 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "org.graalvm.polyglot", + "sdk:POLYGLOT", ], "checkstyle" : "org.graalvm.word", "javaCompliance" : "17+", @@ -332,7 +345,7 @@ "sourceDirs" : ["src"], "dependencies" : [ "mx:JUNIT", - "org.graalvm.collections", + "COLLECTIONS", ], "checkstyle" : "org.graalvm.word", "javaCompliance" : "17+", @@ -342,7 +355,7 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "org.graalvm.nativeimage", + "NATIVEIMAGE", ], "checkstyle" : "org.graalvm.word", "javaCompliance" : "11+", @@ -353,7 +366,7 @@ "sourceDirs" : ["src"], "dependencies" : [ "mx:JUNIT", - "org.graalvm.home", + "sdk:POLYGLOT", ], "checkstyle" : "org.graalvm.word", "javaCompliance" : "17+", @@ -363,7 +376,7 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "GRAAL_SDK", + "NATIVEIMAGE", ], "requires" : [ ], @@ -537,21 +550,50 @@ class UniversalDetector { "GRAAL_SDK" : { "subDir" : "src", "dependencies" : [ - "org.graalvm.polyglot", + "org.graalvm.sdk", + ], + "distDependencies" : [ + "sdk:COLLECTIONS", + "sdk:NATIVEIMAGE", + "sdk:POLYGLOT", + "sdk:WORD", + ], + "javadocType": "api", + "moduleInfo" : { + "name" : "org.graalvm.sdk", + "requires" : [ + "transitive java.logging", + "transitive org.graalvm.word", + "transitive org.graalvm.polyglot", + "transitive org.graalvm.nativeimage", + "transitive org.graalvm.collections", + ], + "exports" : [ + "org.graalvm.sdk" + ], + "uses" : [ + ], + "opens" : [ + ], + }, + "description" : "Shared library", + "maven": True, + }, + + "NATIVEIMAGE" : { + "subDir" : "src", + "dependencies" : [ "org.graalvm.nativeimage", "com.oracle.svm.core.annotate", - "org.graalvm.collections", - "org.graalvm.home", ], - "distDependencies" : [], + "distDependencies" : ["WORD"], "javadocType": "api", "moduleInfo" : { - "name" : "org.graalvm.sdk", - "requires" : ["java.logging"], + "name" : "org.graalvm.nativeimage", + "requires" : [ + "transitive org.graalvm.word", + ], "exports" : [ - "org.graalvm.collections", - "org.graalvm.home", - "org.graalvm.home.impl", "com.oracle.svm.core.annotate", "org.graalvm.nativeimage.hosted", "org.graalvm.nativeimage.c.function", @@ -560,17 +602,49 @@ class UniversalDetector { "org.graalvm.nativeimage.c.constant", "org.graalvm.nativeimage.c", "org.graalvm.nativeimage", + """org.graalvm.nativeimage.impl to org.graalvm.nativeimage.pointsto, + org.graalvm.nativeimage.base, + org.graalvm.nativeimage.builder, + org.graalvm.nativeimage.configure, + com.oracle.svm.svm_enterprise, + org.graalvm.extraimage.builder, + org.graalvm.truffle.runtime.svm, + com.oracle.svm.enterprise.truffle, + org.graalvm.nativeimage.foreign""", + "org.graalvm.nativeimage.impl.clinit to org.graalvm.nativeimage.builder", + ], + "uses" : [], + "opens" : [], + }, + "description" : "A framework that allows to customize native image generation.", + "maven": True, + }, + + "POLYGLOT" : { + "subDir" : "src", + "dependencies" : [ + "org.graalvm.polyglot", + "org.graalvm.home", + ], + "distDependencies" : ["COLLECTIONS", "NATIVEIMAGE"], + "javadocType": "api", + "moduleInfo" : { + "name" : "org.graalvm.polyglot", + "requires" : [ + "transitive java.logging", + "org.graalvm.word", + "org.graalvm.nativeimage", + "org.graalvm.collections", + ], + "exports" : [ + "org.graalvm.home", + "org.graalvm.home.impl", "org.graalvm.polyglot.proxy", "org.graalvm.polyglot.io", "org.graalvm.polyglot.management", "org.graalvm.polyglot", "org.graalvm.options", - "org.graalvm.word", "org.graalvm.polyglot.impl to org.graalvm.truffle, com.oracle.truffle.enterprise", - "org.graalvm.word.impl to jdk.internal.vm.compiler", - """org.graalvm.nativeimage.impl to org.graalvm.nativeimage.pointsto,org.graalvm.nativeimage.base,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.configure,com.oracle.svm.svm_enterprise,org.graalvm.extraimage.builder,org.graalvm.nativeimage.foreign, - org.graalvm.truffle.runtime.svm,com.oracle.svm.enterprise.truffle""", - "org.graalvm.nativeimage.impl.clinit to org.graalvm.nativeimage.builder", ], "uses" : [ "org.graalvm.polyglot.impl.AbstractPolyglotImpl" @@ -579,8 +653,54 @@ class UniversalDetector { "org.graalvm.polyglot to org.graalvm.truffle" ], }, - "description" : "GraalVM is an ecosystem for compiling and running applications written in multiple languages.\nGraalVM removes the isolation between programming languages and enables interoperability in a shared runtime.", + "description" : "A framework that allows to embed polyglot language implementations in Java.", + "maven" : { + "groupId" : "org.graalvm.polyglot", + "artifactId" : "polyglot", + } + }, + + "COLLECTIONS" : { + "subDir" : "src", + "dependencies" : [ + "org.graalvm.collections", + ], + "distDependencies" : [], + "javadocType": "api", + "moduleInfo" : { + "name" : "org.graalvm.collections", + "requires" : [], + "exports" : [ + "org.graalvm.collections", + ], + "uses" : [], + "opens" : [], + }, + "description" : "A collections framework for GraalVM components.", + "maven": True, }, + + "WORD" : { + "subDir" : "src", + "dependencies" : [ + "org.graalvm.word", + ], + "distDependencies" : [], + "javadocType": "api", + "moduleInfo" : { + "name" : "org.graalvm.word", + "requires" : [], + "exports" : [ + "org.graalvm.word", + "org.graalvm.word.impl to jdk.internal.vm.compiler", + ], + "uses" : [], + "opens" : [], + }, + "description" : "A low-level framework for machine-word-sized values in Java.", + "maven": True, + }, + "SDK_TEST" : { "subDir" : "src", "dependencies" : [ @@ -590,9 +710,11 @@ class UniversalDetector { "org.graalvm.home.test", ], "distDependencies" : [ - "GRAAL_SDK", - "LAUNCHER_COMMON", "mx:JUNIT", + "sdk:POLYGLOT", + "sdk:NATIVEIMAGE", + "sdk:COLLECTIONS", + "sdk:LAUNCHER_COMMON" ], "maven" : False, }, @@ -642,7 +764,7 @@ class UniversalDetector { "org.graalvm.launcher", ], "distDependencies" : [ - "GRAAL_SDK", + "sdk:COLLECTIONS", "sdk:POLYGLOT", "JLINE3", ], "description" : "Common infrastructure to create language launchers using the Polyglot API.", @@ -660,7 +782,7 @@ class UniversalDetector { "org.graalvm.polyglot.tck", ], "distDependencies" : [ - "GRAAL_SDK", + "sdk:COLLECTIONS", "sdk:POLYGLOT", ], "javadocType": "api", "description" : """GraalVM TCK SPI""", @@ -674,7 +796,7 @@ class UniversalDetector { }, "subDir" : "src", "dependencies" : ["org.graalvm.jniutils"], - "distDependencies" : ["GRAAL_SDK"], + "distDependencies" : ["COLLECTIONS", "NATIVEIMAGE"], "description" : "Utilities for JNI calls from within native-image.", "allowsJavadocWarnings": True, }, diff --git a/sdk/src/org.graalvm.launcher/src/org/graalvm/launcher/Launcher.java b/sdk/src/org.graalvm.launcher/src/org/graalvm/launcher/Launcher.java index 417735ddd698..53534c7dea0b 100644 --- a/sdk/src/org.graalvm.launcher/src/org/graalvm/launcher/Launcher.java +++ b/sdk/src/org.graalvm.launcher/src/org/graalvm/launcher/Launcher.java @@ -50,7 +50,6 @@ import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; -import java.lang.ref.WeakReference; import java.nio.channels.FileChannel; import java.nio.channels.OverlappingFileLockException; import java.nio.file.AccessDeniedException; @@ -63,7 +62,6 @@ import java.util.ArrayList; import java.util.BitSet; import java.util.Collections; -import java.util.EnumSet; import java.util.Formatter; import java.util.HashMap; import java.util.Iterator; @@ -81,13 +79,10 @@ import org.graalvm.nativeimage.ImageInfo; import org.graalvm.nativeimage.ProcessProperties; import org.graalvm.nativeimage.RuntimeOptions; -import org.graalvm.nativeimage.RuntimeOptions.OptionClass; import org.graalvm.nativeimage.VMRuntime; import org.graalvm.options.OptionCategory; import org.graalvm.options.OptionDescriptor; -import org.graalvm.options.OptionDescriptors; import org.graalvm.options.OptionStability; -import org.graalvm.options.OptionType; import org.graalvm.shadowed.org.jline.terminal.Terminal; import org.graalvm.shadowed.org.jline.terminal.TerminalBuilder; @@ -1347,32 +1342,6 @@ protected void executePolyglot(List mainArgs, boolean forceNative) { class Native { // execve() to JVM/polyglot from native if needed. // Only parses --jvm/--native to find the VMType and --vm.* to pass/set the VM options. - private WeakReference compilerOptionDescriptors; - private WeakReference vmOptionDescriptors; - - private OptionDescriptors getCompilerOptions() { - OptionDescriptors descriptors = null; - if (compilerOptionDescriptors != null) { - descriptors = compilerOptionDescriptors.get(); - } - if (descriptors == null) { - descriptors = RuntimeOptions.getOptions(EnumSet.of(OptionClass.Compiler)); - compilerOptionDescriptors = new WeakReference<>(descriptors); - } - return descriptors; - } - - private OptionDescriptors getVMOptions() { - OptionDescriptors descriptors = null; - if (vmOptionDescriptors != null) { - descriptors = vmOptionDescriptors.get(); - } - if (descriptors == null) { - descriptors = RuntimeOptions.getOptions(EnumSet.of(OptionClass.VM)); - vmOptionDescriptors = new WeakReference<>(descriptors); - } - return descriptors; - } private void setNativeOption(String arg) { if (arg.startsWith("Dgraal.")) { @@ -1406,24 +1375,12 @@ private void setGraalStyleRuntimeOption(String arg) { key = arg.substring(0, eqIdx); value = arg.substring(eqIdx + 1); } - OptionDescriptor descriptor = getCompilerOptions().get(key); - if (descriptor == null) { - descriptor = getVMOptions().get(key); - if (descriptor != null) { - if (isBooleanOption(descriptor)) { - warn("VM options such as '%s' should be set with '--vm.XX:\u00b1%' is deprecated and will be removed.%n", key); - } else { - warn("VM options such as '%s' should be set with '--vm.XX:%'.%n" + - "Support for setting them with '--vm.Dgraal.%' is deprecated and will be removed.%n", key); - } - } - } + RuntimeOptions.Descriptor descriptor = RuntimeOptions.getDescriptor(key); if (descriptor == null) { throw unknownOption(key); } try { - RuntimeOptions.set(key, descriptor.getKey().getType().convert(value)); + RuntimeOptions.set(key, descriptor.convertValue(value)); } catch (IllegalArgumentException iae) { throw abort("Invalid argument: '--vm." + arg + "': " + iae.getMessage()); } @@ -1452,19 +1409,19 @@ public void setRuntimeOption(String arg) { if (eqIdx >= 0) { throw abort("Invalid argument: '--vm." + arg + "': Use either +/- or =, but not both"); } - OptionDescriptor descriptor = getVMOptionDescriptor(key); + RuntimeOptions.Descriptor descriptor = getVMOptionDescriptor(key); if (!isBooleanOption(descriptor)) { throw abort("Invalid argument: " + key + " is not a boolean option, set it with --vm.XX:" + key + "=."); } value = arg.startsWith("+"); } else if (eqIdx > 0) { key = arg.substring(0, eqIdx); - OptionDescriptor descriptor = getVMOptionDescriptor(key); + RuntimeOptions.Descriptor descriptor = getVMOptionDescriptor(key); if (isBooleanOption(descriptor)) { throw abort("Boolean option '" + key + "' must be set with +/- prefix, not = format."); } try { - value = descriptor.getKey().getType().convert(arg.substring(eqIdx + 1)); + value = descriptor.convertValue(arg.substring(eqIdx + 1)); } catch (IllegalArgumentException iae) { throw abort("Invalid argument: '--vm." + arg + "': " + iae.getMessage()); } @@ -1474,15 +1431,8 @@ public void setRuntimeOption(String arg) { RuntimeOptions.set(key, value); } - private OptionDescriptor getVMOptionDescriptor(String key) { - OptionDescriptor descriptor = getVMOptions().get(key); - if (descriptor == null) { - descriptor = getCompilerOptions().get(key); - if (descriptor != null) { - warn("compiler options such as '%s' should be set with '--vm.Dgraal.%'.%n" + - "Support for setting them with '--vm.XX:...' is deprecated and will be removed.%n", key); - } - } + private RuntimeOptions.Descriptor getVMOptionDescriptor(String key) { + RuntimeOptions.Descriptor descriptor = RuntimeOptions.getDescriptor(key); if (descriptor == null) { throw unknownOption(key); } @@ -1503,8 +1453,8 @@ private void setXOption(String arg) { } } - private boolean isBooleanOption(OptionDescriptor descriptor) { - return descriptor.getKey().getType().equals(OptionType.defaultType(Boolean.class)); + private boolean isBooleanOption(RuntimeOptions.Descriptor descriptor) { + return descriptor.valueType() == Boolean.class; } private AbortException unknownOption(String key) { @@ -1513,17 +1463,17 @@ private AbortException unknownOption(String key) { private void printNativeHelp() { System.out.println("Native VM options:"); - SortedMap sortedOptions = new TreeMap<>(); - for (OptionDescriptor descriptor : getVMOptions()) { - if (!descriptor.isDeprecated()) { - sortedOptions.put(descriptor.getName(), descriptor); + SortedMap sortedOptions = new TreeMap<>(); + for (RuntimeOptions.Descriptor descriptor : RuntimeOptions.listDescriptors()) { + if (!descriptor.deprecated()) { + sortedOptions.put(descriptor.name(), descriptor); } } - for (Entry entry : sortedOptions.entrySet()) { - OptionDescriptor descriptor = entry.getValue(); - String helpMsg = descriptor.getHelp(); + for (Entry entry : sortedOptions.entrySet()) { + RuntimeOptions.Descriptor descriptor = entry.getValue(); + String helpMsg = descriptor.help(); if (isBooleanOption(descriptor)) { - Boolean val = (Boolean) descriptor.getKey().getDefaultValue(); + Boolean val = (Boolean) descriptor.defaultValue(); if (helpMsg.length() != 0) { helpMsg += ' '; } @@ -1534,36 +1484,16 @@ private void printNativeHelp() { } launcherOption("--vm.XX:\u00b1" + entry.getKey(), helpMsg); } else { - Object def = descriptor.getKey().getDefaultValue(); + Object def = descriptor.defaultValue(); if (def instanceof String) { def = "\"" + def + "\""; } launcherOption("--vm.XX:" + entry.getKey() + "=" + def, helpMsg); } } - printCompilerOptions(); printBasicNativeHelp(); } - private void printCompilerOptions() { - System.out.println("Compiler options:"); - SortedMap sortedOptions = new TreeMap<>(); - for (OptionDescriptor descriptor : getCompilerOptions()) { - if (!descriptor.isDeprecated()) { - sortedOptions.put(descriptor.getName(), descriptor); - } - } - for (Entry entry : sortedOptions.entrySet()) { - OptionDescriptor descriptor = entry.getValue(); - String helpMsg = descriptor.getHelp(); - Object def = descriptor.getKey().getDefaultValue(); - if (def instanceof String) { - def = '"' + (String) def + '"'; - } - launcherOption("--vm.Dgraal." + entry.getKey() + "=" + def, helpMsg); - } - } - private void executePolyglot(List args, boolean forceNative) { List command = new ArrayList<>(args.size() + 3); Path executable = getGraalVMBinaryPath("polyglot"); diff --git a/sdk/src/org.graalvm.nativebridge.processor.test/src/org/graalvm/nativebridge/processor/test/TestJNIConfig.java b/sdk/src/org.graalvm.nativebridge.processor.test/src/org/graalvm/nativebridge/processor/test/TestJNIConfig.java index a8301d659d58..e125162110a6 100644 --- a/sdk/src/org.graalvm.nativebridge.processor.test/src/org/graalvm/nativebridge/processor/test/TestJNIConfig.java +++ b/sdk/src/org.graalvm.nativebridge.processor.test/src/org/graalvm/nativebridge/processor/test/TestJNIConfig.java @@ -40,15 +40,15 @@ */ package org.graalvm.nativebridge.processor.test; +import java.time.Duration; +import java.util.List; +import java.util.Map; + import org.graalvm.nativebridge.BinaryInput; import org.graalvm.nativebridge.BinaryMarshaller; import org.graalvm.nativebridge.BinaryOutput; import org.graalvm.nativebridge.JNIConfig; -import org.graalvm.polyglot.TypeLiteral; - -import java.time.Duration; -import java.util.List; -import java.util.Map; +import org.graalvm.nativebridge.TypeLiteral; public final class TestJNIConfig { diff --git a/sdk/src/org.graalvm.nativebridge.processor/src/org/graalvm/nativebridge/processor/AbstractBridgeParser.java b/sdk/src/org.graalvm.nativebridge.processor/src/org/graalvm/nativebridge/processor/AbstractBridgeParser.java index 7a9027adf90e..e7512aee1a4e 100644 --- a/sdk/src/org.graalvm.nativebridge.processor/src/org/graalvm/nativebridge/processor/AbstractBridgeParser.java +++ b/sdk/src/org.graalvm.nativebridge.processor/src/org/graalvm/nativebridge/processor/AbstractBridgeParser.java @@ -1418,7 +1418,7 @@ abstract static class AbstractTypeCache { this.string = (DeclaredType) processor.getType("java.lang.String"); this.suppressWarnings = (DeclaredType) processor.getType("java.lang.SuppressWarnings"); this.throwable = (DeclaredType) processor.getType("java.lang.Throwable"); - this.typeLiteral = (DeclaredType) processor.getType("org.graalvm.polyglot.TypeLiteral"); + this.typeLiteral = (DeclaredType) processor.getType("org.graalvm.nativebridge.TypeLiteral"); this.unmanagedMemory = (DeclaredType) processor.getType("org.graalvm.nativeimage.UnmanagedMemory"); this.weakHashMap = (DeclaredType) processor.getType("java.util.WeakHashMap"); this.wordFactory = (DeclaredType) processor.getType("org.graalvm.word.WordFactory"); diff --git a/sdk/src/org.graalvm.nativebridge/src/org/graalvm/nativebridge/JNIConfig.java b/sdk/src/org.graalvm.nativebridge/src/org/graalvm/nativebridge/JNIConfig.java index 60bd1a31e359..e919200840c3 100644 --- a/sdk/src/org.graalvm.nativebridge/src/org/graalvm/nativebridge/JNIConfig.java +++ b/sdk/src/org.graalvm.nativebridge/src/org/graalvm/nativebridge/JNIConfig.java @@ -57,7 +57,6 @@ import java.util.function.Supplier; import org.graalvm.collections.Pair; -import org.graalvm.polyglot.TypeLiteral; /** * A configuration used by the {@link NativeIsolate} and classes generated by the native bridge diff --git a/sdk/src/org.graalvm.nativebridge/src/org/graalvm/nativebridge/TypeLiteral.java b/sdk/src/org.graalvm.nativebridge/src/org/graalvm/nativebridge/TypeLiteral.java new file mode 100644 index 000000000000..3f9f442c37d5 --- /dev/null +++ b/sdk/src/org.graalvm.nativebridge/src/org/graalvm/nativebridge/TypeLiteral.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.graalvm.nativebridge; + +import java.lang.reflect.Array; +import java.lang.reflect.GenericArrayType; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + +/** + * Represents a generic type {@code T}. Java doesn't yet provide a way to represent generic types, + * so this class does. Forces clients to create a subclass of this class which enables retrieval of + * the type information even at runtime. + * + *

+ * For example, to create a type literal for {@code List}, you can create an empty anonymous + * inner class: + * + *

+ * {@code TypeLiteral> list = new TypeLiteral>() {};} + * + */ +public abstract class TypeLiteral { + + private final Type type; + private final Class rawType; + + /** + * Constructs a new type literal. Derives represented class from type parameter. + * + *

+ * Clients create an empty anonymous subclass. Doing so embeds the type parameter in the + * anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure. + * + * @since 19.0 + */ + @SuppressWarnings("unchecked") + protected TypeLiteral() { + this.type = extractLiteralType(this.getClass()); + this.rawType = (Class) extractRawType(type); + } + + private static Type extractLiteralType(@SuppressWarnings("rawtypes") Class literalClass) { + Type superType = literalClass.getGenericSuperclass(); + Type typeArgument = null; + while (true) { + if (superType instanceof ParameterizedType) { + ParameterizedType parametrizedType = (ParameterizedType) superType; + if (parametrizedType.getRawType() == TypeLiteral.class) { + // found + typeArgument = parametrizedType.getActualTypeArguments()[0]; + break; + } else { + throw new AssertionError("Unsupported type hierarchy for type literal."); + } + } else if (superType instanceof Class) { + if (superType == TypeLiteral.class) { + typeArgument = Object.class; + break; + } else { + superType = ((Class) superType).getGenericSuperclass(); + } + } else { + throw new AssertionError("Unsupported type hierarchy for type literal."); + } + } + return typeArgument; + } + + private static Class extractRawType(Type type) { + Class rawType; + if (type instanceof Class) { + rawType = (Class) type; + } else if (type instanceof ParameterizedType) { + rawType = (Class) ((ParameterizedType) type).getRawType(); + } else if (type instanceof GenericArrayType) { + rawType = arrayTypeFromComponentType(extractRawType(((GenericArrayType) type).getGenericComponentType())); + } else { + throw new IllegalArgumentException("Unsupported type: " + type); + } + return rawType; + } + + private static Class arrayTypeFromComponentType(Class componentType) { + return Array.newInstance(componentType, 0).getClass(); + } + + /** + * Returns the type literal including generic type information. + */ + public final Type getType() { + return this.type; + } + + /** + * Returns the raw class type of the literal. + */ + public final Class getRawType() { + return rawType; + } + + @Override + public final boolean equals(Object obj) { + return super.equals(obj); + } + + @Override + public final int hashCode() { + return super.hashCode(); + } + + @Override + public final String toString() { + return "TypeLiteral<" + type + ">"; + } + +} diff --git a/sdk/src/org.graalvm.nativeimage/snapshot.sigtest b/sdk/src/org.graalvm.nativeimage/snapshot.sigtest index 046dad975dff..2a8b790eee46 100644 --- a/sdk/src/org.graalvm.nativeimage/snapshot.sigtest +++ b/sdk/src/org.graalvm.nativeimage/snapshot.sigtest @@ -9,14 +9,6 @@ meth public abstract void close() throws java.lang.Exception CLSS public abstract interface java.lang.Comparable<%0 extends java.lang.Object> meth public abstract int compareTo({java.lang.Comparable%0}) -CLSS public abstract interface !annotation java.lang.Deprecated - anno 0 java.lang.annotation.Documented() - anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) - anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, MODULE, PARAMETER, TYPE]) -intf java.lang.annotation.Annotation -meth public abstract !hasdefault boolean forRemoval() -meth public abstract !hasdefault java.lang.String since() - CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) innr public final static EnumDesc @@ -35,7 +27,7 @@ meth public final java.util.Optional meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object -hfds name,ordinal +hfds hash,name,ordinal CLSS public java.lang.Error cons protected init(java.lang.String,java.lang.Throwable,boolean,boolean) @@ -233,12 +225,12 @@ meth public abstract void log(org.graalvm.nativeimage.c.type.CCharPointer,org.gr CLSS public final org.graalvm.nativeimage.MissingReflectionRegistrationError cons public init(java.lang.String,java.lang.Class,java.lang.Class,java.lang.String,java.lang.Class[]) -meth public java.lang.Class getElementType() meth public java.lang.Class getDeclaringClass() -meth public java.lang.String getElementName() +meth public java.lang.Class getElementType() meth public java.lang.Class[] getParameterTypes() +meth public java.lang.String getElementName() supr java.lang.Error -hfds serialVersionUID +hfds declaringClass,elementName,elementType,parameterTypes,serialVersionUID CLSS public abstract interface org.graalvm.nativeimage.ObjectHandle intf org.graalvm.word.ComparableWord @@ -457,23 +449,22 @@ meth public static void exec(java.nio.file.Path,java.lang.String[],java.util.Map supr java.lang.Object CLSS public final org.graalvm.nativeimage.RuntimeOptions -innr public final static !enum OptionClass +innr public abstract interface static Descriptor meth public static <%0 extends java.lang.Object> {%%0} get(java.lang.String) -meth public static org.graalvm.options.OptionDescriptors getOptions() - anno 0 java.lang.Deprecated(boolean forRemoval=true, java.lang.String since="23.0") -meth public static org.graalvm.options.OptionDescriptors getOptions(java.util.EnumSet) - anno 0 java.lang.Deprecated(boolean forRemoval=true, java.lang.String since="23.0") +meth public static java.util.List listDescriptors() +meth public static org.graalvm.nativeimage.RuntimeOptions$Descriptor getDescriptor(java.lang.String) meth public static void set(java.lang.String,java.lang.Object) supr java.lang.Object -CLSS public final static !enum org.graalvm.nativeimage.RuntimeOptions$OptionClass +CLSS public abstract interface static org.graalvm.nativeimage.RuntimeOptions$Descriptor outer org.graalvm.nativeimage.RuntimeOptions - anno 0 java.lang.Deprecated(boolean forRemoval=true, java.lang.String since="23.0") -fld public final static org.graalvm.nativeimage.RuntimeOptions$OptionClass Compiler -fld public final static org.graalvm.nativeimage.RuntimeOptions$OptionClass VM -meth public static org.graalvm.nativeimage.RuntimeOptions$OptionClass valueOf(java.lang.String) -meth public static org.graalvm.nativeimage.RuntimeOptions$OptionClass[] values() -supr java.lang.Enum +meth public abstract boolean deprecated() +meth public abstract java.lang.Class valueType() +meth public abstract java.lang.Object convertValue(java.lang.String) +meth public abstract java.lang.Object defaultValue() +meth public abstract java.lang.String deprecatedMessage() +meth public abstract java.lang.String help() +meth public abstract java.lang.String name() CLSS public final org.graalvm.nativeimage.StackValue meth public static <%0 extends org.graalvm.word.PointerBase> {%%0} get(int) @@ -1097,26 +1088,26 @@ meth public !varargs static void register(boolean,boolean,java.lang.reflect.Fiel meth public !varargs static void register(boolean,java.lang.reflect.Field[]) anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="21.1") meth public !varargs static void register(java.lang.Class[]) -meth public static void registerClassLookup(java.lang.String) meth public !varargs static void register(java.lang.reflect.Executable[]) -meth public !varargs static void registerMethodLookup(java.lang.Class,java.lang.String,java.lang.Class[]) -meth public !varargs static void registerConstructorLookup(java.lang.Class,java.lang.Class[]) meth public !varargs static void register(java.lang.reflect.Field[]) -meth public static void registerFieldLookup(java.lang.Class,java.lang.String) meth public !varargs static void registerAsQueried(java.lang.reflect.Executable[]) +meth public !varargs static void registerConstructorLookup(java.lang.Class,java.lang.Class[]) meth public !varargs static void registerForReflectiveInstantiation(java.lang.Class[]) +meth public !varargs static void registerMethodLookup(java.lang.Class,java.lang.String,java.lang.Class[]) meth public static void registerAllClasses(java.lang.Class) -meth public static void registerAllDeclaredClasses(java.lang.Class) meth public static void registerAllConstructors(java.lang.Class) +meth public static void registerAllDeclaredClasses(java.lang.Class) meth public static void registerAllDeclaredConstructors(java.lang.Class) -meth public static void registerAllFields(java.lang.Class) meth public static void registerAllDeclaredFields(java.lang.Class) -meth public static void registerAllMethods(java.lang.Class) meth public static void registerAllDeclaredMethods(java.lang.Class) +meth public static void registerAllFields(java.lang.Class) +meth public static void registerAllMethods(java.lang.Class) meth public static void registerAllNestMembers(java.lang.Class) meth public static void registerAllPermittedSubclasses(java.lang.Class) meth public static void registerAllRecordComponents(java.lang.Class) meth public static void registerAllSigners(java.lang.Class) +meth public static void registerClassLookup(java.lang.String) +meth public static void registerFieldLookup(java.lang.Class,java.lang.String) supr java.lang.Object CLSS public final org.graalvm.nativeimage.hosted.RuntimeResourceAccess diff --git a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/RuntimeOptions.java b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/RuntimeOptions.java index 4b20f6926c70..c66f92063e10 100644 --- a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/RuntimeOptions.java +++ b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/RuntimeOptions.java @@ -40,10 +40,9 @@ */ package org.graalvm.nativeimage; -import java.util.EnumSet; +import java.util.List; import org.graalvm.nativeimage.impl.RuntimeOptionsSupport; -import org.graalvm.options.OptionDescriptors; /** * Used for manipulating options at run time. @@ -74,45 +73,80 @@ public static T get(String optionName) { } /** - * Classes of options that can be queried through {@code getOptions(EnumSet)}. - * - * @deprecated This class was mistakenly made API and will be removed in a future version. If - * your codebase depends on it, let us know by creating an issue on GitHub. + * Lists all runtime option descriptors available. * - * @since 19.0 + * @since 23.1 */ - @Deprecated(since = "23.0", forRemoval = true) - public enum OptionClass { - VM, - Compiler + public static List listDescriptors() { + return ImageSingletons.lookup(RuntimeOptionsSupport.class).listDescriptors(); } /** - * Returns available run time options for the selected {@linkplain OptionClass option classes}. - * - * @deprecated This method was mistakenly made an API method and will be removed in a future - * version. If your codebase depends on it, let us know by creating an issue on - * GitHub. + * Looks up a single descriptor given an option name. Returns null if no descriptor + * could be found. * - * @since 19.0 + * @since 23.1 */ - @Deprecated(since = "23.0", forRemoval = true) - public static OptionDescriptors getOptions(EnumSet classes) { - return ImageSingletons.lookup(RuntimeOptionsSupport.class).getOptions(classes); + public static Descriptor getDescriptor(String optionName) { + return ImageSingletons.lookup(RuntimeOptionsSupport.class).getDescriptor(optionName); } - /** - * Returns all available run time options. - * - * @deprecated This method was mistakenly made an API method and will be removed in a future - * version. If your codebase depends on it, let us know by creating an issue on - * GitHub. - * - * @since 19.0 - */ - @Deprecated(since = "23.0", forRemoval = true) - public static OptionDescriptors getOptions() { - return getOptions(EnumSet.allOf(OptionClass.class)); + public interface Descriptor { + /** + * Returns the name of the option that this descriptor represents. + * + * @since 23.1 + */ + String name(); + + /** + * Returns a human-readable description on how to use the option. For newlines, use + * %n. + * + * @since 23.1 + */ + String help(); + + /** + * Returns true if this option was marked deprecated. This indicates that the + * option is going to be removed in a future release or its use is not recommended. + * + * @since 23.1 + */ + boolean deprecated(); + + /** + * Returns the deprecation reason and the recommended fix. For newlines, use + * %n. + * + * @since 23.1 + */ + String deprecatedMessage(); + + /** + * Returns the option type of this key. Typical values are {@link String}, {@link Boolean}, + * {@link Integer}. The result of {@link #convertValue(String)} is guaranteed to be + * assignable to this type. + * + * @since 23.1 + */ + Class valueType(); + + /** + * Returns the default value of type {@link #valueType()} for this option. + * + * @since 23.1 + */ + Object defaultValue(); + + /** + * Converts a string value, validates it, and converts it to an object of this type. For + * option maps includes the previous map stored for the option and the key. + * + * @throws IllegalArgumentException if the value is invalid or cannot be converted. + * @since 23.1 + */ + Object convertValue(String value) throws IllegalArgumentException; } } diff --git a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/RuntimeOptionsSupport.java b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/RuntimeOptionsSupport.java index 0a14bf955173..0162fe7cc470 100644 --- a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/RuntimeOptionsSupport.java +++ b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/RuntimeOptionsSupport.java @@ -40,16 +40,18 @@ */ package org.graalvm.nativeimage.impl; -import java.util.EnumSet; +import java.util.List; -import org.graalvm.nativeimage.RuntimeOptions.OptionClass; -import org.graalvm.options.OptionDescriptors; +import org.graalvm.nativeimage.RuntimeOptions.Descriptor; public interface RuntimeOptionsSupport { + void set(String optionName, Object value); T get(String optionName); - @SuppressWarnings("deprecation") - OptionDescriptors getOptions(EnumSet classes); + List listDescriptors(); + + Descriptor getDescriptor(String optionName); + } diff --git a/sdk/src/org.graalvm.sdk/src/org/graalvm/sdk/Placeholder.java b/sdk/src/org.graalvm.sdk/src/org/graalvm/sdk/Placeholder.java new file mode 100644 index 000000000000..141fc2baed13 --- /dev/null +++ b/sdk/src/org.graalvm.sdk/src/org/graalvm/sdk/Placeholder.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.graalvm.sdk; + +/** + * @since 23.1 + */ +public final class Placeholder { + private Placeholder() { + } + /* + * This class is just here to keep the package and module non-empty. + */ +} diff --git a/sdk/src/org.graalvm.sdk/src/org/graalvm/sdk/package-info.java b/sdk/src/org.graalvm.sdk/src/org/graalvm/sdk/package-info.java new file mode 100644 index 000000000000..ed8012faadd7 --- /dev/null +++ b/sdk/src/org.graalvm.sdk/src/org/graalvm/sdk/package-info.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +/* + @ApiInfo( + group="GraalVM SDK" + ) + */ +/** + * The GraalVM SDK package contains classes for GraalVM. + * + * @since 23.1 + * @deprecated Do not use the sdk module. Use one of the newly split modules: nativeimage, polyglot, + * collections or word instead. + */ +package org.graalvm.sdk; diff --git a/substratevm/mx.substratevm/macro-truffle.properties b/substratevm/mx.substratevm/macro-truffle.properties index 60c81f5d8760..d9775633b7a5 100644 --- a/substratevm/mx.substratevm/macro-truffle.properties +++ b/substratevm/mx.substratevm/macro-truffle.properties @@ -17,6 +17,7 @@ Args = --features=com.oracle.svm.truffle.TruffleFeature \ # The `--add-exports` are a temporary solution for languages on classpath, will be fixed by languages modularization, GR-44217. JavaArgs = -Dtruffle.TruffleRuntime=com.oracle.svm.truffle.api.SubstrateTruffleRuntime \ -Dgraalvm.ForcePolyglotInvalid=false \ + --add-exports org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED \ --add-exports java.base/jdk.internal.module=org.graalvm.truffle.runtime.svm \ --add-exports java.base/jdk.internal.misc=org.graalvm.truffle.runtime.svm \ --add-exports jdk.internal.vm.ci/jdk.vm.ci.meta=org.graalvm.truffle.runtime.svm \ diff --git a/substratevm/mx.substratevm/mx_substratevm.py b/substratevm/mx.substratevm/mx_substratevm.py index 51c4c685fa35..ddd2cb890a45 100644 --- a/substratevm/mx.substratevm/mx_substratevm.py +++ b/substratevm/mx.substratevm/mx_substratevm.py @@ -944,7 +944,7 @@ def native_image_context_run(func, func_args=None, config=None, build_if_missing license_files=[], third_party_license_files=[], # Use short name for Truffle Runtime SVM to select by priority - dependencies=['GraalVM compiler', 'SubstrateVM Static Libraries', 'svmt'], + dependencies=['GraalVM compiler', 'SubstrateVM Static Libraries', 'Graal SDK Native Image', 'svmt'], jar_distributions=['substratevm:LIBRARY_SUPPORT'], builder_jar_distributions=[ 'substratevm:SVM', @@ -1029,6 +1029,7 @@ def _native_image_launcher_extra_jvm_args(): main_class=_native_image_launcher_main_class(), build_args=driver_build_args, extra_jvm_args=_native_image_launcher_extra_jvm_args(), + home_finder=False, ), ], library_configs=[ @@ -1046,6 +1047,7 @@ def _native_image_launcher_extra_jvm_args(): '--enable-url-protocols=jar', ], headers=False, + home_finder=False, ), mx_sdk_vm.LibraryConfig( use_modules='image', @@ -1059,6 +1061,7 @@ def _native_image_launcher_extra_jvm_args(): '--features=com.oracle.svm.diagnosticsagent.NativeImageDiagnosticsAgent$RegistrationFeature', ], headers=False, + home_finder=False, ), ], installable=True, @@ -1200,7 +1203,7 @@ def _native_image_launcher_extra_jvm_args(): "--add-exports org.graalvm.nativeimage.builder/com.oracle.svm.hosted=ALL-UNNAMED", "--add-exports org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c=ALL-UNNAMED", "--add-exports org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.util=ALL-UNNAMED", - "--add-exports org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED", + "--add-exports org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED", ], polyglot_lib_jar_dependencies=[ "substratevm:POLYGLOT_NATIVE_API", @@ -1251,7 +1254,7 @@ def _native_image_launcher_extra_jvm_args(): '-J--add-exports=org.graalvm.truffle.compiler/com.oracle.truffle.compiler.hotspot.libgraal=ALL-UNNAMED', '-J--add-exports=org.graalvm.truffle.compiler/com.oracle.truffle.compiler.hotspot=ALL-UNNAMED', '-J--add-exports=org.graalvm.truffle.compiler/com.oracle.truffle.compiler=ALL-UNNAMED', - '-J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.annotate=ALL-UNNAMED', + '-J--add-exports=org.graalvm.nativeimage/com.oracle.svm.core.annotate=ALL-UNNAMED', '-J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.option=ALL-UNNAMED', ## Packages used after option-processing can be opened by the builder (`-J`-prefix not needed) # LibGraalFeature implements com.oracle.svm.core.feature.InternalFeature (needed to be able to instantiate LibGraalFeature) @@ -1307,6 +1310,7 @@ def _native_image_launcher_extra_jvm_args(): build_args=libgraal_build_args + ['--features=com.oracle.svm.graal.hotspot.libgraal.LibGraalFeature,com.oracle.svm.graal.hotspot.libgraal.truffle.TruffleLibGraalFeature'], add_to_module='java.base', headers=False, + home_finder=False, ), ], support_libraries_distributions=[], diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index dcfb534ff6e5..c3cd307052cf 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -180,7 +180,7 @@ "subDir": "src", "sourceDirs": ["src"], "dependencies": [ - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", "compiler:GRAAL", ], "requiresConcealed" : { @@ -547,7 +547,7 @@ "sourceDirs": ["src"], "dependencies": [ "mx:JUNIT_TOOL", - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", "STANDALONE_POINTSTO" ], "requires": [ @@ -883,7 +883,7 @@ "sourceDirs": ["src"], "dependencies": [ "mx:JUNIT_TOOL", - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", "SVM", ], "requires": [ @@ -916,7 +916,7 @@ "sourceDirs": ["src"], "dependencies": [ "mx:JUNIT_TOOL", - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", "com.oracle.svm.configure", ], "checkstyle": "com.oracle.svm.test", @@ -934,7 +934,7 @@ "com.oracle.svm.tutorial" : { "subDir": "src", "sourceDirs" : ["src"], - "dependencies" : ["sdk:GRAAL_SDK"], + "dependencies" : ["sdk:NATIVEIMAGE"], "checkstyle" : "com.oracle.svm.hosted", "javaCompliance" : "17+", "workingSets" : "SVM", @@ -946,7 +946,8 @@ "subDir": "src", "sourceDirs" : ["src"], "dependencies" : [ - "compiler:GRAAL" + "compiler:GRAAL", + "sdk:NATIVEIMAGE", ], "requiresConcealed" : { "java.base" : [ @@ -1003,7 +1004,7 @@ "sourceDirs": ["src"], "dependencies": [ "mx:JUNIT_TOOL", - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", "com.oracle.svm.graal", ], "requiresConcealed" : { @@ -1043,7 +1044,7 @@ "subDir": "src", "sourceDirs": ["src"], "dependencies": [ - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", ], "checkstyle": "com.oracle.svm.core", "javaCompliance" : "17+", @@ -1164,7 +1165,8 @@ "resources", ], "dependencies" : [ - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", + "sdk:NATIVEIMAGE", "com.oracle.svm.hosted", ], "checkstyle": "com.oracle.svm.core", @@ -1361,7 +1363,7 @@ "com.oracle.svm.core.containers", ], "distDependencies": [ - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", "OBJECTFILE", "POINTSTO", "compiler:GRAAL", @@ -1461,7 +1463,7 @@ "com.oracle.svm.thirdparty", ], "distDependencies": [ - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", "SVM", ], "moduleInfo" : { @@ -1479,7 +1481,7 @@ "com.oracle.svm.junit", ], "distDependencies": [ - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", "SVM", "compiler:GRAAL", "mx:JUNIT_TOOL", @@ -1504,6 +1506,7 @@ "com.oracle.objectfile" ], "distDependencies": [ + "sdk:NATIVEIMAGE", "compiler:GRAAL", ], "moduleInfo" : { @@ -1779,11 +1782,13 @@ ], "distDependencies": [ "compiler:GRAAL", + "sdk:NATIVEIMAGE", ], "exclude": [ ], "moduleInfo" : { "name" : "org.graalvm.nativeimage.base", + "requires" : ["java.sql", "java.xml"],# workaround for GR-47773 on the module-path which requires java.sql (like truffle) or java.xml "exports" : [ "com.oracle.svm.util to org.graalvm.nativeimage.pointsto,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.llvm,org.graalvm.nativeimage.agent.jvmtibase,org.graalvm.nativeimage.agent.tracing,org.graalvm.nativeimage.agent.diagnostics,org.graalvm.nativeimage.junitsupport,com.oracle.svm.svm_enterprise,com.oracle.svm_enterprise.ml_dataset,org.graalvm.extraimage.builder,com.oracle.svm.extraimage_enterprise,org.graalvm.extraimage.librarysupport,org.graalvm.nativeimage.foreign,org.graalvm.truffle.runtime.svm,com.oracle.truffle.enterprise.svm", "com.oracle.svm.common.meta to org.graalvm.nativeimage.pointsto,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.llvm,org.graalvm.extraimage.builder,org.graalvm.nativeimage.foreign,org.graalvm.truffle.runtime.svm,com.oracle.truffle.enterprise.svm", @@ -1891,7 +1896,7 @@ ], "distDependencies": [ "mx:JUNIT_TOOL", - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", "STANDALONE_POINTSTO", ], "testDistribution" : True, @@ -1907,7 +1912,7 @@ ], "distDependencies": [ "mx:JUNIT_TOOL", - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", "SVM", "SVM_CONFIGURE", ], @@ -1920,7 +1925,8 @@ "org.graalvm.polyglot.nativeapi", ], "distDependencies": [ - "sdk:GRAAL_SDK", + "sdk:NATIVEIMAGE", + "sdk:POLYGLOT", "SVM", ], "maven": False diff --git a/substratevm/src/com.oracle.svm.configure.test/src/META-INF/native-image/native-image.properties b/substratevm/src/com.oracle.svm.configure.test/src/META-INF/native-image/native-image.properties index 061a0420a766..383d9568d011 100644 --- a/substratevm/src/com.oracle.svm.configure.test/src/META-INF/native-image/native-image.properties +++ b/substratevm/src/com.oracle.svm.configure.test/src/META-INF/native-image/native-image.properties @@ -1,4 +1,4 @@ Args = \ - --add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED \ + --add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED \ --add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.util.json=ALL-UNNAMED \ -H:IncludeResources=com/oracle/svm/configure/test/config/.*json diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/BuildDirectoryProvider.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/BuildDirectoryProvider.java new file mode 100644 index 000000000000..08b3f5da97ac --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/BuildDirectoryProvider.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core; + +import java.nio.file.Path; + +import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + +@Platforms(Platform.HOSTED_ONLY.class) +public interface BuildDirectoryProvider { + + /** + * Returns the home directory of native-image. If native-image is shipped as part of a JDK then + * this returns the JDK home directory. + */ + Path getHome(); + + static BuildDirectoryProvider singleton() { + return ImageSingletons.lookup(BuildDirectoryProvider.class); + } + +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionValues.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionValues.java index fd52c18cba7f..818f0323e03b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionValues.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionValues.java @@ -25,32 +25,25 @@ package com.oracle.svm.core.option; import java.util.ArrayList; -import java.util.EnumSet; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Optional; import org.graalvm.collections.EconomicSet; import org.graalvm.collections.UnmodifiableEconomicMap; import org.graalvm.compiler.api.replacements.Fold; -import org.graalvm.compiler.options.EnumMultiOptionKey; import org.graalvm.compiler.options.ModifiableOptionValues; -import org.graalvm.compiler.options.NestedBooleanOptionKey; import org.graalvm.compiler.options.OptionDescriptor; import org.graalvm.compiler.options.OptionKey; import org.graalvm.compiler.options.OptionValues; +import org.graalvm.compiler.options.OptionsParser; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.RuntimeOptions.OptionClass; +import org.graalvm.nativeimage.RuntimeOptions.Descriptor; import org.graalvm.nativeimage.impl.RuntimeOptionsSupport; -import org.graalvm.options.OptionDescriptors; -import org.graalvm.options.OptionType; import com.oracle.svm.core.annotate.AnnotateOriginal; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.heap.RestrictHeapAccess; -import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ClassUtil; /** @@ -113,91 +106,45 @@ public T get(String optionName) { return optionKey.getValue(RuntimeOptionValues.singleton()); } - @SuppressWarnings({"unchecked", "deprecation"}) - @Override - public OptionDescriptors getOptions(EnumSet classes) { - Iterable descriptors = RuntimeOptionParser.singleton().getDescriptors(); - List graalvmDescriptors = new ArrayList<>(); - for (OptionDescriptor descriptor : descriptors) { - if (classes.contains(getOptionClass(descriptor))) { - org.graalvm.options.OptionDescriptor.Builder builder = org.graalvm.options.OptionDescriptor.newBuilder(asGraalVMOptionKey(descriptor), descriptor.getName()); - String helpMsg = descriptor.getHelp(); - int helpLen = helpMsg.length(); - if (helpLen > 0 && helpMsg.charAt(helpLen - 1) != '.') { - helpMsg += '.'; - } - builder.help(helpMsg); - builder.deprecated(descriptor.isDeprecated()); - builder.deprecationMessage(descriptor.getDeprecationMessage()); - graalvmDescriptors.add(builder.build()); - } - } - return OptionDescriptors.create(graalvmDescriptors); - } + record DescriptorImpl(String name, String help, Class valueType, Object defaultValue, boolean deprecated, String deprecatedMessage) implements Descriptor { - @SuppressWarnings("deprecation") - private static OptionClass getOptionClass(OptionDescriptor descriptor) { - if (descriptor.getOptionKey() instanceof RuntimeOptionKey) { - return OptionClass.VM; + @Override + public Object convertValue(String value) throws IllegalArgumentException { + Optional descriptor = RuntimeOptionParser.singleton().getDescriptor(name); + return OptionsParser.parseOptionValue(descriptor.get(), value); } - return OptionClass.Compiler; + } - @SuppressWarnings({"unchecked", "rawtypes"}) - private static org.graalvm.options.OptionKey asGraalVMOptionKey(OptionDescriptor descriptor) { - Class clazz = (Class) descriptor.getOptionValueType(); - OptionType type; - if (clazz.isEnum()) { - type = (OptionType) ENUM_TYPE_CACHE.computeIfAbsent(clazz, c -> new OptionType<>(ClassUtil.getUnqualifiedName(c), s -> (T) Enum.valueOf((Class) c, s))); - } else if (clazz == Long.class) { - type = (OptionType) LONG_OPTION_TYPE; - } else if (clazz == EconomicSet.class) { - EnumMultiOptionKey multiOptionKey = (EnumMultiOptionKey) descriptor.getOptionKey(); - type = (OptionType) ENUM_MULTI_TYPE_CACHE.computeIfAbsent(multiOptionKey.getEnumClass(), - c -> new OptionType<>("Multi" + ClassUtil.getUnqualifiedName(multiOptionKey.getEnumClass()), s -> (T) multiOptionKey.valueOf(s))); - } else { - type = OptionType.defaultType(clazz); - if (type == null) { - throw VMError.shouldNotReachHere("unsupported type: " + clazz); + @Override + public List listDescriptors() { + List options = new ArrayList<>(); + Iterable descriptors = RuntimeOptionParser.singleton().getDescriptors(); + for (OptionDescriptor descriptor : descriptors) { + DescriptorImpl option = asDescriptor(descriptor); + if (option != null) { + options.add(option); } } - OptionKey optionKey = (OptionKey) descriptor.getOptionKey(); - while (optionKey instanceof NestedBooleanOptionKey) { - optionKey = (OptionKey) ((NestedBooleanOptionKey) optionKey).getParentOption(); - } - T defaultValue = optionKey.getDefaultValue(); - return new org.graalvm.options.OptionKey<>(defaultValue, type); + return options; } - private static final Map, OptionType> ENUM_TYPE_CACHE = new HashMap<>(); - - private static final Map, OptionType> ENUM_MULTI_TYPE_CACHE = new HashMap<>(); - - private static final OptionType LONG_OPTION_TYPE = new OptionType<>("long", RuntimeOptionsSupportImpl::parseLong); - - private static long parseLong(String v) { - String valueString = v.toLowerCase(); - long scale = 1; - if (valueString.endsWith("k")) { - scale = 1024L; - } else if (valueString.endsWith("m")) { - scale = 1024L * 1024L; - } else if (valueString.endsWith("g")) { - scale = 1024L * 1024L * 1024L; - } else if (valueString.endsWith("t")) { - scale = 1024L * 1024L * 1024L * 1024L; + private static DescriptorImpl asDescriptor(OptionDescriptor descriptor) { + if (descriptor == null || !(descriptor.getOptionKey() instanceof RuntimeOptionKey)) { + return null; } - - if (scale != 1) { - /* Remove trailing scale character. */ - valueString = valueString.substring(0, valueString.length() - 1); + String help = descriptor.getHelp(); + int helpLen = help.length(); + if (helpLen > 0 && help.charAt(helpLen - 1) != '.') { + help += '.'; } + return new DescriptorImpl(descriptor.getName(), help, descriptor.getOptionValueType(), descriptor.getOptionKey().getDefaultValue(), descriptor.isDeprecated(), + descriptor.getDeprecationMessage()); + } - try { - return Long.parseLong(valueString) * scale; - } catch (NumberFormatException nfe) { - throw new IllegalArgumentException(String.format("Invalid value \"%s\". Allowed values are [1, inf)(||||).", v)); - } + @Override + public Descriptor getDescriptor(String optionName) { + return asDescriptor(RuntimeOptionParser.singleton().getDescriptor(optionName).orElse(null)); } } diff --git a/substratevm/src/com.oracle.svm.diagnosticsagent/src/com/oracle/svm/diagnosticsagent/NativeImageDiagnosticsAgent.java b/substratevm/src/com.oracle.svm.diagnosticsagent/src/com/oracle/svm/diagnosticsagent/NativeImageDiagnosticsAgent.java index cd8fc1bcd7a7..75001cf0be9d 100644 --- a/substratevm/src/com.oracle.svm.diagnosticsagent/src/com/oracle/svm/diagnosticsagent/NativeImageDiagnosticsAgent.java +++ b/substratevm/src/com.oracle.svm.diagnosticsagent/src/com/oracle/svm/diagnosticsagent/NativeImageDiagnosticsAgent.java @@ -290,7 +290,7 @@ private void openInstrumentationModuleToAllOtherModules(JvmtiEnv jvmti, JNIEnvir JNIObjectHandle moduleName = Support.callObjectMethod(jni, module, moduleGetName); String name = Support.fromJniString(jni, moduleName); - if (name != null && name.equals("org.graalvm.sdk")) { + if (name != null && name.equals("org.graalvm.nativeimage")) { clinitTrackingSupportModule = module; break; } diff --git a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java index 9dd609f551fe..27149cc87ce3 100644 --- a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java +++ b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java @@ -176,7 +176,9 @@ public LibGraalFeature() { ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LibGraalFeature.class, false, "jdk.internal.vm.ci"); ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LibGraalFeature.class, false, "jdk.internal.vm.compiler"); ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LibGraalFeature.class, false, "jdk.internal.vm.compiler.management"); - ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LibGraalFeature.class, false, "org.graalvm.sdk", "org.graalvm.nativeimage.impl"); + ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LibGraalFeature.class, false, "org.graalvm.collections"); + ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LibGraalFeature.class, false, "org.graalvm.word"); + ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LibGraalFeature.class, false, "org.graalvm.nativeimage", "org.graalvm.nativeimage.impl"); ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LibGraalFeature.class, false, "org.graalvm.nativeimage.base"); ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LibGraalFeature.class, false, "org.graalvm.nativeimage.builder"); ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, LibGraalFeature.class, true, "org.graalvm.nativeimage.llvm"); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/BuildDirectoryProviderImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/BuildDirectoryProviderImpl.java new file mode 100644 index 000000000000..9e91c2bac132 --- /dev/null +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/BuildDirectoryProviderImpl.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.hosted; + +import java.nio.file.Path; + +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + +import com.oracle.svm.core.BuildDirectoryProvider; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; + +@Platforms(Platform.HOSTED_ONLY.class) +@AutomaticallyRegisteredImageSingleton(BuildDirectoryProvider.class) +public class BuildDirectoryProviderImpl implements BuildDirectoryProvider { + + @Override + public Path getHome() { + String home = System.getProperty("native-image.root"); + if (home == null || home.isEmpty()) { + // for compatibility with old HomeFinder -> should be removed + home = System.getProperty("org.graalvm.launcher.home"); + } + if (home == null || home.isEmpty()) { + home = System.getProperty("java.home"); + } + return Path.of(home); + } + +} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java index 9f09ec585f5a..80a379cf7d87 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java @@ -661,7 +661,7 @@ private void run() { List requiresInit = Arrays.asList( "jdk.internal.vm.ci", "jdk.internal.vm.compiler", "com.oracle.graal.graal_enterprise", - "org.graalvm.sdk", "org.graalvm.truffle", "org.graalvm.truffle.runtime", + "org.graalvm.nativeimage", "org.graalvm.truffle", "org.graalvm.truffle.runtime", "org.graalvm.truffle.compiler", "com.oracle.truffle.enterprise", "org.graalvm.jniutils", "org.graalvm.nativebridge"); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java index 544e042f3009..95b89ed6873b 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGeneratorRunner.java @@ -192,6 +192,12 @@ private static void checkBootModuleDependencies(boolean verbose) { Set expectedBuilderDependencies = Set.of( "java.base", "java.management", + "java.logging", + // workaround for GR-47773 on the module-path which requires java.sql (like + // truffle) or java.xml + "java.sql", + "java.xml", + "java.transaction.xa", "jdk.management", "java.compiler", "jdk.jfr", @@ -722,7 +728,10 @@ public static void main(String[] args) { } public static void setModuleAccesses() { - ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "org.graalvm.sdk"); + ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "org.graalvm.word"); + ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "org.graalvm.nativeimage"); + ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "org.graalvm.collections"); + ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "org.graalvm.polyglot"); ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "org.graalvm.truffle"); ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "jdk.internal.vm.ci"); ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "jdk.internal.vm.compiler"); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/LLVMToolchain.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/LLVMToolchain.java index 8e3de8c5453e..a9fde8aae706 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/LLVMToolchain.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/LLVMToolchain.java @@ -32,8 +32,7 @@ import java.util.Collections; import java.util.List; -import org.graalvm.home.HomeFinder; - +import com.oracle.svm.core.BuildDirectoryProvider; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.util.InterruptImageBuilding; import com.oracle.svm.hosted.c.util.FileUtils; @@ -97,10 +96,9 @@ public static Path getLLVMBinDir() { if (property != null) { return Paths.get(property); } - - Path runtimeDir = HomeFinder.getInstance().getHomeFolder(); + Path runtimeDir = BuildDirectoryProvider.singleton().getHome(); if (runtimeDir == null) { - throw new IllegalStateException("Could not find GraalVM home"); + throw new IllegalStateException("Could not find java.home"); } if (System.getProperty("java.specification.version").startsWith("1.")) { runtimeDir = runtimeDir.resolve("jre"); diff --git a/substratevm/src/com.oracle.svm.truffle.tck/src/META-INF/native-image/native-image.properties b/substratevm/src/com.oracle.svm.truffle.tck/src/META-INF/native-image/native-image.properties index c43b228f5498..0c5b7039cfad 100644 --- a/substratevm/src/com.oracle.svm.truffle.tck/src/META-INF/native-image/native-image.properties +++ b/substratevm/src/com.oracle.svm.truffle.tck/src/META-INF/native-image/native-image.properties @@ -1,6 +1,6 @@ JavaArgs = --add-exports org.graalvm.nativeimage.base/com.oracle.svm.util=ALL-UNNAMED \ --add-exports org.graalvm.nativeimage.builder/com.oracle.svm.core=ALL-UNNAMED \ - --add-exports org.graalvm.nativeimage.builder/com.oracle.svm.core.annotate=ALL-UNNAMED \ + --add-exports org.graalvm.nativeimage/com.oracle.svm.core.annotate=ALL-UNNAMED \ --add-exports org.graalvm.nativeimage.builder/com.oracle.svm.core.configure=ALL-UNNAMED \ --add-exports org.graalvm.nativeimage.builder/com.oracle.svm.core.option=ALL-UNNAMED \ --add-exports org.graalvm.nativeimage.builder/com.oracle.svm.core.util=ALL-UNNAMED \ diff --git a/substratevm/src/com.oracle.svm.truffle/src/META-INF/native-image/org.graalvm.truffle.runtime.svm/native-image.properties b/substratevm/src/com.oracle.svm.truffle/src/META-INF/native-image/org.graalvm.truffle.runtime.svm/native-image.properties index 5045dcda5b9b..fc017a5c5f6d 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/META-INF/native-image/org.graalvm.truffle.runtime.svm/native-image.properties +++ b/substratevm/src/com.oracle.svm.truffle/src/META-INF/native-image/org.graalvm.truffle.runtime.svm/native-image.properties @@ -1,4 +1,4 @@ -Args = --add-opens=org.graalvm.sdk/org.graalvm.polyglot=org.graalvm.truffle \ +Args = --add-opens=org.graalvm.polyglot/org.graalvm.polyglot=org.graalvm.truffle \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=org.graalvm.truffle.runtime.svm \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=org.graalvm.truffle.runtime.svm \ --add-exports=java.base/jdk.internal.misc=org.graalvm.truffle.runtime.svm \ diff --git a/truffle/external_repos/populate.py b/truffle/external_repos/populate.py index 1ac0a3bd05f4..f15f238c5751 100644 --- a/truffle/external_repos/populate.py +++ b/truffle/external_repos/populate.py @@ -56,7 +56,7 @@ requires java.logging; requires jdk.unsupported; requires org.antlr.antlr4.runtime; - requires org.graalvm.sdk; + requires org.graalvm.polyglot; requires org.graalvm.truffle; provides com.oracle.truffle.api.provider.TruffleLanguageProvider with com.oracle.truffle.sl.SLLanguageProvider; diff --git a/truffle/external_repos/simplelanguage/language/pom.xml b/truffle/external_repos/simplelanguage/language/pom.xml index 3169cb8bb836..4ff29e3ad39f 100644 --- a/truffle/external_repos/simplelanguage/language/pom.xml +++ b/truffle/external_repos/simplelanguage/language/pom.xml @@ -50,7 +50,7 @@ 4.12.0 ${project.build.directory}/jars - --upgrade-module-path='${jar.dir}/truffle-api.jar' --add-opens org.graalvm.sdk/org.graalvm.polyglot=ALL-UNNAMED --add-exports java.base/jdk.internal.module=ALL-UNNAMED + --upgrade-module-path='${jar.dir}/truffle-api.jar' --add-opens org.graalvm.polylgot/org.graalvm.polyglot=ALL-UNNAMED --add-exports java.base/jdk.internal.module=ALL-UNNAMED diff --git a/truffle/external_repos/simplelanguage/launcher/pom.xml b/truffle/external_repos/simplelanguage/launcher/pom.xml index 2c1efa962b05..7e3f9d9900e8 100644 --- a/truffle/external_repos/simplelanguage/launcher/pom.xml +++ b/truffle/external_repos/simplelanguage/launcher/pom.xml @@ -86,7 +86,7 @@ com.oracle.truffle:truffle-api com.oracle.truffle:truffle-dsl-processor com.oracle.truffle:truffle-tck - org.graalvm.sdk:graal-sdk + org.graalvm.polyglot:polyglot @@ -109,8 +109,8 @@ - org.graalvm.sdk - graal-sdk + org.graalvm.polyglot + polyglot ${graalvm.version} diff --git a/truffle/external_repos/simplelanguage/sl b/truffle/external_repos/simplelanguage/sl index c6403a59462c..17761a3659f0 100755 --- a/truffle/external_repos/simplelanguage/sl +++ b/truffle/external_repos/simplelanguage/sl @@ -155,7 +155,7 @@ else echo "Could not find mvn cache at $HOME/.m2" exit 1 fi - GRAAL_SDK_PATH="$HOME/.m2/repository/org/graalvm/sdk/graal-sdk/$VERSION/graal-sdk-$VERSION.jar" + GRAAL_SDK_PATH="$HOME/.m2/repository/org/graalvm/polyglot/polyglot/$VERSION/polylgot-$VERSION.jar" TRUFFLE_API_PATH="$HOME/.m2/repository/org/graalvm/truffle/truffle-api/$VERSION/truffle-api-$VERSION.jar" "$JAVACMD" "${JAVA_ARGS[@]}" -p "$GRAAL_SDK_PATH":"$TRUFFLE_API_PATH":"$ANTLR_RUNTIME_PATH":"$LANGUAGE_PATH" --add-modules "org.graalvm.truffle" -cp "$LAUNCHER_PATH" "$MAIN_CLASS" "${PROGRAM_ARGS[@]}" fi diff --git a/truffle/mx.truffle/mx_truffle.py b/truffle/mx.truffle/mx_truffle.py index fd1b850995ef..08bec1bc766b 100644 --- a/truffle/mx.truffle/mx_truffle.py +++ b/truffle/mx.truffle/mx_truffle.py @@ -197,7 +197,7 @@ def _unittest_config_participant(config): mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.truffle/*=ALL-UNNAMED']) mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.truffle.compiler/*=ALL-UNNAMED']) mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.truffle.runtime/*=ALL-UNNAMED']) - mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.sdk/*=ALL-UNNAMED']) + mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.polyglot/*=ALL-UNNAMED']) mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.sl/*=ALL-UNNAMED']) mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.truffle/*=org.graalvm.sl']) @@ -235,7 +235,7 @@ def _sl_command(vm_args, sl_args, use_optimized_runtime=True, use_enterprise=Tru graalvm_home = mx_sdk_vm.graalvm_home(fatalIfMissing=True) java_path = os.path.join(graalvm_home, 'bin', mx.exe_suffix('java')) dist_names = resolve_sl_dist_names(use_optimized_runtime=use_optimized_runtime, use_enterprise=use_enterprise) - return [java_path] + vm_args + mx.get_runtime_jvm_args(names=dist_names) + ["com.oracle.truffle.sl.launcher.SLMain"] + sl_args + return [java_path] + vm_args + mx.get_runtime_jvm_args(names=dist_names) + ["--module", "org.graalvm.sl_launcher/com.oracle.truffle.sl.launcher.SLMain"] + sl_args def slnative(args): """build a native image of an SL program""" @@ -257,7 +257,7 @@ def _native_image_sl(vm_args, target_dir, use_optimized_runtime=True, use_enterp mx.warn("No native-image installed in GraalVM {}. Switch to an environment that has an installed native-image command.".format(graalvm_home)) return None target_path = os.path.join(target_dir, mx.exe_suffix('sl')) - mx.run([native_image_path] + vm_args + mx.get_runtime_jvm_args(names=resolve_sl_dist_names(use_optimized_runtime=use_optimized_runtime, use_enterprise=use_enterprise)) + ["com.oracle.truffle.sl.launcher.SLMain", target_path]) + mx.run([native_image_path] + vm_args + mx.get_runtime_jvm_args(names=resolve_sl_dist_names(use_optimized_runtime=use_optimized_runtime, use_enterprise=use_enterprise)) + ["--module", "org.graalvm.sl_launcher/com.oracle.truffle.sl.launcher.SLMain", target_path]) return target_path def _truffle_gate_runner(args, tasks): diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 9c9c1866210a..df8b7723fa8b 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -199,7 +199,7 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", ], "requires" : [ "java.logging", @@ -241,7 +241,7 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", "com.oracle.truffle.api.instrumentation", "com.oracle.truffle.api.exception", ], @@ -260,7 +260,6 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "sdk:GRAAL_SDK", "TRUFFLE_API", "TRUFFLE_COMPILER", ], @@ -312,7 +311,7 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", "com.oracle.truffle.api.exception", "truffle:TRUFFLE_ASM_9.5", ], @@ -979,7 +978,7 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", ], "checkstyle" : "com.oracle.truffle.api", "javaCompliance" : "17+", @@ -1279,7 +1278,6 @@ "TRUFFLE_RUNTIME_ATTACH_RESOURCES", ], "distDependencies" : [ - "sdk:GRAAL_SDK", "sdk:JNIUTILS", "TRUFFLE_API", "TRUFFLE_COMPILER", @@ -1375,7 +1373,7 @@ "com.oracle.truffle.api.staticobject", ], "distDependencies" : [ - "sdk:GRAAL_SDK" + "sdk:POLYGLOT" ], "description" : "Truffle is a multi-language framework for executing dynamic languages\nthat achieves high performance when combined with Graal.", "javadocType": "api", @@ -1613,13 +1611,17 @@ "TRUFFLE_SL_LAUNCHER" : { "subDir" : "src", + "moduleInfo" : { + "name" : "org.graalvm.sl_launcher", + }, "javaCompliance" : "17+", "dependencies" : [ "com.oracle.truffle.sl.launcher", ], "distDependencies" : [ - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", ], + "useModulePath": True, "description" : "Truffle SL launchers using the polyglot API.", "allowsJavadocWarnings": True, }, diff --git a/truffle/mx.truffle/tck.py b/truffle/mx.truffle/tck.py index 3663f0fa2b17..278692d1c249 100644 --- a/truffle/mx.truffle/tck.py +++ b/truffle/mx.truffle/tck.py @@ -212,7 +212,7 @@ def _rmdir_recursive(to_delete): os.unlink(to_delete) def _run(args, log_level=False): - _log(LogLevel.FINE, "exec({0})", ', '.join(['"' + a + '"' for a in args])) + _log(LogLevel.FINE, "exec({0})", ' '.join(args)) return subprocess.Popen(args) def _run_java(javaHome, mainClass, cp=None, truffleCp=None, bootCp=None, vmArgs=None, args=None, dbgPort=None): @@ -351,13 +351,13 @@ def execute_tck(graalvm_home, mode=Mode.default(), language_filter=None, values_ jarsToPatch = [] for jarPath in cp: if 'polyglot-tck.jar' in jarPath: - additional_vm_arguments.append('--add-exports=org.graalvm.sdk/org.graalvm.polyglot.tck=ALL-UNNAMED') + additional_vm_arguments.append('--add-exports=org.graalvm.polyglot/org.graalvm.polyglot.tck=ALL-UNNAMED') jarsToPatch.append(os.path.abspath(jarPath)) if 'truffle-tck-common.jar' in jarPath: - additional_vm_arguments.append('--add-exports=org.graalvm.sdk/com.oracle.truffle.tck.common.inline=ALL-UNNAMED') + additional_vm_arguments.append('--add-exports=org.graalvm.polyglot/com.oracle.truffle.tck.common.inline=ALL-UNNAMED') jarsToPatch.append(os.path.abspath(jarPath)) if jarsToPatch: - additional_vm_arguments.extend(['--patch-module', 'org.graalvm.sdk=' + ':'.join(jarsToPatch)]) + additional_vm_arguments.extend(['--patch-module', 'org.graalvm.polyglot=' + ':'.join(jarsToPatch)]) return _execute_tck_impl(graalvm_home, mode, language_filter, values_filter, tests_filter, [_ClassPathEntry(os.path.abspath(e)) for e in cp], diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TruffleExceptionTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TruffleExceptionTest.java index b2f655b766c3..6ab9920a4790 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TruffleExceptionTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/TruffleExceptionTest.java @@ -142,7 +142,7 @@ protected CallTarget parse(TruffleLanguage.ParsingRequest request) throws Except } }, " test", - "(org.graalvm.sdk/)?org.graalvm.polyglot.Context.eval"); + "(org.graalvm.polyglot/)?org.graalvm.polyglot.Context.eval"); } @Test @@ -162,7 +162,7 @@ protected CallTarget parse(TruffleLanguage.ParsingRequest request) throws Except " test-throw", " test-call-inner", " test-call-outer", - "(org.graalvm.sdk/)?org.graalvm.polyglot.Context.eval"); + "(org.graalvm.polyglot/)?org.graalvm.polyglot.Context.eval"); } @Test @@ -182,7 +182,7 @@ protected CallTarget parse(TruffleLanguage.ParsingRequest request) throws Except }, " test-call-inner", " test-call-outer", - "(org.graalvm.sdk/)?org.graalvm.polyglot.Context.eval"); + "(org.graalvm.polyglot/)?org.graalvm.polyglot.Context.eval"); } @Test @@ -199,7 +199,7 @@ protected CallTarget parse(TruffleLanguage.ParsingRequest request) throws Except } }, " test", - "(org.graalvm.sdk/)?org.graalvm.polyglot.Context.eval"); + "(org.graalvm.polyglot/)?org.graalvm.polyglot.Context.eval"); } @Test @@ -215,7 +215,7 @@ protected CallTarget parse(TruffleLanguage.ParsingRequest request) throws Except Pattern.quote("com.oracle.truffle.api.test.TruffleExceptionTest$ThrowNode.executeVoid"), Pattern.quote("com.oracle.truffle.api.test.TruffleExceptionTest$TestRootNode.execute"), " test", - "(org.graalvm.sdk/)?org.graalvm.polyglot.Context.eval"); + "(org.graalvm.polyglot/)?org.graalvm.polyglot.Context.eval"); } @Test diff --git a/vm/mx.vm/ce-unchained b/vm/mx.vm/ce-unchained index 0ec0c82ef8a7..17ac29f69726 100644 --- a/vm/mx.vm/ce-unchained +++ b/vm/mx.vm/ce-unchained @@ -1,5 +1,5 @@ -DYNAMIC_IMPORTS=/compiler,/sdk,/substratevm,/tools,/truffle -COMPONENTS=cmp,lg,ni,nic,nil,sdk,sdkl,svm,svmt,svmsl,tflc,tflsm -NATIVE_IMAGES=graalvm-native-binutil,graalvm-native-clang,graalvm-native-clang-cl,graalvm-native-clang++,graalvm-native-flang,graalvm-native-ld,lib:jvmcicompiler,lib:native-image-agent,lib:native-image-diagnostics-agent,native-image +DYNAMIC_IMPORTS=/sdk,/truffle,/compiler,/substratevm +COMPONENTS=cmp,lg,ni,nic,nil,sdkni,svm,svmt,svmsl,tflc,tflsm +NATIVE_IMAGES=lib:jvmcicompiler,lib:native-image-agent,lib:native-image-diagnostics-agent,native-image NON_REBUILDABLE_IMAGES=lib:jvmcicompiler DISABLE_INSTALLABLES=False diff --git a/vm/mx.vm/libgraal b/vm/mx.vm/libgraal index 720dec5800fb..0ca42680789c 100644 --- a/vm/mx.vm/libgraal +++ b/vm/mx.vm/libgraal @@ -1,4 +1,4 @@ DYNAMIC_IMPORTS=/substratevm -COMPONENTS=lg,tfla,tflc,cmp +COMPONENTS=lg,cmp NATIVE_IMAGES=lib:jvmcicompiler DISABLE_INSTALLABLES=true diff --git a/vm/mx.vm/mx_vm.py b/vm/mx.vm/mx_vm.py index d86079e6470f..2d493facbbd7 100644 --- a/vm/mx.vm/mx_vm.py +++ b/vm/mx.vm/mx_vm.py @@ -162,17 +162,17 @@ llvm_components = ['bgraalvm-native-binutil', 'bgraalvm-native-clang', 'bgraalvm-native-clang-cl', 'bgraalvm-native-clang++', 'bgraalvm-native-flang', 'bgraalvm-native-ld'] # pylint: disable=line-too-long -ce_components_minimal = ['bgu', 'bpolyglot', 'cmp', 'cov', 'dap', 'gu', 'gvm', 'ins', 'insight', 'insightheap', 'lg', 'libpoly', 'lsp', 'nfi-libffi', 'nfi', 'poly', 'polynative', 'pro', 'sdk', 'sdkl', 'spolyglot', 'tfl', 'tfla', 'tflc', 'tflm', 'truffle-json'] +ce_components_minimal = ['bgu', 'bpolyglot', 'cmp', 'cov', 'dap', 'gu', 'gvm', 'ins', 'insight', 'insightheap', 'lg', 'libpoly', 'lsp', 'nfi-libffi', 'nfi', 'poly', 'polynative', 'pro', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'spolyglot', 'tfl', 'tfla', 'tflc', 'tflm', 'truffle-json'] ce_components = ce_components_minimal + ['nr_lib_jvmcicompiler', 'bnative-image-configure', 'ni', 'nic', 'nil', 'svm', 'svmt', 'svmnfi', 'svmsl'] -ce_win_complete_components = ['antlr4', 'bgu', 'bnative-image-configure', 'bpolyglot', 'cmp', 'cov', 'dap', 'ejvm', 'gu', 'gvm', 'gwa', 'icu4j', 'ins', 'insight', 'insightheap', 'java', 'js', 'jsl', 'jss', 'lg', 'libpoly', 'llp', 'llrc', 'llrl', 'llrn', 'lsp', 'nfi-libffi', 'nfi', 'ni', 'nic', 'nil', 'njs', 'njsl', 'poly', 'polynative', 'pro', 'pyn', 'pynl', 'rgx', 'sdk', 'sdkl', 'spolyglot', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm', 'truffle-json', 'vvm'] +ce_win_complete_components = ['antlr4', 'bgu', 'bnative-image-configure', 'bpolyglot', 'cmp', 'cov', 'dap', 'ejvm', 'gu', 'gvm', 'gwa', 'icu4j', 'ins', 'insight', 'insightheap', 'java', 'js', 'jsl', 'jss', 'lg', 'libpoly', 'llp', 'llrc', 'llrl', 'llrn', 'lsp', 'nfi-libffi', 'nfi', 'ni', 'nic', 'nil', 'njs', 'njsl', 'poly', 'polynative', 'pro', 'pyn', 'pynl', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'spolyglot', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm', 'truffle-json', 'vvm'] ce_aarch64_complete_components = ce_win_complete_components + ['rby', 'rbyl', 'svml'] ce_complete_components = ce_aarch64_complete_components + ['ellvm', 'R', 'bRMain'] ce_darwin_aarch64_complete_components = list(ce_aarch64_complete_components) ce_darwin_aarch64_complete_components.remove('svml') # GR-34811 / GR-40147 -ce_ruby_components = ['antlr4', 'cmp', 'cov', 'dap', 'gvm', 'icu4j', 'ins', 'insight', 'insightheap', 'lg', 'llp', 'llrc', 'llrn', 'lsp', 'nfi-libffi', 'nfi', 'pro', 'rby', 'rbyl', 'rgx', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc', 'tflm', 'truffle-json'] -ce_python_components = llvm_components + ['antlr4', 'bgu', 'sllvmvm', 'bpolybench', 'bpolyglot', 'cmp', 'cov', 'dap', 'dis', 'gu', 'gvm', 'icu4j', 'ins', 'insight', 'insightheap', 'lg', 'libpoly', 'llp', 'llrc', 'llrl', 'llrn', 'lsp', 'nfi-libffi', 'nfi', 'pbm', 'pmh', 'poly', 'polynative', 'pro', 'pyn', 'pynl', 'rgx', 'sdk', 'sdkl', 'spolyglot', 'tfl', 'tfla', 'tflc', 'tflm', 'truffle-json'] +ce_ruby_components = ['antlr4', 'cmp', 'cov', 'dap', 'gvm', 'icu4j', 'ins', 'insight', 'insightheap', 'lg', 'llp', 'llrc', 'llrn', 'lsp', 'nfi-libffi', 'nfi', 'pro', 'rby', 'rbyl', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'tflm', 'truffle-json'] +ce_python_components = llvm_components + ['antlr4', 'bgu', 'sllvmvm', 'bpolybench', 'bpolyglot', 'cmp', 'cov', 'dap', 'dis', 'gu', 'gvm', 'icu4j', 'ins', 'insight', 'insightheap', 'lg', 'libpoly', 'llp', 'llrc', 'llrl', 'llrn', 'lsp', 'nfi-libffi', 'nfi', 'pbm', 'pmh', 'poly', 'polynative', 'pro', 'pyn', 'pynl', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'spolyglot', 'tfl', 'tfla', 'tflc', 'tflm', 'truffle-json'] ce_fastr_components = ce_components + llvm_components + ['antlr4', 'sllvmvm', 'llp', 'bnative-image', 'snative-image-agent', 'R', 'bRMain', 'bnative-image-configure', 'llrc', 'snative-image-diagnostics-agent', 'llrn', 'llrl'] -ce_no_native_components = ['bgu', 'bpolyglot', 'cmp', 'cov', 'dap', 'gu', 'gvm', 'ins', 'insight', 'insightheap', 'lsp', 'nfi-libffi', 'nfi', 'polynative', 'pro', 'sdk', 'sdkl', 'spolyglot', 'tfl', 'tfla', 'tflc', 'tflm', 'truffle-json', 'libpoly', 'poly'] +ce_no_native_components = ['bgu', 'bpolyglot', 'cmp', 'cov', 'dap', 'gu', 'gvm', 'ins', 'insight', 'insightheap', 'lsp', 'nfi-libffi', 'nfi', 'polynative', 'pro', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'spolyglot', 'tfl', 'tfla', 'tflc', 'tflm', 'truffle-json', 'libpoly', 'poly'] mx_sdk_vm.register_vm_config('community', ce_components + llvm_components, _suite, env_file='ce-win') mx_sdk_vm.register_vm_config('community', ce_components, _suite, env_file='ce-aarch64') @@ -191,20 +191,20 @@ mx_sdk_vm.register_vm_config('ce-python', ce_python_components, _suite) mx_sdk_vm.register_vm_config('ce-fastr', ce_fastr_components, _suite) mx_sdk_vm.register_vm_config('ce-no_native', ce_no_native_components, _suite) -mx_sdk_vm.register_vm_config('libgraal', ['cmp', 'lg', 'sdk', 'tfla', 'tflc'], _suite) -mx_sdk_vm.register_vm_config('toolchain-only', ['antlr4', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc', 'tflm', 'nfi-libffi', 'nfi', 'cmp', 'llp', 'llrc', 'llrn'], _suite) -mx_sdk_vm.register_vm_config('libgraal-bash', llvm_components + ['bgu', 'cmp', 'gu', 'gvm', 'lg', 'nfi-libffi', 'nfi', 'poly', 'polynative', 'sdk', 'sdkl', 'tfl', 'tfla', 'tflc', 'tflm', 'bpolyglot'], _suite, env_file=False) -mx_sdk_vm.register_vm_config('toolchain-only-bash', llvm_components + ['antlr4', 'bgu', 'tfl', 'tfla', 'tflc', 'tflm', 'gu', 'gvm', 'polynative', 'llp', 'nfi-libffi', 'nfi', 'svml', 'bgu', 'sdk', 'sdkl', 'llrc', 'llrn', 'cmp'], _suite, env_file=False) -mx_sdk_vm.register_vm_config('ce', llvm_components + ['antlr4', 'java', 'libpoly', 'sjavavm', 'spolyglot', 'ejvm', 'sjsvm', 'sllvmvm', 'bnative-image', 'srubyvm', 'pynl', 'spythonvm', 'pyn', 'bwasm', 'cmp', 'gwa', 'icu4j', 'js', 'jsl', 'jss', 'lg', 'llp', 'nfi-libffi', 'nfi', 'ni', 'nil', 'pbm', 'pmh', 'pbi', 'rby', 'rbyl', 'rgx', 'sdk', 'sdkl', 'llrc', 'llrn', 'llrl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file='polybench-ce') -mx_sdk_vm.register_vm_config('ce', ['bnative-image', 'bpolybench', 'cmp', 'icu4j', 'lg', 'nfi', 'ni', 'nil', 'pbi', 'pbm', 'pmh', 'sdk', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, dist_name='ce', env_file='polybench-ctw-ce') -mx_sdk_vm.register_vm_config('ce', ['pbm', 'pmh', 'pbi', 'ni', 'icu4j', 'js', 'jsl', 'jss', 'lg', 'nfi-libffi', 'nfi', 'tfl', 'tfla', 'tflc', 'svm', 'svmt', 'nil', 'rgx', 'sdk', 'sdkl', 'cmp', 'tflm', 'svmnfi', 'svmsl', 'bnative-image', 'sjsvm', 'snative-image-agent', 'snative-image-diagnostics-agent'], _suite, env_file='polybench-nfi-ce') -mx_sdk_vm.register_vm_config('ce', llvm_components + ['antlr4', 'sllvmvm', 'bnative-image', 'cmp', 'lg', 'llrc', 'llrl', 'llrn', 'nfi-libffi', 'nfi', 'ni', 'nil', 'pbm', 'pbi', 'sdk', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file='polybench-sulong-ce') -mx_sdk_vm.register_vm_config('ce', ['nr_lib_jvmcicompiler', 'bnative-image-configure', 'svm', 'nic', 'tflc', 'ni', 'sdk', 'sdkl', 'nil', 'lg', 'svmsl', 'svmt', 'cmp', 'tflsm'], _suite, env_file='ce-unchained') +mx_sdk_vm.register_vm_config('libgraal', ['cmp', 'lg', 'sdkc', 'tflc'], _suite) +mx_sdk_vm.register_vm_config('toolchain-only', ['antlr4', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'tflm', 'nfi-libffi', 'nfi', 'cmp', 'llp', 'llrc', 'llrn'], _suite) +mx_sdk_vm.register_vm_config('libgraal-bash', llvm_components + ['bgu', 'cmp', 'gu', 'gvm', 'lg', 'nfi-libffi', 'nfi', 'poly', 'polynative', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'tflm', 'bpolyglot'], _suite, env_file=False) +mx_sdk_vm.register_vm_config('toolchain-only-bash', llvm_components + ['antlr4', 'bgu', 'tfl', 'tfla', 'tflc', 'tflm', 'gu', 'gvm', 'polynative', 'llp', 'nfi-libffi', 'nfi', 'svml', 'bgu', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'llrc', 'llrn', 'cmp'], _suite, env_file=False) +mx_sdk_vm.register_vm_config('ce', llvm_components + ['antlr4', 'java', 'libpoly', 'sjavavm', 'spolyglot', 'ejvm', 'sjsvm', 'sllvmvm', 'bnative-image', 'srubyvm', 'pynl', 'spythonvm', 'pyn', 'bwasm', 'cmp', 'gwa', 'icu4j', 'js', 'jsl', 'jss', 'lg', 'llp', 'nfi-libffi', 'nfi', 'ni', 'nil', 'pbm', 'pmh', 'pbi', 'rby', 'rbyl', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'llrc', 'llrn', 'llrl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file='polybench-ce') +mx_sdk_vm.register_vm_config('ce', ['bnative-image', 'bpolybench', 'cmp', 'icu4j', 'lg', 'nfi', 'ni', 'nil', 'pbi', 'pbm', 'pmh', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, dist_name='ce', env_file='polybench-ctw-ce') +mx_sdk_vm.register_vm_config('ce', ['pbm', 'pmh', 'pbi', 'ni', 'icu4j', 'js', 'jsl', 'jss', 'lg', 'nfi-libffi', 'nfi', 'tfl', 'tfla', 'tflc', 'svm', 'svmt', 'nil', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'cmp', 'tflm', 'svmnfi', 'svmsl', 'bnative-image', 'sjsvm', 'snative-image-agent', 'snative-image-diagnostics-agent'], _suite, env_file='polybench-nfi-ce') +mx_sdk_vm.register_vm_config('ce', llvm_components + ['antlr4', 'sllvmvm', 'bnative-image', 'cmp', 'lg', 'llrc', 'llrl', 'llrn', 'nfi-libffi', 'nfi', 'ni', 'nil', 'pbm', 'pbi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file='polybench-sulong-ce') +mx_sdk_vm.register_vm_config('ce-unchained', ['nr_lib_jvmcicompiler', 'bnative-image-configure', 'svm', 'nic', 'tflc', 'ni', 'sdkni', 'sdkc', 'nil', 'lg', 'svmsl', 'svmt', 'cmp', 'tflsm'], _suite, env_file='ce-unchained') if mx.get_os() == 'windows': - mx_sdk_vm.register_vm_config('svm', ['bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'njucp', 'nic', 'poly', 'polynative', 'rgx', 'sdk', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file=False) + mx_sdk_vm.register_vm_config('svm', ['bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'njucp', 'nic', 'poly', 'polynative', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file=False) else: - mx_sdk_vm.register_vm_config('svm', ['bgu', 'bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'gu', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'njucp', 'nic', 'poly', 'polynative', 'rgx', 'sdk', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'svml', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file=False) + mx_sdk_vm.register_vm_config('svm', ['bgu', 'bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'gu', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'njucp', 'nic', 'poly', 'polynative', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'svml', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file=False) # pylint: enable=line-too-long diff --git a/vm/mx.vm/mx_vm_gate.py b/vm/mx.vm/mx_vm_gate.py index 7620b7d3fc01..39b8b874485a 100644 --- a/vm/mx.vm/mx_vm_gate.py +++ b/vm/mx.vm/mx_vm_gate.py @@ -46,6 +46,7 @@ from os.path import join, exists, dirname, isdir, isfile, getsize, abspath from tempfile import NamedTemporaryFile, mkdtemp from contextlib import contextmanager +import mx_truffle _suite = mx.suite('vm') @@ -364,8 +365,8 @@ def _test_libgraal_CompilationTimeout_Truffle(extra_vm_arguments): '-XX:+UseJVMCINativeLibrary'] # but ensure libgraal is still used by Truffle delay = abspath(join(dirname(__file__), 'Delay.sl')) - cp = mx.classpath(["com.oracle.truffle.sl", "com.oracle.truffle.sl.launcher"]) - cmd = [join(graalvm_home, 'bin', 'java')] + vmargs + ['-cp', cp, 'com.oracle.truffle.sl.launcher.SLMain', delay] + cp_args = mx.get_runtime_jvm_args(mx_truffle.resolve_sl_dist_names(use_optimized_runtime=True, use_enterprise=True)) + cmd = [join(graalvm_home, 'bin', 'java')] + vmargs + cp_args + ['--module', 'org.graalvm.sl_launcher/com.oracle.truffle.sl.launcher.SLMain', delay] err = mx.OutputCapture() exit_code = mx.run(cmd, nonZeroIsFatal=False, err=err) if err.data: @@ -547,7 +548,7 @@ def gate_substratevm(tasks, quickbuild=False): '--macro:truffle', '--language:nfi', '--add-exports=java.base/jdk.internal.module=ALL-UNNAMED', - '--add-exports=org.graalvm.sdk/org.graalvm.polyglot.impl=ALL-UNNAMED', + '--add-exports=org.graalvm.polyglot/org.graalvm.polyglot.impl=ALL-UNNAMED', '-H:MaxRuntimeCompileMethods=5000', '-R:MaxHeapSize=2g', '--enable-url-protocols=jar', @@ -700,9 +701,6 @@ def gate_svm_truffle_tck_python(tasks): def gate_truffle_unchained(tasks): truffle_suite = mx.suite('truffle') - if truffle_suite: - import mx_truffle - with Task('Truffle Unchained SL JVM', tasks, tags=[VmGateTasks.truffle_unchained]) as t: if t: if not truffle_suite: diff --git a/vm/mx.vm/suite.py b/vm/mx.vm/suite.py index a7bac7a6cae7..930d73f729b0 100644 --- a/vm/mx.vm/suite.py +++ b/vm/mx.vm/suite.py @@ -57,7 +57,7 @@ }, { "name": "fastr", - "version": "aacb5b9fa77de952764c71986113fcd8434a0e68", + "version": "4d2fdc9f4b2a5e6e41c1e55283dbeb174d22f626", "dynamic": True, "urls": [ {"url": "https://github.com/oracle/fastr.git", "kind": "git"}, @@ -115,6 +115,7 @@ "checkstyle": "org.graalvm.component.installer", "dependencies": [ "sdk:LAUNCHER_COMMON", + "sdk:POLYGLOT", "truffle:VISUALVM-LIB-JFLUID-HEAP", ], "requires": [ @@ -241,7 +242,8 @@ ], "distDependencies": [ "sdk:LAUNCHER_COMMON", - "truffle:VISUALVM-LIB-JFLUID-HEAP", + "sdk:POLYGLOT", + "truffle:VISUALVM-LIB-JFLUID-HEAP", ], "maven" : False, }, diff --git a/wasm/mx.wasm/suite.py b/wasm/mx.wasm/suite.py index 7f3a25da2615..c9e7a0199228 100644 --- a/wasm/mx.wasm/suite.py +++ b/wasm/mx.wasm/suite.py @@ -82,7 +82,7 @@ "sourceDirs" : ["src"], "dependencies" : [ "truffle:TRUFFLE_API", - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", ], "requires": [ "jdk.unsupported", # sun.misc.Unsafe @@ -243,7 +243,7 @@ ], "distDependencies" : [ "truffle:TRUFFLE_API", - "sdk:GRAAL_SDK", + "sdk:POLYGLOT", ], "description" : "GraalWasm, an engine for the WebAssembly language in GraalVM.", "allowsJavadocWarnings": True,