Skip to content

Commit af88da7

Browse files
Flowdalicppkarwaszvy
committed
Use Java version-specific warnings in StackLocator (#1760)
Co-authored-by: Piotr P. Karwasz <[email protected]> Co-authored-by: Volkan Yazıcı <[email protected]>
1 parent b8d08c4 commit af88da7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,19 @@ public final class StackLocator {
7272
} else {
7373
o = getCallerClassMethod.invoke(null, 1);
7474
if (o == sunReflectionClass) {
75-
System.err.println("WARNING: Unexpected result from sun.reflect.Reflection.getCallerClass(int), adjusting offset for future calls.");
75+
LowLevelLogUtil.log(
76+
"WARNING: Unexpected result from sun.reflect.Reflection.getCallerClass(int), adjusting offset for future calls.");
7677
java7u25CompensationOffset = 1;
7778
}
7879
}
7980
} catch (final Exception | LinkageError e) {
80-
System.err.println("WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.");
81+
if (Constants.JAVA_MAJOR_VERSION > 8) {
82+
LowLevelLogUtil.log(
83+
"WARNING: Runtime environment does not support multi-release JARs. This will impact location-based features.");
84+
} else {
85+
LowLevelLogUtil.log(
86+
"WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact location-based features.");
87+
}
8188
getCallerClassMethod = null;
8289
java7u25CompensationOffset = -1;
8390
}

0 commit comments

Comments
 (0)