8320618: NPE: Cannot invoke "java.lang.constant.ClassDesc.isArray()" because "this.sym" is null

Reviewed-by: alanb
This commit is contained in:
Adam Sotona 2023-11-27 08:25:31 +00:00
parent f6e5559ae9
commit 28d3762bd3
2 changed files with 14 additions and 3 deletions

View File

@ -1394,7 +1394,7 @@ public final class StackMapGenerator {
} }
Type getComponent() { Type getComponent() {
if (sym.isArray()) { if (isArray()) {
var comp = sym.componentType(); var comp = sym.componentType();
if (comp.isPrimitive()) { if (comp.isPrimitive()) {
return switch (comp.descriptorString().charAt(0)) { return switch (comp.descriptorString().charAt(0)) {

View File

@ -24,7 +24,7 @@
/* /*
* @test * @test
* @summary Testing Classfile stack maps generator. * @summary Testing Classfile stack maps generator.
* @bug 8305990 8320222 * @bug 8305990 8320222 8320618
* @build testdata.* * @build testdata.*
* @run junit StackMapsTest * @run junit StackMapsTest
*/ */
@ -43,7 +43,6 @@ import static jdk.internal.classfile.Classfile.ACC_STATIC;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.lang.constant.ConstantDescs; import java.lang.constant.ConstantDescs;
import java.lang.constant.MethodTypeDesc; import java.lang.constant.MethodTypeDesc;
import java.util.List;
import java.lang.reflect.AccessFlag; import java.lang.reflect.AccessFlag;
/** /**
@ -237,6 +236,18 @@ class StackMapsTest {
.verify(null)); .verify(null));
} }
@Test
void testInvalidAALOADStack() {
Classfile.of().build(ClassDesc.of("Test"), clb
-> clb.withMethodBody("test", ConstantDescs.MTD_void, 0, cob
-> cob.bipush(10)
.anewarray(ConstantDescs.CD_Object)
.lconst_1() //long on stack caused NPE, see 8320618
.aaload()
.astore(2)
.return_()));
}
private static final FileSystem JRT = FileSystems.getFileSystem(URI.create("jrt:/")); private static final FileSystem JRT = FileSystems.getFileSystem(URI.create("jrt:/"));
private static void testTransformedStackMaps(String classPath, Classfile.Option... options) throws Exception { private static void testTransformedStackMaps(String classPath, Classfile.Option... options) throws Exception {