ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 62952] AntClassLoader is not multi-release JAR aware
Date Wed, 05 Dec 2018 11:38:32 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=62952

--- Comment #1 from Jaikiran Pai <jaikiran@apache.org> ---
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:

<quote>
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
available.

        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
JarFile.runtimeVersion().
        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()).



</quote>


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:

run.task:
 [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.

[1] https://docs.oracle.com/javase/9/docs/api/java/util/jar/JarFile.html

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