ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [Bug 62952] AntClassLoader is not multi-release JAR aware
Date Wed, 05 Dec 2018 11:38:32 GMT

--- Comment #1 from Jaikiran Pai <> ---
Hello Javier,

It's true that AntClassLoader currently out of the box doesn't support
multi-release jar files. The java.util.jar.JarFile documentation[1] has an
interesting and useful information which states:

Implementation Note:
    If the API can not be used to configure a JarFile (e.g. to override the
configuration of a compiled application or library), two System properties are

        jdk.util.jar.version can be assigned a value that is the String
representation of a non-negative integer <= Runtime.version().major(). The
value is used to set the effective runtime version to something other than the
default value obtained by evaluating Runtime.version().major(). The effective
runtime version is the version that the JarFile(File, boolean, int,
Runtime.Version) constructor uses when the value of the last argument is
        jdk.util.jar.enableMultiRelease can be assigned one of the three String
values true, false, or force. The value true, the default value, enables
multi-release jar file processing. The value false disables multi-release jar
processing, ignoring the "Multi-Release" manifest attribute, and the versioned
directories in a multi-release jar file if they exist. Furthermore, the method
isMultiRelease() returns false. The value force causes the JarFile to be
initialized to runtime versioning after construction. It effectively does the
same as this code: (new JarFile(File, boolean, int, JarFile.runtimeVersion()).


So I set up the 'jdk.util.jar.enableMultiRelease' system property to 'force'
through ANT_OPTS as follows:

export ANT_OPTS="-Djdk.util.jar.enableMultiRelease=force"

and ran your example:

ant -f ant-test.xml

on a Java 9 setup and it worked fine and used the Java 9 version of the task.
Here's the snippet from the output:

 [testTask] Executing Java9+ Task. MRJAR is supported!
     [echo] ========================================
     [echo] Now using the same jar in a jvm process
     [echo] ========================================
     [java] Executing Java9+ Task. MRJAR is supported!

Having said that, we can certainly make AntClassLoader support multi-release
jar file out of the box and I'll go ahead and commit a change for that so it's
available in the next release.


You are receiving this mail because:
You are the assignee for the bug.
View raw message