Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,22 @@ private List<TypeParam> parseParamTypes() {
RefTypeSig classBound = null;
ArrayList<RefTypeSig> interfaceBounds = null;
require(':');
if (sig.charAt(sigp) != ':')
classBound = referenceTypeSig();
if (sig.charAt(sigp) != ':') {
int p = nextIdentifierEnd(sig, sigp);
// For non-identifier chars:
// . / < indicates class type (inner, package, type arg)
// [ indicates array type
// ; indicates class/type var type
// > and : are illegal, such as in <P:R:>
if (p < sig.length()) {
char limit = sig.charAt(p);
if (limit != '>' && limit != ':') {
classBound = referenceTypeSig();
}
}
// If classBound is absent here, we start tokenizing
// next type parameter, which can trigger failures
}
while (match(':')) {
if (interfaceBounds == null)
interfaceBounds = new ArrayList<>();
Expand Down
16 changes: 15 additions & 1 deletion test/jdk/jdk/classfile/SignaturesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/*
* @test
* @summary Testing Signatures.
* @bug 8321540 8319463 8357955
* @bug 8321540 8319463 8357955 8368050 8368331
* @run junit SignaturesTest
*/
import java.io.IOException;
Expand Down Expand Up @@ -120,6 +120,20 @@ void testBuildingSignatures() {
assertEqualsDeep(
ArrayTypeSig.of(2, TypeVarSig.of("E")),
Signature.parseFrom("[[TE;"));

assertEqualsDeep(
MethodSignature.of(
List.of(TypeParam.of("A", ClassTypeSig.of("one/Two")), // /
TypeParam.of("B", ClassTypeSig.of(ClassTypeSig.of("Outer"), "Inner")), // .
TypeParam.of("C", ArrayTypeSig.of(BaseTypeSig.of('I'))), // [
TypeParam.of("D", ClassTypeSig.of("Generic", TypeArg.unbounded())), // <
TypeParam.of("E", TypeVarSig.of("A")), // ;
TypeParam.of("F", (ClassTypeSig) null), // :
TypeParam.of("G", (ClassTypeSig) null)), // >
List.of(),
BaseTypeSig.of('V')),
MethodSignature.parseFrom("<A:Lone/Two;B:LOuter.Inner;C:[ID:LGeneric<*>;E:TA;F:G:>()V")
);
}

@Test
Expand Down