Skip to content

Commit

Permalink
When running in GraalVM native image auto-detect LIBRARY_SLF4J and LI…
Browse files Browse the repository at this point in the history
…BRARY_COMMONS
  • Loading branch information
fugerit79 committed Jan 18, 2025
1 parent 66b108b commit 35e569b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions freemarker-core/src/main/java/freemarker/log/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,22 @@ private static String getLibraryName(int libraryEnum) {
return LIBRARIES_BY_PRIORITY[(libraryEnum - 1) * 2 + 1];
}

private static boolean isAutoDetected(int libraryEnum) {
// 2.4: Remove libraryEnum == LIBRARY_SLF4J || libraryEnum == LIBRARY_COMMONS
// legacy auto-detection (until FreeMarker 2.3.X)
private static boolean isAutoDetectedLegacy( int libraryEnum ) {
return !(libraryEnum == LIBRARY_AUTO || libraryEnum == LIBRARY_NONE
|| libraryEnum == LIBRARY_SLF4J || libraryEnum == LIBRARY_COMMONS);
}

// next generation auto-detection (FreeMarker 2.4.X and on)
private static boolean isAutoDetectedNG( int libraryEnum ) {
return !(libraryEnum == LIBRARY_AUTO || libraryEnum == LIBRARY_NONE);
}

private static boolean isAutoDetected(int libraryEnum) {
// 2.4: Remove libraryEnum == LIBRARY_SLF4J || libraryEnum == LIBRARY_COMMONS (use only isAutoDetectedNG()=
return IS_GRAALVM_NATIVE ? isAutoDetectedNG(libraryEnum) : isAutoDetectedLegacy(libraryEnum);
}

private static int libraryEnum;
private static LoggerFactory loggerFactory;
private static boolean initializedFromSystemProperty;
Expand Down

0 comments on commit 35e569b

Please sign in to comment.