JDK-8135069 : C2 replaces range checks by unsigned comparison with -1
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-09-04
  • Updated: 2015-11-09
  • Resolved: 2015-09-15
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 b84Fixed
Related Reports
Relates :  
Relates :  
Description
The range check optimization introduced by JDK-8073480 replaces checks of the form (i < 0 && i > length - 1) with an unsigned comparison of i and (length - 1). If length is 0, i is compared to -1 and the range check does *not* fail.

Applying the attached patch to TestBadFoldCompare.java reproduces the problem.
Comments
This showed up with the compact strings implementation in "java.lang.String.startsWith": Error with JDK 1.9.0-internal-20150827225921.sherman.sandbox-b00: <BEA-149205> <Failed to initialize the application "specj" due to error java.lang.ArrayIndexOutOfBoundsException: -1 java.lang.ArrayIndexOutOfBoundsException: -1 at java.lang.String.startsWith(String.java:1495) at java.lang.String.endsWith(String.java:1545) at java.util.zip.ZipEntry.isDirectory(ZipEntry.java:646) at weblogic.servlet.internal.WarSource.isDirectory(WarSource.java:202) at weblogic.servlet.internal.WarSource.<init>(WarSource.java:48) at weblogic.servlet.internal.War$ResourceFinder.getSources(War.java:735) at weblogic.servlet.internal.WebBaseModuleExtensionContext.getSources(WebBaseModuleExtensionContext.java:39) at com.oracle.injection.integration.CDIUtils.addSources(CDIUtils.java:446)
04-09-2015