Skip to content

Commit a5b0f8c

Browse files
author
Christian Wimmer
committed
Exclude JDK classes from AssertInitializationSpecifiedForAllClasses check
1 parent ac259b2 commit a5b0f8c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/classinitialization/ClassInitializationFeature.java

+11
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,18 @@ public void afterAnalysis(AfterAnalysisAccess a) {
193193
}
194194

195195
if (ClassInitializationOptions.AssertInitializationSpecifiedForAllClasses.getValue()) {
196+
/*
197+
* This option enables a check that all application classes have an explicitly
198+
* specified initialization status. This is useful to ensure that most classes (all
199+
* classes for which it is feasible) are marked as "initialize at image build time"
200+
* to avoid the overhead of class initialization checks at run time.
201+
*
202+
* We exclude JDK classes from the check: the application should not interfere with
203+
* the class initialization status of the JDK because the application cannot know
204+
* which JDK classes are safe for initialization at image build time.
205+
*/
196206
List<String> unspecifiedClasses = classInitializationSupport.classesWithKind(RUN_TIME).stream()
207+
.filter(c -> c.getClassLoader() != null && c.getClassLoader() != ClassLoader.getPlatformClassLoader())
197208
.filter(c -> classInitializationSupport.specifiedInitKindFor(c) == null)
198209
.map(Class::getTypeName)
199210
.collect(Collectors.toList());

0 commit comments

Comments
 (0)