Skip to content

Commit

Permalink
Exclude JDK classes from AssertInitializationSpecifiedForAllClasses c…
Browse files Browse the repository at this point in the history
…heck
  • Loading branch information
Christian Wimmer committed Jun 26, 2023
1 parent 7f6d6f3 commit 38e9a50
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,18 @@ public void afterAnalysis(AfterAnalysisAccess a) {
}

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

0 comments on commit 38e9a50

Please sign in to comment.