Skip to content

Commit 28d3762

Browse files
committed
8320618: NPE: Cannot invoke "java.lang.constant.ClassDesc.isArray()" because "this.sym" is null
Reviewed-by: alanb
1 parent f6e5559 commit 28d3762

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ Type toArray() {
13941394
}
13951395

13961396
Type getComponent() {
1397-
if (sym.isArray()) {
1397+
if (isArray()) {
13981398
var comp = sym.componentType();
13991399
if (comp.isPrimitive()) {
14001400
return switch (comp.descriptorString().charAt(0)) {

test/jdk/jdk/classfile/StackMapsTest.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/*
2525
* @test
2626
* @summary Testing Classfile stack maps generator.
27-
* @bug 8305990 8320222
27+
* @bug 8305990 8320222 8320618
2828
* @build testdata.*
2929
* @run junit StackMapsTest
3030
*/
@@ -43,7 +43,6 @@
4343
import java.lang.constant.ClassDesc;
4444
import java.lang.constant.ConstantDescs;
4545
import java.lang.constant.MethodTypeDesc;
46-
import java.util.List;
4746
import java.lang.reflect.AccessFlag;
4847

4948
/**
@@ -237,6 +236,18 @@ void testClassVersions() throws Exception {
237236
.verify(null));
238237
}
239238

239+
@Test
240+
void testInvalidAALOADStack() {
241+
Classfile.of().build(ClassDesc.of("Test"), clb
242+
-> clb.withMethodBody("test", ConstantDescs.MTD_void, 0, cob
243+
-> cob.bipush(10)
244+
.anewarray(ConstantDescs.CD_Object)
245+
.lconst_1() //long on stack caused NPE, see 8320618
246+
.aaload()
247+
.astore(2)
248+
.return_()));
249+
}
250+
240251
private static final FileSystem JRT = FileSystems.getFileSystem(URI.create("jrt:/"));
241252

242253
private static void testTransformedStackMaps(String classPath, Classfile.Option... options) throws Exception {

0 commit comments

Comments
 (0)