Skip to content

Commit 7b31e0c

Browse files
committed
Polish contribution
See gh-36938
1 parent 233e7b9 commit 7b31e0c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

spring-core/src/test/java/org/springframework/aot/nativex/feature/ThrowawayClassLoaderTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public InputStream getResourceAsStream(String name) {
5757
assertThat(closed).as("InputStream closed").isTrue();
5858
}
5959

60-
@Test
60+
@Test // gh-36938
6161
void loadClassThrowsClassNotFoundExceptionWhenClassResourceIsMissing() {
6262
// The grandparent resolves bootstrap classes only, so super.loadClass(...) fails,
6363
// and the resource loader provides no class bytes. The fallback must then honor the
@@ -70,10 +70,13 @@ public InputStream getResourceAsStream(String name) {
7070
};
7171
ThrowawayClassLoader classLoader = new ThrowawayClassLoader(resourceLoader);
7272

73+
String name = "com.example.MissingClass";
7374
assertThatExceptionOfType(ClassNotFoundException.class)
74-
.isThrownBy(() -> classLoader.loadClass("com.example.MissingClass"));
75+
.isThrownBy(() -> classLoader.loadClass(name))
76+
.withMessageContaining(name);
7577
}
7678

79+
7780
private static byte[] classBytesOf(String className) throws IOException {
7881
String resourceName = className.replace('.', '/') + ".class";
7982
try (InputStream in = ThrowawayClassLoaderTests.class.getClassLoader().getResourceAsStream(resourceName)) {

0 commit comments

Comments
 (0)