JDK-8062923 : XSL: Run-time internal error in 'substring()'
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 6u65,7u71,8,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-11-05
  • Updated: 2016-08-26
  • Resolved: 2015-01-26
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 6 JDK 7 JDK 8 JDK 9
6u101Fixed 7u80Fixed 8u45Fixed 9 b49Fixed
Related Reports
Relates :  
Relates :  
Description
If the substring function is used during the XSL transformation with negative length, i.e. <xsl:value-of select="substring('asdf',2,-1)/> then the following internal error is observed:
java.lang.RuntimeException: Run-time internal error in 'substring()' 
        at 
com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary.runTimeError(BasisLibrary.java:1527) 
        at 
com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary.runTimeError(BasisLibrary.java:1531) 
        at 
com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary.substringF(BasisLibrary.java:302) 
        at newbug1.template$dot$0() 
        at newbug1.applyTemplates() 
        at newbug1.transform() 
        at 
com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:605) 
        at 
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:734) 
        at 
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:345) 
        at tmp.xform(tmp.java:123) 
        at tmp.main(tmp.java:102)

But according to w3.org documentation the empty string should be returned:
http://www.w3.org/TR/xpath-functions/#func-substring
Comments
No issues with nightly 7u-CPU testing. SQE OK to take the fix to PSU15_02.
29-01-2015

Such incorrect processing of negative length values can cause similar issue when the length is -Inf (JDK-8062924): |<xsl:value-of select="substring('asdf',2,-1 div 0)"/>| For negative length values empty string "" should be returned.
18-11-2014