Skip to content

Commit

Permalink
[GR-60117] Enable build support for JEP 493 enabled base JDKs.
Browse files Browse the repository at this point in the history
PullRequest: mx/1853
  • Loading branch information
dougxc committed Nov 27, 2024
2 parents 2302f25 + 5f9b918 commit e262358
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
16 changes: 8 additions & 8 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

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

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

"oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+22", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+22-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+22-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+22-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+22-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+22-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+22-jvmci-b01-sulong", "platformspecific": true }
"oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+24", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+24-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+24-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+24-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+24-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+24-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+24-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
6 changes: 4 additions & 2 deletions src/mx/_impl/mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,9 @@ def __init__(self, parents=None):
# TODO GR-49766 completely remove this line and usages of `mx_tests`
# self.add_argument('--mx-tests', action='store_true', help='load mxtests suite (mx debugging)')
self.add_argument('--jdk', action='store', help='JDK to use for the "java" command', metavar='<tag:compliance>')
self.add_argument('--jmods-dir', action='store', help='path to built jmods (default JAVA_HOME/jmods)', metavar='<path>')
self.add_argument('--jmods-dir', action='store', help="path to directory containing jmods which are added to --module-path when compiling "
"module-info.java for a distribution's module. The default is JAVA_HOME/jmods. Specify NO_JMODS to indicate "
"JAVA_HOME is a JEP 493-enabled JDK (i.e. has no jmods).", metavar='<path>')
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'])
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)
self.add_argument('--proguard-cp', action='store', help='class path containing ProGuard jars to be used instead of default versions')
Expand Down Expand Up @@ -18222,7 +18224,7 @@ def alarm_handler(signum, frame):
_CACHE_DIR = get_env('MX_CACHE_DIR', join(dot_mx_dir(), 'cache'))

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

_mx_start_datetime = datetime.utcnow()

Expand Down
12 changes: 12 additions & 0 deletions src/mx/_impl/mx_jardistribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def __init__(self, suite, name, subDir, path, sourcesPath, deps, mainClass, excl
else:
self._sources_path = '<uninitialized>'

self.module_info_compilation_participants = []
self.archiveparticipants = []
self.mainClass = mainClass
self.javaCompliance = mx.JavaCompliance(javaCompliance) if javaCompliance else None
Expand Down Expand Up @@ -285,6 +286,17 @@ def set_archiveparticipant(self, archiveparticipant):
def origin(self):
return mx.Dependency.origin(self)

def add_module_info_compilation_participant(self, participant):
"""
Adds a callable that can add javac args when compiling ``module-info.java``
for the Java module derived from this distribution.
:param participant: a callable that takes a JavaModuleDescriptor (describing this
distribution's Java module) and returns a list of
args to be added to javac when compiling ``module-info.java``
"""
self.module_info_compilation_participants.append(participant)

def classpath_repr(self, resolve=True):
if resolve and not exists(self.path):
if exists(self.original_path()):
Expand Down
17 changes: 13 additions & 4 deletions src/mx/_impl/mx_javamodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,14 +1085,18 @@ def safe_path_arg(p):
# The --system=none and --limit-modules options are used to support distribution defined modules
# that override non-upgradeable modules in the source JDK (e.g. org.graalvm.sdk is part of a
# GraalVM JDK). This means --module-path needs to contain the jmods for the JDK modules.
javac_args.append('--system=none')
use_jmods = not (mx.get_opts().jmods_dir and mx.get_opts().jmods_dir == 'NO_JMODS')
if use_jmods:
javac_args.append('--system=none')
if requires_clean:
javac_args.append('--limit-modules=' + ','.join(requires_clean.keys()))
jdk_jmods = (mx.get_opts().jmods_dir or join(jdk.home, 'jmods'))
if not exists(jdk_jmods):
if use_jmods and not exists(jdk_jmods):
mx.abort('Missing directory containing JMOD files: ' + jdk_jmods)
modulepath_jars.extend((join(jdk_jmods, m) for m in os.listdir(jdk_jmods) if m.endswith('.jmod')))
javac_args.append('--module-path=' + safe_path_arg(os.pathsep.join(modulepath_jars)))
if use_jmods:
modulepath_jars.extend((join(jdk_jmods, m) for m in os.listdir(jdk_jmods) if m.endswith('.jmod')))
if modulepath_jars:
javac_args.append('--module-path=' + safe_path_arg(os.pathsep.join(modulepath_jars)))

if concealedRequires:
for module, packages in concealedRequires.items():
Expand All @@ -1105,6 +1109,11 @@ def safe_path_arg(p):
# modules in qualified exports (not sure how to avoid these since we build modules
# separately).
javac_args.append('-Xlint:-options,-module')

# Apply module-info compilation participants
for part in dist.module_info_compilation_participants:
javac_args.extend(part(jmd))

javac_args.append(safe_path_arg(module_info_java))

# Convert javac args to @args file
Expand Down

0 comments on commit e262358

Please sign in to comment.