Skip to content

The JDK 9 module system support for the Javac Task - #16

Closed
tzezula wants to merge 3 commits into
apache:masterfrom
tzezula:jigsaw/javac
Closed

The JDK 9 module system support for the Javac Task#16
tzezula wants to merge 3 commits into
apache:masterfrom
tzezula:jigsaw/javac

Conversation

@tzezula

@tzezula tzezula commented Mar 11, 2016

Copy link
Copy Markdown
Contributor

Added a support for jigsaw modulepath, upgrademodulepath and modulesourcepath to Javac task. Both single module and multi module compilation is supported.

@asfgit asfgit closed this in edca1db Mar 21, 2016
@bodewig

bodewig commented Mar 21, 2016

Copy link
Copy Markdown
Member

This looks a bit more complex than I would have naively expected, I've probably been underestimating the impact of modules.

Many thanks!

@tzezula

tzezula commented Mar 21, 2016

Copy link
Copy Markdown
Contributor Author

Yes. Unfortunately the javac -modulesourcepath option for the multi module compilation is more complex than existing path arguments. It's described in JEP 261: Module System. The important part is:

In large systems the source code for a particular module may be spread across several different directories. In the JDK itself, e.g., the source files for a module may be found in any one of the directories src//share/classes, src///classes, or build/gensrc/, where is the name of the target operating system. To express this in a module source path while preserving module identities we allow each element of such a path to use braces ({ and }) to enclose commas-separated lists of alternatives and a single asterisk ( * ) to stand for the module name. The module source path for the JDK can then be written as
{src//{share,}/classes,build/gensrc/}

In simple words the javac -modulesourcepath {src/*/{share,<os>}/classes,build/gensrc/*} -d build means that modules will be searched in the src or build/gensrc folders. The java sources of the modules located in the src are in folders share/classes or <os>/classes (relative to module). The java sources of the modules located in build/gensrc are directly in module folder. The path before the * in the path element is a path to module and the path after the * is a path in the module to the actual source root.
During the multi module compilation the javac creates module directories in the build folder containing the module classes.
The Ant Javac task needs to interpret the sourcepath elements to find all modules and their java files to do the up to date check.

For example in a project structure:

src/java.base/share/classes/
src/java.logging/share/classes/
build/java.base/
build/java.logging/

and javac options -modulesourcepath src/*/{share,<os>}/classes -d build the modules are java.base and java.logging. The java.base module has sources in the src/java.base/share/classes/ and is compiled into the build/java.base/ folder. The java.logging module has sources in the src/java.logging/share/classes/ and is compiled into the build/java.logging/ folder. The Ant Javac task needs to do up to date check of sources in src/java.base/share/classes/ (src/java.logging/share/classes/) with classes in build/java.base/ (build/java.logging/).

@bodewig

bodewig commented Mar 23, 2016

Copy link
Copy Markdown
Member

Many thanks for the explanation.

javac.checkParameters();
fail("Build exception should have been thrown - neither srcDir nor modulesourcepath");
} catch (BuildException e) {
//pass

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use @Test(expected = BuildException.class) instead of useless try/catch.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I didn't know this.

jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Apr 18, 2016
Changes from Ant 1.9.6 TO Ant 1.9.7
===================================

Changes that could break older environments:
-------------------------------------------

 * <exec> and <apply> used to ignore the dir attribute if it was the
   same as the current working directory.  They now no longer do,
   which changes the behavior for vmlauncher="false" which would have
   used the project's basedir rather than the current working
   directory in that case.
   Bugzilla Report 58555

Fixed bugs:
-----------

 * ZipOutputStream could cause an ArrayIndexOutOfBoundsException when
   adding entries with comments.  This never happens when using Ant as
   a build tool but may affect users using Ant's zip package as a
   library.

 * <gunzip> and <bunzip2> didn't work for non-filesystem resources.

 * <jar> ignored the zip64Mode attribute when creating manifest-only
   jars.  This resulted in jar files that couldn't be read by Java5.
   Bugzilla Report 58428

 * <untar> will now detect GNU tar longname/link records even if they
   don't use the names used by GNU tar itself.  star is known to
   create archives of that kind.
   https://issues.apache.org/jira/browse/COMPRESS-324

 * <script> could fail to find javax.script on JDK9 with Jigsaw.
   Bugzilla Report 58271

 * <import> sometimes failed to normalize file names which could lead
   to files getting imported twice which in turn could lead to targets
   getting executed twice.
   Bugzilla Report 58886

 * TarInputStream now properly extraxt directory entries with a
   non-zero size.

 * <union> would drop file resources pointing to the same file but
   using different names.
   Bugzilla Report 57965

 * <replace>'s result was undefined when using the replacefilterfile
   attribute and some keys inside the properties files have been
   substrings of other keys. Keys are now sorted by descending size.
   Bugzilla Report 58997

 * Ant fails to run when arguments contain double-quote character.
   Bugzilla Report 58898

 * Ant fails to run if ANT_HOME contains a double-quote character.
   Bugzilla Report 58874

 * Definer's way to parse URLs from classloader breaks with
   recent Java 9 builds (b108).
   Bugzilla Report 59130

 * <ant> and <antcall> now preserve the ext status set by an <exit>
   task.
   Bugzilla Report 59228

Other changes:
--------------

 * <scp> now supports (filesystem-only) resource collections in
   addition to filesets.
   Bugzilla Report 50769

 * The <http> condition has a new optional attribute followRedirects.
   Bugzilla Report 58840

 * <java> now supports Java9 modules.
   apache/ant#15

 * <javac> now supports Java9 modules.
   apache/ant#16

 * <sshexec> and <scp> have two new attributes serverAliveInterval and
   serverAliveCountMax that can be used to keep a intermediaries from
   closing idle connections.
   Bugzilla Report 59162
msk pushed a commit to msk/pkgsrc that referenced this pull request May 11, 2026
Changes from Ant 1.9.6 TO Ant 1.9.7
===================================

Changes that could break older environments:
-------------------------------------------

 * <exec> and <apply> used to ignore the dir attribute if it was the
   same as the current working directory.  They now no longer do,
   which changes the behavior for vmlauncher="false" which would have
   used the project's basedir rather than the current working
   directory in that case.
   Bugzilla Report 58555

Fixed bugs:
-----------

 * ZipOutputStream could cause an ArrayIndexOutOfBoundsException when
   adding entries with comments.  This never happens when using Ant as
   a build tool but may affect users using Ant's zip package as a
   library.

 * <gunzip> and <bunzip2> didn't work for non-filesystem resources.

 * <jar> ignored the zip64Mode attribute when creating manifest-only
   jars.  This resulted in jar files that couldn't be read by Java5.
   Bugzilla Report 58428

 * <untar> will now detect GNU tar longname/link records even if they
   don't use the names used by GNU tar itself.  star is known to
   create archives of that kind.
   https://issues.apache.org/jira/browse/COMPRESS-324

 * <script> could fail to find javax.script on JDK9 with Jigsaw.
   Bugzilla Report 58271

 * <import> sometimes failed to normalize file names which could lead
   to files getting imported twice which in turn could lead to targets
   getting executed twice.
   Bugzilla Report 58886

 * TarInputStream now properly extraxt directory entries with a
   non-zero size.

 * <union> would drop file resources pointing to the same file but
   using different names.
   Bugzilla Report 57965

 * <replace>'s result was undefined when using the replacefilterfile
   attribute and some keys inside the properties files have been
   substrings of other keys. Keys are now sorted by descending size.
   Bugzilla Report 58997

 * Ant fails to run when arguments contain double-quote character.
   Bugzilla Report 58898

 * Ant fails to run if ANT_HOME contains a double-quote character.
   Bugzilla Report 58874

 * Definer's way to parse URLs from classloader breaks with
   recent Java 9 builds (b108).
   Bugzilla Report 59130

 * <ant> and <antcall> now preserve the ext status set by an <exit>
   task.
   Bugzilla Report 59228

Other changes:
--------------

 * <scp> now supports (filesystem-only) resource collections in
   addition to filesets.
   Bugzilla Report 50769

 * The <http> condition has a new optional attribute followRedirects.
   Bugzilla Report 58840

 * <java> now supports Java9 modules.
   apache/ant#15

 * <javac> now supports Java9 modules.
   apache/ant#16

 * <sshexec> and <scp> have two new attributes serverAliveInterval and
   serverAliveCountMax that can be used to keep a intermediaries from
   closing idle connections.
   Bugzilla Report 59162
jperkin pushed a commit to TritonDataCenter/pkgsrc that referenced this pull request May 14, 2026
Changes from Ant 1.9.6 TO Ant 1.9.7
===================================

Changes that could break older environments:
-------------------------------------------

 * <exec> and <apply> used to ignore the dir attribute if it was the
   same as the current working directory.  They now no longer do,
   which changes the behavior for vmlauncher="false" which would have
   used the project's basedir rather than the current working
   directory in that case.
   Bugzilla Report 58555

Fixed bugs:
-----------

 * ZipOutputStream could cause an ArrayIndexOutOfBoundsException when
   adding entries with comments.  This never happens when using Ant as
   a build tool but may affect users using Ant's zip package as a
   library.

 * <gunzip> and <bunzip2> didn't work for non-filesystem resources.

 * <jar> ignored the zip64Mode attribute when creating manifest-only
   jars.  This resulted in jar files that couldn't be read by Java5.
   Bugzilla Report 58428

 * <untar> will now detect GNU tar longname/link records even if they
   don't use the names used by GNU tar itself.  star is known to
   create archives of that kind.
   https://issues.apache.org/jira/browse/COMPRESS-324

 * <script> could fail to find javax.script on JDK9 with Jigsaw.
   Bugzilla Report 58271

 * <import> sometimes failed to normalize file names which could lead
   to files getting imported twice which in turn could lead to targets
   getting executed twice.
   Bugzilla Report 58886

 * TarInputStream now properly extraxt directory entries with a
   non-zero size.

 * <union> would drop file resources pointing to the same file but
   using different names.
   Bugzilla Report 57965

 * <replace>'s result was undefined when using the replacefilterfile
   attribute and some keys inside the properties files have been
   substrings of other keys. Keys are now sorted by descending size.
   Bugzilla Report 58997

 * Ant fails to run when arguments contain double-quote character.
   Bugzilla Report 58898

 * Ant fails to run if ANT_HOME contains a double-quote character.
   Bugzilla Report 58874

 * Definer's way to parse URLs from classloader breaks with
   recent Java 9 builds (b108).
   Bugzilla Report 59130

 * <ant> and <antcall> now preserve the ext status set by an <exit>
   task.
   Bugzilla Report 59228

Other changes:
--------------

 * <scp> now supports (filesystem-only) resource collections in
   addition to filesets.
   Bugzilla Report 50769

 * The <http> condition has a new optional attribute followRedirects.
   Bugzilla Report 58840

 * <java> now supports Java9 modules.
   apache/ant#15

 * <javac> now supports Java9 modules.
   apache/ant#16

 * <sshexec> and <scp> have two new attributes serverAliveInterval and
   serverAliveCountMax that can be used to keep a intermediaries from
   closing idle connections.
   Bugzilla Report 59162
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants