Skip to content

Commit bdbf8fc

Browse files
liachMandy Chung
authored andcommitted
8303930: Fix ConstantUtils.skipOverFieldSignature void case return value
Reviewed-by: mchung
1 parent 4a5d7ca commit bdbf8fc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/java.base/share/classes/java/lang/constant/ConstantUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -193,7 +193,7 @@ static int skipOverFieldSignature(String descriptor, int start, int end, boolean
193193
int index = start;
194194
while (index < end) {
195195
switch (descriptor.charAt(index)) {
196-
case JVM_SIGNATURE_VOID: if (!voidOK) { return index; }
196+
case JVM_SIGNATURE_VOID: if (!voidOK) { return 0; }
197197
case JVM_SIGNATURE_BOOLEAN:
198198
case JVM_SIGNATURE_BYTE:
199199
case JVM_SIGNATURE_CHAR:

test/jdk/java/lang/constant/boottest/java.base/java/lang/constant/ConstantUtilsTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
3333

3434
/**
3535
* @test
36+
* @bug 8303930
3637
* @compile ConstantUtilsTest.java
3738
* @run testng ConstantUtilsTest
3839
* @summary unit tests for methods of java.lang.constant.ConstantUtils that are not covered by other unit tests
@@ -66,4 +67,9 @@ public void testValidateMemberName() {
6667
}
6768
}
6869
}
70+
71+
public void testSkipOverFieldSignatureVoid() {
72+
int ret = ConstantUtils.skipOverFieldSignature("(V)V", 1, 4, false);
73+
assertEquals(ret, 0, "Descriptor of (V)V starting at index 1, void disallowed");
74+
}
6975
}

0 commit comments

Comments
 (0)