Skip to content

Commit

Permalink
[GR-58951] Do not automatically export imported JVMCI packages.
Browse files Browse the repository at this point in the history
PullRequest: mx/1843
  • Loading branch information
dougxc committed Oct 10, 2024
2 parents 0823db9 + 2f4cbe6 commit 1653fa4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/mx/_impl/mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7042,11 +7042,22 @@ def visit(dep, edge):

parse_requiresConcealed_attribute(jdk, getattr(self, 'requiresConcealed', None), concealed, None, self)

# JVMCI is special as it not concealed in JDK 8 but is concealed in JDK 9+.
compat = self.suite.getMxCompatibility()
if 'jdk.internal.vm.ci' in (jmd.name for jmd in jdk.get_modules()) and self.get_declaring_module_name() != 'jdk.internal.vm.ci':
jvmci_packages = [p for p in self.imported_java_packages(projectDepsOnly=False) if p.startswith('jdk.vm.ci')]
if jvmci_packages:
concealed.setdefault('jdk.internal.vm.ci', set()).update(jvmci_packages)
concealed_packages = concealed.setdefault('jdk.internal.vm.ci', set())
missing = frozenset(jvmci_packages).difference(concealed_packages)
if missing:
if compat.automatically_export_jvmci_packages():
concealed_packages.update(missing)
else:
nl = os.linesep
msg = f'As of mx {compat.version()}, JVMCI packages are not automatically exported to projects that import them. ' \
f'Instead projects must use a "requiresConcealed" attribute:{nl}{nl}'
packages = '", "'.join(sorted(missing))
msg += f' "requiresConcealed" : {{ "jdk.internal.vm.ci": ["{packages}"] }}'
self.abort(msg)

concealed = {module : list(concealed[module]) for module in concealed}
setattr(self, cache, concealed)
Expand Down Expand Up @@ -18204,7 +18215,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.32.4") # [GR-58295] Ignore commit info for foreign suites in mx benchmarks
version = VersionSpec("7.33.0") # [GR-58951] Do not automatically export JVMCI packages

_mx_start_datetime = datetime.utcnow()

Expand Down
18 changes: 17 additions & 1 deletion src/mx/_impl/mx_compat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# ----------------------------------------------------------------------------------------------------
#
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 2024, 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
Expand Down Expand Up @@ -307,6 +307,13 @@ def get_supported_hash_algorithms(self):
"""
return None

def automatically_export_jvmci_packages(self):
"""
JVMCI packages seen in import statements of a project's Java sources
will automatically result in an --add-exports option being added to the
javac command line for the project.
"""
return True

class MxCompatibility520(MxCompatibility500):
@staticmethod
Expand Down Expand Up @@ -794,6 +801,15 @@ def proguard_libs(self):
'RETRACE': '7_5_0',
}

class MxCompatibility733(MxCompatibility728):

@staticmethod
def version():
return mx.VersionSpec("7.33.0")

def automatically_export_jvmci_packages(self):
return False

def minVersion():
_ensureCompatLoaded()
return list(_versionsMap)[0]
Expand Down

0 comments on commit 1653fa4

Please sign in to comment.