Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ default ConstantValueEntry constantValueEntry(ConstantDesc c) {
if (c instanceof Long l) return longEntry(l);
if (c instanceof Float f) return floatEntry(f);
if (c instanceof Double d) return doubleEntry(d);
throw new IllegalArgumentException("Illegal type: " + (c == null ? null : c.getClass()));
throw new IllegalArgumentException("Illegal type: " + c.getClass()); // implicit null check
}

/**
Expand All @@ -559,7 +559,8 @@ default LoadableConstantEntry loadableConstantEntry(ConstantDesc c) {
if (c instanceof MethodTypeDesc mtd) return methodTypeEntry(mtd);
if (c instanceof DirectMethodHandleDesc dmhd) return methodHandleEntry(dmhd);
if (c instanceof DynamicConstantDesc<?> dcd) return constantDynamicEntry(dcd);
throw new IllegalArgumentException("Illegal type: " + (c == null ? null : c.getClass()));
// Shouldn't reach here
throw new IllegalArgumentException("Illegal type: " + c.getClass()); // implicit null check
}

/**
Expand Down
9 changes: 8 additions & 1 deletion test/jdk/jdk/classfile/ConstantDescSymbolsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/*
* @test
* @bug 8304031 8338406 8338546
* @bug 8304031 8338406 8338546 8361909
* @summary Testing handling of various constant descriptors in ClassFile API.
* @modules java.base/jdk.internal.constant
* java.base/jdk.internal.classfile.impl
Expand Down Expand Up @@ -58,6 +58,13 @@

final class ConstantDescSymbolsTest {

@Test
void testNulls() {
var cpb = ConstantPoolBuilder.of();
assertThrows(NullPointerException.class, () -> cpb.loadableConstantEntry(null));
assertThrows(NullPointerException.class, () -> cpb.constantValueEntry(null));
}

// Testing that primitive class descs are encoded properly as loadable constants.
@Test
void testPrimitiveClassDesc() throws Throwable {
Expand Down