Skip to content

Commit

Permalink
[GR-57114] Checks that uses clauses in module info do not use binary …
Browse files Browse the repository at this point in the history
…class names.

PullRequest: mx/1824
  • Loading branch information
dougxc committed Aug 8, 2024
2 parents d11f31f + ba738a2 commit a53e024
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mx/_impl/mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18198,7 +18198,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.29.1") # GR-57159: Parse underscores inside .toml identifiers.
version = VersionSpec("7.29.2") # GR-57114: service names in module info must use non-binary class names

_mx_start_datetime = datetime.utcnow()

Expand Down
14 changes: 12 additions & 2 deletions src/mx/_impl/mx_javamodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,15 @@ def is_valid_module_name(name):
_versioned_re = re.compile(r'META-INF/_?versions/([1-9][0-9]*)/(.+)')
_javamodule_buildlevel = None

def _check_uses(uses, context):
"""
Checks that no class names in `uses` contain "$".
"""
for use in uses:
if "$" in use:
mx.abort(f"specification of service {use} must use non-binary name of nested class (i.e. replace '$' with '.')", context=context)
return uses

def make_java_module(dist, jdk, archive, javac_daemon=None, alt_module_info_name=None):
"""
Creates a Java module from a distribution.
Expand Down Expand Up @@ -739,7 +748,8 @@ def replicate(src, dst):
# override automatic qualifiers like transitive if they are explicitly specified in the module info
# this allows to customize the default behavior.
requires[name] = qualifiers
base_uses.update(module_info.get('uses', []))
base_uses.update(_check_uses(module_info.get('uses', []), dist))

_process_exports((alt_module_info or module_info).get('exports', []), module_packages)

opens = module_info.get('opens', {})
Expand All @@ -755,7 +765,7 @@ def replicate(src, dst):

with mx.Timer('projects', times):
for project in java_projects:
base_uses.update(getattr(project, 'uses', []))
base_uses.update(_check_uses(getattr(project, 'uses', []), project))
for m in getattr(project, 'runtimeDeps', []):
requires.setdefault(m, set()).add('static')

Expand Down

0 comments on commit a53e024

Please sign in to comment.