diff --git a/src/java.base/share/classes/java/lang/constant/ConstantUtils.java b/src/java.base/share/classes/java/lang/constant/ConstantUtils.java index b397664145f..21f52ee2f35 100644 --- a/src/java.base/share/classes/java/lang/constant/ConstantUtils.java +++ b/src/java.base/share/classes/java/lang/constant/ConstantUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -193,7 +193,7 @@ class ConstantUtils { int index = start; while (index < end) { switch (descriptor.charAt(index)) { - case JVM_SIGNATURE_VOID: if (!voidOK) { return index; } + case JVM_SIGNATURE_VOID: if (!voidOK) { return 0; } case JVM_SIGNATURE_BOOLEAN: case JVM_SIGNATURE_BYTE: case JVM_SIGNATURE_CHAR: diff --git a/test/jdk/java/lang/constant/boottest/java.base/java/lang/constant/ConstantUtilsTest.java b/test/jdk/java/lang/constant/boottest/java.base/java/lang/constant/ConstantUtilsTest.java index 87a5315688c..12ef29273dc 100644 --- a/test/jdk/java/lang/constant/boottest/java.base/java/lang/constant/ConstantUtilsTest.java +++ b/test/jdk/java/lang/constant/boottest/java.base/java/lang/constant/ConstantUtilsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import static org.testng.Assert.*; /** * @test + * @bug 8303930 * @compile ConstantUtilsTest.java * @run testng ConstantUtilsTest * @summary unit tests for methods of java.lang.constant.ConstantUtils that are not covered by other unit tests @@ -66,4 +67,9 @@ public class ConstantUtilsTest { } } } + + public void testSkipOverFieldSignatureVoid() { + int ret = ConstantUtils.skipOverFieldSignature("(V)V", 1, 4, false); + assertEquals(ret, 0, "Descriptor of (V)V starting at index 1, void disallowed"); + } }