-
Bug
-
Resolution: Fixed
-
P4
-
22
-
b04
-
Verified
The class signature parsing code can fail with an unexpected error on invalid input:
jshell> ClassSignature.parseFrom("Ljava/lang/Object;Ljava/lang/Iterable<LFoo;>")
| Exception java.lang.StringIndexOutOfBoundsException: String index out of range: 44
| at StringLatin1.charAt (StringLatin1.java:48)
| at String.charAt (String.java:1517)
| at SignaturesImpl.referenceTypeSig (SignaturesImpl.java:137)
| at SignaturesImpl.parseClassSignature (SignaturesImpl.java:53)
| at ClassSignature.parseFrom (ClassSignature.java:84)
| at (#4:1)
I would expect that this method be specified to throw a specific exception on parse failure, and for the underlying code to then be consistent with that specification.
This was reported by a user using my downstream backport of this API to Java 17: https://github.com/dmlloyd/jdk-classfile-preview/issues/15 and also relates toJDK-8320360.
jshell> ClassSignature.parseFrom("Ljava/lang/Object;Ljava/lang/Iterable<LFoo;>")
| Exception java.lang.StringIndexOutOfBoundsException: String index out of range: 44
| at StringLatin1.charAt (StringLatin1.java:48)
| at String.charAt (String.java:1517)
| at SignaturesImpl.referenceTypeSig (SignaturesImpl.java:137)
| at SignaturesImpl.parseClassSignature (SignaturesImpl.java:53)
| at ClassSignature.parseFrom (ClassSignature.java:84)
| at (#4:1)
I would expect that this method be specified to throw a specific exception on parse failure, and for the underlying code to then be consistent with that specification.
This was reported by a user using my downstream backport of this API to Java 17: https://github.com/dmlloyd/jdk-classfile-preview/issues/15 and also relates to
- relates to
-
JDK-8320360 ClassFile.parse: Some defect class files cause unexpected exceptions to be thrown
-
- Closed
-