This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch release/2.21.0
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit af88da7cb926abb1d35d2dc208381097fed8bd4d
Author: Florian Schmaus <[email protected]>
AuthorDate: Thu Oct 5 14:54:44 2023 +0200

    Use Java version-specific warnings in `StackLocator` (#1760)
    
    Co-authored-by: Piotr P. Karwasz <[email protected]>
    Co-authored-by: Volkan Yazıcı <[email protected]>
---
 .../main/java/org/apache/logging/log4j/util/StackLocator.java | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git 
a/log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java 
b/log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java
index d738f32a87..2ee943185e 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java
@@ -72,12 +72,19 @@ public final class StackLocator {
             } else {
                 o = getCallerClassMethod.invoke(null, 1);
                 if (o == sunReflectionClass) {
-                    System.err.println("WARNING: Unexpected result from 
sun.reflect.Reflection.getCallerClass(int), adjusting offset for future 
calls.");
+                    LowLevelLogUtil.log(
+                            "WARNING: Unexpected result from 
sun.reflect.Reflection.getCallerClass(int), adjusting offset for future 
calls.");
                     java7u25CompensationOffset = 1;
                 }
             }
         } catch (final Exception | LinkageError e) {
-            System.err.println("WARNING: sun.reflect.Reflection.getCallerClass 
is not supported. This will impact performance.");
+            if (Constants.JAVA_MAJOR_VERSION > 8) {
+                LowLevelLogUtil.log(
+                        "WARNING: Runtime environment does not support 
multi-release JARs. This will impact location-based features.");
+            } else {
+                LowLevelLogUtil.log(
+                        "WARNING: sun.reflect.Reflection.getCallerClass is not 
supported. This will impact location-based features.");
+            }
             getCallerClassMethod = null;
             java7u25CompensationOffset = -1;
         }

Reply via email to