rgoers commented on a change in pull request #480:
URL: https://github.com/apache/logging-log4j2/pull/480#discussion_r603790813
##########
File path:
log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java
##########
@@ -16,75 +16,23 @@
*/
package org.apache.logging.log4j.util;
-import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Optional;
import java.util.Stack;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
- * <em>Consider this class private.</em> Provides various methods to determine
the caller class. <h3>Background</h3>
- * <p>
- * This method, available only in the Oracle/Sun/OpenJDK implementations of
the Java Virtual Machine, is a much more
- * efficient mechanism for determining the {@link Class} of the caller of a
particular method. When it is not available,
- * a {@link SecurityManager} is the second-best option. When this is also not
possible, the {@code StackTraceElement[]}
- * returned by {@link Throwable#getStackTrace()} must be used, and its {@code
String} class name converted to a
- * {@code Class} using the slow {@link Class#forName} (which can add an extra
microsecond or more for each invocation
- * depending on the runtime ClassLoader hierarchy).
- * </p>
- * <p>
- * During Java 8 development, the {@code
sun.reflect.Reflection.getCallerClass(int)} was removed from OpenJDK, and this
- * change was back-ported to Java 7 in version 1.7.0_25 which changed the
behavior of the call and caused it to be off
- * by one stack frame. This turned out to be beneficial for the survival of
this API as the change broke hundreds of
- * libraries and frameworks relying on the API which brought much more
attention to the intended API removal.
- * </p>
- * <p>
- * After much community backlash, the JDK team agreed to restore {@code
getCallerClass(int)} and keep its existing
- * behavior for the rest of Java 7. However, the method is deprecated in Java
8, and current Java 9 development has not
- * addressed this API. Therefore, the functionality of this class cannot be
relied upon for all future versions of Java.
- * It does, however, work just fine in Sun JDK 1.6, OpenJDK 1.6,
Oracle/OpenJDK 1.7, and Oracle/OpenJDK 1.8. Other Java
- * environments may fall back to using {@link Throwable#getStackTrace()} which
is significantly slower due to
- * examination of every virtual frame of execution.
- * </p>
+ * <em>Consider this class private.</em> Determines the caller's class.
*/
-public final class StackLocator {
+public class StackLocator {
Review comment:
Interesting. I didn't actually modify the class. Just moved the version
from the Java9 branch in. I wonder why this and the @PerformanceSensitive
annotation weren't ever added to that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]