CSR :
|
|
Relates :
|
|
Relates :
|
Summary ------- Represent the `superclass` and `superinterfaces` in `ClassTypeSig` with `ClassTypeSig` and `List<ClassTypeSig>`. Problem ------- In JVMS 4.7.9.1, the superclass and superinterfaces of a class signature is required to be class signatures. Yet Class-File API uses a `RefTypeSig`, allowing potentially invalid signatures, like using an array class as a superclass. Solution -------- Change the `superclass` and `superinterfaces` in `ClassTypeSig` from `RefTypeSig` and `List<RefTypeSig>` to `ClassTypeSig` and `List<ClassTypeSig>`. Specification ------------- --- a/src/java.base/share/classes/java/lang/classfile/ClassSignature.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassSignature.java @@ -42,10 +42,10 @@ public sealed interface ClassSignature List<Signature.TypeParam> typeParameters(); /** {@return the instantiation of the superclass in this signature} */ - Signature.RefTypeSig superclassSignature(); + Signature.ClassTypeSig superclassSignature(); /** {@return the instantiation of the interfaces in this signature} */ - List<Signature.RefTypeSig> superinterfaceSignatures(); + List<Signature.ClassTypeSig> superinterfaceSignatures(); /** {@return the raw signature string} */ String signatureString(); @@ -55,8 +55,8 @@ public sealed interface ClassSignature * @param superclassSignature the superclass * @param superinterfaceSignatures the interfaces */ - public static ClassSignature of(Signature.RefTypeSig superclassSignature, - Signature.RefTypeSig... superinterfaceSignatures) { + public static ClassSignature of(Signature.ClassTypeSig superclassSignature, + Signature.ClassTypeSig... superinterfaceSignatures) { return of(List.of(), superclassSignature, superinterfaceSignatures); } @@ -67,8 +67,8 @@ public static ClassSignature of(Signature.RefTypeSig superclassSignature, * @param superinterfaceSignatures the interfaces */ public static ClassSignature of(List<Signature.TypeParam> typeParameters, - Signature.RefTypeSig superclassSignature, - Signature.RefTypeSig... superinterfaceSignatures) { + Signature.ClassTypeSig superclassSignature, + Signature.ClassTypeSig... superinterfaceSignatures) { return new SignaturesImpl.ClassSignatureImpl( requireNonNull(typeParameters), requireNonNull(superclassSignature),
|