Skip to content

Commit e262358

Browse files
committed
[GR-60117] Enable build support for JEP 493 enabled base JDKs.
PullRequest: mx/1853
2 parents 2302f25 + 5f9b918 commit e262358

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed

common.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
1010
"jdks": {
11-
"galahad-jdk": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+22-2651", "platformspecific": true, "extrabundles": ["static-libs"]},
11+
"galahad-jdk": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+24-2950", "platformspecific": true, "extrabundles": ["static-libs"]},
1212

1313
"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.7", "build_id": "jdk-17.0.7+8", "platformspecific": true, "extrabundles": ["static-libs"]},
1414
"labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.1-b02", "platformspecific": true },
@@ -45,13 +45,13 @@
4545

4646
"oraclejdk23": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+37", "platformspecific": true, "extrabundles": ["static-libs"]},
4747

48-
"oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+22", "platformspecific": true, "extrabundles": ["static-libs"]},
49-
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+22-jvmci-b01", "platformspecific": true },
50-
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+22-jvmci-b01-debug", "platformspecific": true },
51-
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+22-jvmci-b01-sulong", "platformspecific": true },
52-
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+22-jvmci-b01", "platformspecific": true },
53-
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+22-jvmci-b01-debug", "platformspecific": true },
54-
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+22-jvmci-b01-sulong", "platformspecific": true }
48+
"oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+24", "platformspecific": true, "extrabundles": ["static-libs"]},
49+
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+24-jvmci-b01", "platformspecific": true },
50+
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+24-jvmci-b01-debug", "platformspecific": true },
51+
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+24-jvmci-b01-sulong", "platformspecific": true },
52+
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+24-jvmci-b01", "platformspecific": true },
53+
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+24-jvmci-b01-debug", "platformspecific": true },
54+
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+24-jvmci-b01-sulong", "platformspecific": true }
5555
},
5656

5757
"eclipse": {

src/mx/_impl/mx.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,9 @@ def __init__(self, parents=None):
849849
# TODO GR-49766 completely remove this line and usages of `mx_tests`
850850
# self.add_argument('--mx-tests', action='store_true', help='load mxtests suite (mx debugging)')
851851
self.add_argument('--jdk', action='store', help='JDK to use for the "java" command', metavar='<tag:compliance>')
852-
self.add_argument('--jmods-dir', action='store', help='path to built jmods (default JAVA_HOME/jmods)', metavar='<path>')
852+
self.add_argument('--jmods-dir', action='store', help="path to directory containing jmods which are added to --module-path when compiling "
853+
"module-info.java for a distribution's module. The default is JAVA_HOME/jmods. Specify NO_JMODS to indicate "
854+
"JAVA_HOME is a JEP 493-enabled JDK (i.e. has no jmods).", metavar='<path>')
853855
self.add_argument('--version-conflict-resolution', dest='version_conflict_resolution', action='store', help='resolution mechanism used when a suite is imported with different versions', default='suite', choices=['suite', 'none', 'latest', 'latest_all', 'ignore'])
854856
self.add_argument('-c', '--max-cpus', action='store', type=int, dest='cpu_count', help='the maximum number of cpus to use during build', metavar='<cpus>', default=None)
855857
self.add_argument('--proguard-cp', action='store', help='class path containing ProGuard jars to be used instead of default versions')
@@ -18222,7 +18224,7 @@ def alarm_handler(signum, frame):
1822218224
_CACHE_DIR = get_env('MX_CACHE_DIR', join(dot_mx_dir(), 'cache'))
1822318225

1822418226
# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
18225-
version = VersionSpec("7.35.0") # [GR-59726] Fix use of internal xml function changed in Python 3.13+
18227+
version = VersionSpec("7.35.1") # [GR-60117] Enable build support for JEP 493 enabled base JDKs
1822618228

1822718229
_mx_start_datetime = datetime.utcnow()
1822818230

src/mx/_impl/mx_jardistribution.py

+12
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def __init__(self, suite, name, subDir, path, sourcesPath, deps, mainClass, excl
9898
else:
9999
self._sources_path = '<uninitialized>'
100100

101+
self.module_info_compilation_participants = []
101102
self.archiveparticipants = []
102103
self.mainClass = mainClass
103104
self.javaCompliance = mx.JavaCompliance(javaCompliance) if javaCompliance else None
@@ -285,6 +286,17 @@ def set_archiveparticipant(self, archiveparticipant):
285286
def origin(self):
286287
return mx.Dependency.origin(self)
287288

289+
def add_module_info_compilation_participant(self, participant):
290+
"""
291+
Adds a callable that can add javac args when compiling ``module-info.java``
292+
for the Java module derived from this distribution.
293+
294+
:param participant: a callable that takes a JavaModuleDescriptor (describing this
295+
distribution's Java module) and returns a list of
296+
args to be added to javac when compiling ``module-info.java``
297+
"""
298+
self.module_info_compilation_participants.append(participant)
299+
288300
def classpath_repr(self, resolve=True):
289301
if resolve and not exists(self.path):
290302
if exists(self.original_path()):

src/mx/_impl/mx_javamodules.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -1085,14 +1085,18 @@ def safe_path_arg(p):
10851085
# The --system=none and --limit-modules options are used to support distribution defined modules
10861086
# that override non-upgradeable modules in the source JDK (e.g. org.graalvm.sdk is part of a
10871087
# GraalVM JDK). This means --module-path needs to contain the jmods for the JDK modules.
1088-
javac_args.append('--system=none')
1088+
use_jmods = not (mx.get_opts().jmods_dir and mx.get_opts().jmods_dir == 'NO_JMODS')
1089+
if use_jmods:
1090+
javac_args.append('--system=none')
10891091
if requires_clean:
10901092
javac_args.append('--limit-modules=' + ','.join(requires_clean.keys()))
10911093
jdk_jmods = (mx.get_opts().jmods_dir or join(jdk.home, 'jmods'))
1092-
if not exists(jdk_jmods):
1094+
if use_jmods and not exists(jdk_jmods):
10931095
mx.abort('Missing directory containing JMOD files: ' + jdk_jmods)
1094-
modulepath_jars.extend((join(jdk_jmods, m) for m in os.listdir(jdk_jmods) if m.endswith('.jmod')))
1095-
javac_args.append('--module-path=' + safe_path_arg(os.pathsep.join(modulepath_jars)))
1096+
if use_jmods:
1097+
modulepath_jars.extend((join(jdk_jmods, m) for m in os.listdir(jdk_jmods) if m.endswith('.jmod')))
1098+
if modulepath_jars:
1099+
javac_args.append('--module-path=' + safe_path_arg(os.pathsep.join(modulepath_jars)))
10961100

10971101
if concealedRequires:
10981102
for module, packages in concealedRequires.items():
@@ -1105,6 +1109,11 @@ def safe_path_arg(p):
11051109
# modules in qualified exports (not sure how to avoid these since we build modules
11061110
# separately).
11071111
javac_args.append('-Xlint:-options,-module')
1112+
1113+
# Apply module-info compilation participants
1114+
for part in dist.module_info_compilation_participants:
1115+
javac_args.extend(part(jmd))
1116+
11081117
javac_args.append(safe_path_arg(module_info_java))
11091118

11101119
# Convert javac args to @args file

0 commit comments

Comments
 (0)