Skip to content

Commit d132578

Browse files
committed
removed support for JDK versions < 17
1 parent 9f9c21a commit d132578

File tree

2 files changed

+62
-130
lines changed

2 files changed

+62
-130
lines changed

sdk/mx.sdk/mx_sdk_vm.py

Lines changed: 55 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -573,20 +573,16 @@ def _probe_jvmci_info(jdk, attribute_name):
573573
sink = lambda x: x
574574
mx.run([jdk.java, '-XX:+UnlockExperimentalVMOptions', '-XX:+PrintFlagsFinal', '-version'], out=out, err=sink)
575575
enableJVMCI = False
576-
enableJVMCIProduct = False
577576
jvmciThreadsPerNativeLibraryRuntime = None
578577
for line in out.lines:
579578
if 'EnableJVMCI' in line and 'true' in line:
580579
enableJVMCI = True
581-
if 'EnableJVMCIProduct' in line:
582-
enableJVMCIProduct = True
583580
if 'JVMCIThreadsPerNativeLibraryRuntime' in line:
584581
m = re.search(r'JVMCIThreadsPerNativeLibraryRuntime *= *(\d+)', line)
585582
if not m:
586583
mx.abort(f'Could not extract value of JVMCIThreadsPerNativeLibraryRuntime from "{line}"')
587584
jvmciThreadsPerNativeLibraryRuntime = int(m.group(1))
588585
setattr(jdk, '.enables_jvmci_by_default', enableJVMCI)
589-
setattr(jdk, '.supports_enablejvmciproduct', enableJVMCIProduct)
590586
setattr(jdk, '.jvmciThreadsPerNativeLibraryRuntime', jvmciThreadsPerNativeLibraryRuntime)
591587
return getattr(jdk, attribute_name)
592588

@@ -596,13 +592,6 @@ def jdk_enables_jvmci_by_default(jdk):
596592
"""
597593
return _probe_jvmci_info(jdk, '.enables_jvmci_by_default')
598594

599-
def jdk_supports_enablejvmciproduct(jdk):
600-
"""
601-
Determines if the jdk supports flag -XX:+EnableJVMCIProduct which isn't the case
602-
for some OpenJDK 11u distros.
603-
"""
604-
return _probe_jvmci_info(jdk, '.supports_enablejvmciproduct')
605-
606595
def get_JVMCIThreadsPerNativeLibraryRuntime(jdk):
607596
"""
608597
Gets the value of the flag -XX:JVMCIThreadsPerNativeLibraryRuntime.
@@ -611,50 +600,6 @@ def get_JVMCIThreadsPerNativeLibraryRuntime(jdk):
611600
"""
612601
return _probe_jvmci_info(jdk, '.jvmciThreadsPerNativeLibraryRuntime')
613602

614-
def _probe_jlink_info(jdk, attribute_name):
615-
"""
616-
Determines if the jlink executable in `jdk` supports various options such
617-
as those added by JDK-8232080 and JDK-8237467.
618-
"""
619-
if not hasattr(jdk, '.supports_JDK_8232080'):
620-
output = mx.OutputCapture()
621-
jlink_exe = jdk.javac.replace('javac', 'jlink')
622-
mx.run([jlink_exe, '--list-plugins'], out=output)
623-
setattr(jdk, '.supports_JDK_8232080', '--add-options=' in output.data or '--add-options ' in output.data)
624-
setattr(jdk, '.supports_save_jlink_argfiles', '--save-jlink-argfiles=' in output.data or '--save-jlink-argfiles ' in output.data)
625-
setattr(jdk, '.supports_copy_files', '--copy-files=' in output.data or '--copy-files ' in output.data)
626-
return getattr(jdk, attribute_name)
627-
628-
def jlink_supports_8232080(jdk):
629-
"""
630-
Determines if the jlink executable in `jdk` supports ``--add-options`` and
631-
``--vendor-[bug-url|vm-bug-url|version]`` added by JDK-8232080.
632-
"""
633-
return _probe_jlink_info(jdk, '.supports_JDK_8232080')
634-
635-
def jlink_has_save_jlink_argfiles(jdk):
636-
"""
637-
Determines if the jlink executable in `jdk` supports ``--save-jlink-argfiles``.
638-
"""
639-
return _probe_jlink_info(jdk, '.supports_save_jlink_argfiles')
640-
641-
def _jdk_omits_warning_for_jlink_set_ThreadPriorityPolicy(jdk): # pylint: disable=invalid-name
642-
"""
643-
Determines if the `jdk` suppresses a warning about ThreadPriorityPolicy when it
644-
is non-zero if the value is set from the jimage.
645-
https://bugs.openjdk.java.net/browse/JDK-8235908.
646-
"""
647-
if not hasattr(jdk, '.omits_ThreadPriorityPolicy_warning'):
648-
out = mx.OutputCapture()
649-
sink = lambda x: x
650-
tmpdir = tempfile.mkdtemp(prefix='jdk_omits_warning_for_jlink_set_ThreadPriorityPolicy')
651-
jlink_exe = jdk.javac.replace('javac', 'jlink')
652-
mx.run([jlink_exe, '--add-options=-XX:ThreadPriorityPolicy=1', '--output=' + join(tmpdir, 'jdk'), '--add-modules=java.base'])
653-
mx.run([mx.exe_suffix(join(tmpdir, 'jdk', 'bin', 'java')), '-version'], out=sink, err=out)
654-
shutil.rmtree(tmpdir)
655-
setattr(jdk, '.omits_ThreadPriorityPolicy_warning', '-XX:ThreadPriorityPolicy=1 may require system level permission' not in out.data)
656-
return getattr(jdk, '.omits_ThreadPriorityPolicy_warning')
657-
658603
def _read_java_base_hashes(jdk):
659604
"""
660605
Read the hashes stored in the ``java.base`` module of `jdk`.
@@ -808,65 +753,56 @@ def _get_image_vm_options(jdk, use_upgrade_module_path, modules, synthetic_modul
808753
:return list: the list of VM options to cook into the image
809754
"""
810755
vm_options = []
811-
if jlink_supports_8232080(jdk):
812-
if mx.get_env('CONTINUOUS_INTEGRATION', None) == 'true':
813-
is_gate = mx.get_env('BUILD_TARGET', None) == 'gate'
814-
is_bench = 'bench-' in mx.get_env('BUILD_NAME', '')
815-
if is_gate or is_bench:
816-
# For gate and benchmark jobs, we want to know about each compilation failure
817-
# but only exit the VM on systemic compilation failure for gate jobs.
818-
vm_options.append('-Djdk.graal.CompilationFailureAction=Diagnose')
819-
mx.log('Adding -Djdk.graal.CompilationFailureAction=Diagnose VM option to image')
820-
if is_gate:
821-
mx.log('Adding -Djdk.graal.SystemicCompilationFailureRate=-1 VM option to image')
822-
vm_options.append('-Djdk.graal.SystemicCompilationFailureRate=-1')
823-
824-
if use_upgrade_module_path or _jdk_omits_warning_for_jlink_set_ThreadPriorityPolicy(jdk):
825-
vm_options.append('-XX:ThreadPriorityPolicy=1')
826-
else:
827-
mx.logv('[Creating JDK without -XX:ThreadPriorityPolicy=1]')
828-
829-
if jdk_supports_enablejvmciproduct(jdk):
830-
non_synthetic_modules = [m.name for m in modules if m not in synthetic_modules]
831-
if default_to_jvmci or 'jdk.graal.compiler' in non_synthetic_modules:
832-
threads = get_JVMCIThreadsPerNativeLibraryRuntime(jdk)
833-
vm_options.extend(['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCIProduct'])
834-
# -XX:+EnableJVMCI must be explicitly specified to the java launcher to add
835-
# jdk.internal.vm.ci to the root set (JDK-8345826)
836-
vm_options.append('-XX:+EnableJVMCI')
837-
if threads is not None and threads != 1:
838-
vm_options.append('-XX:JVMCIThreadsPerNativeLibraryRuntime=1')
839-
if default_to_jvmci == 'lib':
840-
vm_options.append('-XX:+UseJVMCINativeLibrary')
841-
vm_options.extend(['-XX:-UnlockExperimentalVMOptions'])
842-
import mx_sdk_vm_impl
843-
if 'jdk.graal.compiler' in non_synthetic_modules and mx_sdk_vm_impl._get_libgraal_component() is None:
844-
# If libgraal is absent, jargraal is used by default.
845-
# Use of jargraal requires exporting jdk.internal.misc to
846-
# Graal as it uses jdk.internal.misc.Unsafe. To avoid warnings
847-
# about unknown modules (e.g. in `-Xint` mode), the export target
848-
# modules must be explicitly added to the root set with `--add-modules`.
849-
if 'com.oracle.graal.graal_enterprise' in non_synthetic_modules:
850-
vm_options.extend([
851-
'--add-modules=jdk.graal.compiler,com.oracle.graal.graal_enterprise',
852-
'--add-exports=java.base/jdk.internal.misc=jdk.graal.compiler,com.oracle.graal.graal_enterprise'
853-
])
854-
else:
855-
vm_options.extend([
856-
'--add-modules=jdk.graal.compiler',
857-
'--add-exports=java.base/jdk.internal.misc=jdk.graal.compiler'
858-
])
756+
if mx.get_env('CONTINUOUS_INTEGRATION', None) == 'true':
757+
is_gate = mx.get_env('BUILD_TARGET', None) == 'gate'
758+
is_bench = 'bench-' in mx.get_env('BUILD_NAME', '')
759+
if is_gate or is_bench:
760+
# For gate and benchmark jobs, we want to know about each compilation failure
761+
# but only exit the VM on systemic compilation failure for gate jobs.
762+
vm_options.append('-Djdk.graal.CompilationFailureAction=Diagnose')
763+
mx.log('Adding -Djdk.graal.CompilationFailureAction=Diagnose VM option to image')
764+
if is_gate:
765+
mx.log('Adding -Djdk.graal.SystemicCompilationFailureRate=-1 VM option to image')
766+
vm_options.append('-Djdk.graal.SystemicCompilationFailureRate=-1')
767+
768+
vm_options.append('-XX:ThreadPriorityPolicy=1')
769+
770+
non_synthetic_modules = [m.name for m in modules if m not in synthetic_modules]
771+
if default_to_jvmci or 'jdk.graal.compiler' in non_synthetic_modules:
772+
threads = get_JVMCIThreadsPerNativeLibraryRuntime(jdk)
773+
vm_options.extend(['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCIProduct'])
774+
# -XX:+EnableJVMCI must be explicitly specified to the java launcher to add
775+
# jdk.internal.vm.ci to the root set (JDK-8345826)
776+
vm_options.append('-XX:+EnableJVMCI')
777+
if threads is not None and threads != 1:
778+
vm_options.append('-XX:JVMCIThreadsPerNativeLibraryRuntime=1')
779+
if default_to_jvmci == 'lib':
780+
vm_options.append('-XX:+UseJVMCINativeLibrary')
781+
vm_options.extend(['-XX:-UnlockExperimentalVMOptions'])
782+
import mx_sdk_vm_impl
783+
if 'jdk.graal.compiler' in non_synthetic_modules and mx_sdk_vm_impl._get_libgraal_component() is None:
784+
# If libgraal is absent, jargraal is used by default.
785+
# Use of jargraal requires exporting jdk.internal.misc to
786+
# Graal as it uses jdk.internal.misc.Unsafe. To avoid warnings
787+
# about unknown modules (e.g. in `-Xint` mode), the export target
788+
# modules must be explicitly added to the root set with `--add-modules`.
789+
if 'com.oracle.graal.graal_enterprise' in non_synthetic_modules:
790+
vm_options.extend([
791+
'--add-modules=jdk.graal.compiler,com.oracle.graal.graal_enterprise',
792+
'--add-exports=java.base/jdk.internal.misc=jdk.graal.compiler,com.oracle.graal.graal_enterprise'
793+
])
859794
else:
860-
# Don't default to using JVMCI as JIT unless Graal is being updated in the image.
861-
# This avoids unexpected issues with using the out-of-date Graal compiler in
862-
# the JDK itself.
863-
vm_options.extend(['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCIProduct', '-XX:-UseJVMCICompiler', '-XX:-UnlockExperimentalVMOptions'])
864-
else:
865-
mx.logv('[Creating JDK without -XX:+EnableJVMCIProduct]')
866-
if modules and use_upgrade_module_path:
867-
vm_options.append('--upgrade-module-path=' + os.pathsep.join((synthetic_modules.get(m, m.jarpath) for m in modules)))
868-
elif use_upgrade_module_path:
869-
mx.abort('Cannot create an image with an --upgrade-module-path setting since jlink does not support the --add-options flag')
795+
vm_options.extend([
796+
'--add-modules=jdk.graal.compiler',
797+
'--add-exports=java.base/jdk.internal.misc=jdk.graal.compiler'
798+
])
799+
else:
800+
# Don't default to using JVMCI as JIT unless Graal is being updated in the image.
801+
# This avoids unexpected issues with using the out-of-date Graal compiler in
802+
# the JDK itself.
803+
vm_options.extend(['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCIProduct', '-XX:-UseJVMCICompiler', '-XX:-UnlockExperimentalVMOptions'])
804+
if modules and use_upgrade_module_path:
805+
vm_options.append('--upgrade-module-path=' + os.pathsep.join((synthetic_modules.get(m, m.jarpath) for m in modules)))
870806
return vm_options
871807

872808
def _copy_src_zip(from_jdk, to_jdk, extra_modules, extra_modules_predicate):
@@ -967,9 +903,8 @@ def jlink_new_jdk(jdk, dst_jdk_dir, module_dists, ignore_dists,
967903
if not isdir(jmods_dir):
968904
mx.abort('Cannot derive a new JDK from ' + jdk.home + ' since ' + jmods_dir + ' is missing or is not a directory')
969905

970-
# Exclude jdk.aot due to GR-10545 and JDK-8255616
971906
# Exclude graal in case it is included in the base JDK
972-
jdk_modules = {jmd.name: jmd for jmd in jdk.get_modules() if jmd.name != 'jdk.aot' and not jmd.name.startswith('jdk.graal.compiler')}
907+
jdk_modules = {jmd.name: jmd for jmd in jdk.get_modules() if not jmd.name.startswith('jdk.graal.compiler')}
973908
modules = [as_java_module(dist, jdk) for dist in module_dists]
974909
module_names = frozenset((m.name for m in modules))
975910
all_module_names = frozenset(list(jdk_modules.keys())) | module_names
@@ -1118,7 +1053,7 @@ def get_jmod_path_with_specified_module_info(self, m):
11181053
jlink.append(f'--add-options={" ".join(vm_options)}')
11191054
jlink_persist.append(f'--add-options="{" ".join(vm_options)}"')
11201055

1121-
if jlink_supports_8232080(jdk) and vendor_info is not None:
1056+
if vendor_info is not None:
11221057
for name, value in vendor_info.items():
11231058
jlink.append(f'--{name}={value}')
11241059
jlink_persist.append(f'--{name}="{value}"')
@@ -1127,11 +1062,10 @@ def get_jmod_path_with_specified_module_info(self, m):
11271062
if isfile(release_file):
11281063
jlink.append(f'--release-info={release_file}')
11291064

1130-
if jlink_has_save_jlink_argfiles(jdk):
1131-
jlink_persist_argfile = join(build_dir, 'jlink.persist.options')
1132-
with open(jlink_persist_argfile, 'w') as fp:
1133-
fp.write('\n'.join(jlink_persist))
1134-
jlink.append(f'--save-jlink-argfiles={jlink_persist_argfile}')
1065+
jlink_persist_argfile = join(build_dir, 'jlink.persist.options')
1066+
with open(jlink_persist_argfile, 'w') as fp:
1067+
fp.write('\n'.join(jlink_persist))
1068+
jlink.append(f'--save-jlink-argfiles={jlink_persist_argfile}')
11351069

11361070
if exists(dst_jdk_dir):
11371071
if use_upgrade_module_path and _vm_options_match(vm_options, vm_options_path):

vm/mx.vm/mx_vm_gate.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,15 @@ def _test_libgraal_basic(extra_vm_arguments, libgraal_location):
139139
"""
140140

141141
graalvm_home = mx_sdk_vm_impl.graalvm_home()
142-
graalvm_jdk = mx.JDKConfig(graalvm_home)
143142
jres = [('GraalVM', graalvm_home, [])]
144143

145-
if mx_sdk_vm.jlink_has_save_jlink_argfiles(graalvm_jdk):
146-
# Create a minimal image that should contain libgraal
147-
libgraal_jre = abspath('libgraal-jre')
148-
if exists(libgraal_jre):
149-
mx.rmtree(libgraal_jre)
150-
mx.run([join(graalvm_home, 'bin', 'jlink'), f'--output={libgraal_jre}', '--add-modules=java.base'])
151-
jres.append(('LibGraal JRE', libgraal_jre, []))
152-
atexit.register(mx.rmtree, libgraal_jre)
144+
# Create a minimal image that should contain libgraal
145+
libgraal_jre = abspath('libgraal-jre')
146+
if exists(libgraal_jre):
147+
mx.rmtree(libgraal_jre)
148+
mx.run([join(graalvm_home, 'bin', 'jlink'), f'--output={libgraal_jre}', '--add-modules=java.base'])
149+
jres.append(('LibGraal JRE', libgraal_jre, []))
150+
atexit.register(mx.rmtree, libgraal_jre)
153151

154152
expect = r"Using compiler configuration '[^']+' \(\"[^\"]+\"\) provided by [\.\w]+ loaded from a[ \w]* Native Image shared library"
155153
compiler_log_file = abspath('graal-compiler.log')

0 commit comments

Comments
 (0)