Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECJ batch compiler only loads multi-release classes with exact --release match #2778

Open
Marcono1234 opened this issue Jul 30, 2024 · 0 comments
Labels
compiler Eclipse Java Compiler (ecj) related issues jpms

Comments

@Marcono1234
Copy link

This is a clone of https://bugs.eclipse.org/bugs/show_bug.cgi?id=577790, as suggested in #2773 (comment)

Version

ecj-3.38.0.jar from Maven Central

(and earlier versions, see Bugzilla report)

Description

Libraries which want to target Java 8 (respectively Android) as lowest version, but also want to provide a module descriptor commonly use multi-release JARs for this, e.g. META-INF/versions/9/module-info.class. This is also explicitly mentioned in the JAR specification:

A module descriptor may be present under a versioned area but not present under the top-level directory.

The problem is that the ECJ batch compiler when used with --release N only considers META-INF/versions/N, but not any directories < N of libraries in the module path.

This differs from javac behavior, from Java runtime behavior (as required by the JAR specification) and also from Eclipse JDT behavior within the IDE (that has a different problem though, see #2495).

This report here is only about --release; currently the ECJ batch compiler does not read multi-release classes at all when using -target, see #2774.

There was a pull request for this, but it has been abandoned: #61

Reproduction steps

  1. Download the attached multi-release-test.zip and unzip it
  2. Download ECJ, for example from https://search.maven.org/artifact/org.eclipse.jdt/ecj
  3. Run ECJ with --release 11
    java -jar ./ecj.jar --release 11 --module-path ./multi-release.jar ./module-info.java
    
    ❌ Bug: It cannot find the referenced module
  4. Run ECJ with --release 10 (which matches exactly the META-INF/versions/10 in the JAR)
    java -jar ./ecj.jar --release 10 --module-path ./multi-release.jar ./module-info.java
    
    ℹ️ As expected: Compilation succeeds
@Marcono1234 Marcono1234 changed the title ECJ batch compiler fails to recognize multi-release module on module-path ECJ batch compiler only loads multi-release classes with exact --release match Jul 30, 2024
@stephan-herrmann stephan-herrmann added compiler Eclipse Java Compiler (ecj) related issues jpms labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Eclipse Java Compiler (ecj) related issues jpms
Projects
None yet
Development

No branches or pull requests

2 participants