Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[MCOMPILER-462] Modular Multi-Release JAR and Maven-Bundle-Plugin together cause inconsistent compilation behavior

Open
#680 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java

Research direction

Start with the attached ModularMRJAR reproducer, especially its pom and the compile-java11 execution. Run the three listed package commands with -X and compare the classpath, modulepath, and compiler options between incremental and clean builds. Done means the second and third runs compile identically when a new class is added.

Written by the indexing model from the issue text.

Description

bug priority:major

Anand Beh opened MCOMPILER-462 and commented

Building a project with a module descriptor placed in a multi-release directory, and in conjunction with the maven-bundle-plugin, creates discrepancies between "clean package" and "package" after changes have been made to the source tree.

This is best explained by reproducing the issue.

Reproducer

Attached to this issue. Also clonable from https://github.com/A248/ModularMRJAR

Steps to reproduce

  1. Download the attached reproducer
  2. First Run: Run mvn package
  3. Add a new class, e.g. "Clazz2" in src/main/java/org/mrjar
  4. Second Run: Run mvn package
  5. Third Run: Run mvn clean package

The Second Run can be repeated any number of times. It will consistently fail with the reason that the org.mrjar package is not found.

Results

 

  • First Run - compilation success
  • Second Run - failure
  • Third Run - success

The Third Run and the Second Run should compile identically.

Analysis

The difference between the second run and the third run is visible using the -X option.

The trouble happens when compiling the MR classes - i.e., the compile-java11 execution defined in the reproducer's pom.

On the second run, the non-MR classes are placed on the modulepath. The MR classes fail to compile:

[DEBUG] Classpath:
[DEBUG] Modulepath:
[DEBUG] /Users/anandbeh/git/ModularMRJAR/target/classes
[DEBUG] Source roots:
[DEBUG] /Users/anandbeh/git/ModularMRJAR/src/main/java11
[DEBUG] Command line options:
[DEBUG] -d /Users/anandbeh/git/ModularMRJAR/target/classes/META-INF/versions/11 --module-path /Users/anandbeh/git/ModularMRJAR/target/classes: -sourcepath /Users/anandbeh/git/ModularMRJAR/src/main/java11:/Users/anandbeh/git/ModularMRJAR/target/generated-sources/annotations: -s /Users/anandbeh/git/ModularMRJAR/target/generated-sources/annotations -g -nowarn --release 11 -encoding UTF-8 --module-version 0.1.0-SNAPSHOT

On the third run, the non-MR classes are placed on the classpath. The MR classes compile. It is further notable that the compiler command line options differ:

 

[DEBUG] Classpath:
[DEBUG]  /Users/anandbeh/git/ModularMRJAR/target/classes
[DEBUG] Source roots:
[DEBUG]  /Users/anandbeh/git/ModularMRJAR/src/main/java11
[DEBUG] Command line options:
[DEBUG] -d /Users/anandbeh/git/ModularMRJAR/target/classes/META-INF/versions/11 -classpath /Users/anandbeh/git/ModularMRJAR/target/classes: -sourcepath /Users/anandbeh/git/ModularMRJAR/src/main/java11:/Users/anandbeh/git/ModularMRJAR/target/generated-sources/annotations: -s /Users/anandbeh/git/ModularMRJAR/target/generated-sources/annotations -g -nowarn --release 11 -encoding UTF-8 --patch-module org.mrjar=/Users/anandbeh/git/ModularMRJAR/target/classes --module-version 0.1.0-SNAPSHOT

 
How to Resolve / Lesson from when not using the maven-bundle-plugin

If the maven-bundle-plugin were to NOT be used, then:

  1. The Second Run would succeed.
  2. The non-MR classes are placed on the class-path consistently.

This suggests the behavior of the Second Run in placing the non-MR classes on the module-path is incorrect. The Second Run should place the non-MR classes on the class-path just like the Third Run does.


Affects: 3.8.1

Attachments:

Dominant language
Java
Stars
261
Forks
194
Avg merge
1d 5h
Merged PRs (30d)
17

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/maven-compiler-plugin

All issues in apache/maven-compiler-plugin

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.