Java 9+ multi-release jars are not supported in ant tasks

Bug #1808383 reported by Javier Armendariz
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
ant (Ubuntu)
Fix Released
Medium
Unassigned
Xenial
New
Medium
Unassigned
Bionic
Fix Released
Medium
Unassigned
Cosmic
Fix Released
Medium
Unassigned
Disco
Fix Released
Medium
Unassigned

Bug Description

Reproduced in release: Ubuntu 18.04.1 LTS
Version of ant used: 1.10.3-1ubuntu0.1

Having a multi-release jar with different .class files for Java 8 and Java 9, when using this jar in a custom ant task and running in Java 9+, the Java 8 class file will be loaded instead of the Java 9 one. This may lead to errors when the older class uses a deprecated/removed API.

This can be easily reproduced using the code pushed to this repository: https://github.com/katanagari7c1/ant-mrjar-support-test

This issue have already been reported in the ant bug tracker:
https://bz.apache.org/bugzilla/show_bug.cgi?id=62952

It has already been fixed and will be introduced in next release 1.10.6:
https://github.com/apache/ant/commit/593aff2d2ea52a025cfe7da32155216719029a7d

description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ant (Ubuntu):
status: New → Confirmed
Revision history for this message
Stefan Huehner (stefan-huehner) wrote :

Hello,
the next upstream release 1.10.6 did still not yet happen after some longer delay.
Last talked about end of January here:
https://mail-archives.apache.org/mod_mbox/ant-dev/201901.mbox/browser

After discussing on #debian-java with doko/tdaitx we propose to backport the single fix mentioned here to add the missing compatibility with openjdk11 to last packaged version.

Attached are 2 patches matching the 2 upstream commits to fix the issue:
https://gitbox.apache.org/repos/asf?p=ant.git;a=commit;h=593aff2d2ea52a025cfe7da32155216719029a7d
https://gitbox.apache.org/repos/asf?p=ant.git;a=commit;h=69269adced56238dc80297b9ae881442cd56259c

Note:
First patch is modified to remove the hunk to patch WHATSNEW file adding entry for this fix to 1.10.6 section. Remove as with the backport the whole entry for 1.10.6 is not present being applied as backport on top of 1.10.5

We consider the fix safe as:
1.) Created by upstream planned to be release in next upstream version
2.) Conceptually simple fix:
- Detection of Java9 at runtime
- if present use newer API from openjdk which implements the real logic
- if not use existing API as before
The Multi-release awareness itself for the jar-file is coming from Openjdk code (present there since java9)
3.) New feature functionally only modifies behavior when jar file is a 'multi-release jarfile' containing different byte-code targeting different Java versions at runtime.

We did the following tests:
a.) Based on current version in bionic-proposed: 1.10.5-2~18.04
b.) Quilt imported both patches and rebuilt ant packages.
c.) In pristine bionic having bionic-proposed (and dist-upgrade ran)

Using our application (3rd party not available in Ubuntu) having custom ant task using log4j2 (upstream multi-release jar file)

a.) Unpatched <=1.10.5 ant fails at runtime as it select java<=8 classfile version from jar imcompatible with openjdk11
- Patched 1.10.5 does work correctly without failing

b.) Testcase reported in this issue above works fine

c.) Run test-case upstream added along with the fix:
    ant/src/etc/testcases/core$ ant -f antclassloader.xml testMRJar

We repeated above tests using both openjdk-11 and openjdk-8 from bionic.

Revision history for this message
Stefan Huehner (stefan-huehner) wrote :
Mathew Hodson (mhodson)
tags: added: patch patch-accepted-upstream
Changed in ant (Ubuntu Xenial):
importance: Undecided → Medium
Changed in ant (Ubuntu Bionic):
importance: Undecided → Medium
Changed in ant (Ubuntu Cosmic):
importance: Undecided → Medium
Changed in ant (Ubuntu Disco):
importance: Undecided → Medium
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ant - 1.10.5-2ubuntu1

---------------
ant (1.10.5-2ubuntu1) disco; urgency=medium

  * Enable multi release jar support. (LP: #1808383)
    - debian/patches/0016-multirelease-jar-support.patch: apply 2 upstream
      patches to provide mrjar support.

 -- Tiago Stürmer Daitx <email address hidden> Thu, 14 Mar 2019 14:52:44 +0000

Changed in ant (Ubuntu Disco):
status: Confirmed → Fix Released
Changed in ant (Ubuntu Cosmic):
status: New → Fix Committed
Changed in ant (Ubuntu Bionic):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ant - 1.10.5-3~18.04

---------------
ant (1.10.5-3~18.04) bionic; urgency=medium

  * Backport for OpenJDK 11. LP: #1818647.

ant (1.10.5-3) unstable; urgency=medium

  [ Matthias Klose ]
  * Mark binary packages as M-A: foreign. Closes: #925467.
  * Bump standards version.

  [ Tiago Stürmer Daitx ]
  * Enable multi release jar support. LP: #1808383.
    - debian/patches/0016-multirelease-jar-support.patch: apply 2 upstream
      patches to provide mrjar support.

ant (1.10.5-2) unstable; urgency=medium

  * Team upload.
  * Lower the minimum required source/target level to 1.6 again.
    This is acceptable for OpenJDK 11 but must be reverted for OpenJDK 12.
    Thanks to Bdale Garbee for the report and patch. (Closes: #906785)
  * Declare compliance with Debian Policy 4.2.1.

ant (1.10.5-1) unstable; urgency=medium

  * Team upload.
  * New upstream release
  * Replaced debian/orig-tar.sh with the Files-Excluded mechanism
  * Standards-Version updated to 4.1.5

ant (1.10.4-2) unstable; urgency=medium

  * Team upload.
  * Reverted the modification setting the 'release' attribute automatically
    since this renders the internal JDK APIs unavailable at compile time.
    (Closes: #902895)

ant (1.10.4-1) unstable; urgency=medium

  * Team upload.
  * New upstream release
    - Refreshed the patches
    - Compile with hamcrest-all on the classpath

ant (1.10.3-2) unstable; urgency=medium

  * Team upload.
  * Automatically set the value of the javac --release attribute to improve
    the backward compatibility of the code compiled with Java 9 or later.
  * Standards-Version updated to 4.1.4
  * Use salsa.debian.org Vcs-* URLs

 -- Matthias Klose <email address hidden> Thu, 28 Mar 2019 11:13:28 +0100

Changed in ant (Ubuntu Bionic):
status: Fix Committed → Fix Released
Changed in ant (Ubuntu Cosmic):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.