-
CSR
-
Resolution: Unresolved
-
P4
-
None
-
low
-
SE
Summary
Move the encoded length validation for java.lang.classfile.constantpool.Utf8Entry
to when they are being constructed, instead of when they are written to class
files.
Problem
java.lang.classfile.constantpool.Utf8Entry
can be constructed with oversized String
instances that cannot be encoded in the class
file format. Such errors are reported only when class
files are written, which allows invalid instances to float around in the runtime, which makes such failures hard to track.
Solution
Reject oversized String
s used to construct Utf8Entry
, so they now fail immediately with an IllegalArgumentException
. This makes invalid constant nominal descriptors rejected too.
Specification
No specification change proposed for now. This affects the whole ClassFile API, but might be covered in the "Consistency checks, syntax checks and verification" section, which specifies fatal exceptions are thrown as IAE. However, some models can be constructed without being written.
Possible specification changes include:
- Documenting every affected API. This is way too massive and applies to collections of strings, nominal descriptors, and many other sites. 2.
- csr of
-
JDK-8367585 Move Utf8Entry length validation earlier
-
- Open
-