8303930: Fix ConstantUtils.skipOverFieldSignature void case return value

Reviewed-by: mchung
This commit is contained in:
Chen Liang 2023-03-31 17:14:44 +00:00 committed by Mandy Chung
parent 4a5d7ca7d9
commit bdbf8fc61d
2 changed files with 9 additions and 3 deletions
src/java.base/share/classes/java/lang/constant
test/jdk/java/lang/constant/boottest/java.base/java/lang/constant

@ -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:

@ -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");
}
}