Skip to content

Commit c890433

Browse files
committed
Improve error message and rename function for initializing classes for earlier JDKs
1 parent 3364e05 commit c890433

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

common/junit-platform-native/src/main/java/org/graalvm/junit/platform/JUnitPlatformFeature.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
106106
/* Before GraalVM version 22 we couldn't have classes initialized at run-time
107107
* that are also used at build-time but not added to the image heap */
108108
if (Runtime.version().feature() <= 21) {
109-
initializeClassesForJDKsBefore21();
109+
initializeClassesForJDK21OrEarlier();
110110
}
111111

112112
List<? extends DiscoverySelector> selectors = getSelectors();
@@ -232,14 +232,15 @@ private static Class<?> findClassOrNull(ClassLoader loader, String className) {
232232
}
233233
}
234234

235-
private static void initializeClassesForJDKsBefore21() {
235+
private static void initializeClassesForJDK21OrEarlier() {
236236
try (InputStream is = JUnitPlatformFeature.class.getResourceAsStream("/initialize-at-buildtime")) {
237237
if (is != null) {
238238
BufferedReader br = new BufferedReader(new InputStreamReader(is));
239239
br.lines().forEach(RuntimeClassInitialization::initializeAtBuildTime);
240+
br.close();
240241
}
241242
} catch (IOException e) {
242-
throw new RuntimeException(e);
243+
throw new RuntimeException("Failed to process build time initializations for JDK 21 or earlier");
243244
}
244245
}
245246
}

0 commit comments

Comments
 (0)