JDK-8165723 : JarFile::isMultiRelease() method returns false when it should return true
  • Type: Bug
  • Component: core-libs
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-09-08
  • Updated: 2016-09-15
  • Resolved: 2016-09-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b136Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
The attached jar files have valid manifests:

multirelease-0.8-SNAPSHOT_failure.jar
-----------------------------------------------------
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.3.9
Built-By: scholterf
Build-Jdk: 9-ea
Multi-Release: true

multirelease-0.8-SNAPSHOT_success.jar
--------------------------------------------------------
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.4.0-SNAPSHOT
Built-By: scholterf
Build-Jdk: 9-ea
Multi-Release: true

Yet, JarFile thinks the "failure" jar does not have the "Multi-Release: true" attribute, demonstrated by

jshell> /op script
multirelease-0.8-SNAPSHOT_success.jar is multi-release? true
multirelease-0.8-SNAPSHOT_failure.jar is multi-release? false

jshell> /li

   1 : import java.util.jar.*;
   2 : File f = new File("multirelease-0.8-SNAPSHOT_success.jar");
   3 : JarFile jf = new JarFile(f, false, 1, JarFile.runtimeVersion());
   4 : System.out.println(f + " is multi-release? " + jf.isMultiRelease());
   5 : f = new File("multirelease-0.8-SNAPSHOT_failure.jar");
   6 : jf = new JarFile(f, false, 1, JarFile.runtimeVersion());
   7 : System.out.println(f + " is multi-release? " + jf.isMultiRelease());

Further investigation shows that JarFile::match returns -1 for the "failure" jar.

Comments
Caused by an erroneously constructed good suffix table after hand-implementing Boyer-Moore as part of JDK-8152733
10-09-2016

I believe the "good suffix table" optimization that applied to "class-path: true" fails for "multi-release: true": in this particular test, when it matches: "xxxxxxMulti-Release" with "Multi-Release: true" it matches the first e, fails on s and shifts 19 when it should actually shift j + 1 - bad_suffix_for('s') = 6. A proper good suffix table is required for matching "multi-release: true"
09-09-2016