pjfanning commented on code in PR #3151:
URL: https://github.com/apache/pekko/pull/3151#discussion_r3458313487


##########
actor/src/main/scala/org/apache/pekko/util/Reflect.scala:
##########
@@ -36,15 +36,17 @@ private[pekko] object Reflect {
    * This optionally holds a function which looks N levels above itself
    * on the call stack and returns the `Class[_]` object for the code
    * executing in that stack frame. Implemented using
-   * `sun.reflect.Reflection.getCallerClass` if available, None otherwise.
+   * `java.lang.StackWalker` (JDK 9+).
    *
    * Hint: when comparing to Thread.currentThread().getStackTrace, add two 
levels.
    */
   val getCallerClass: Option[Int => Class[?]] = {
     try {
-      val c = Class.forName("sun.reflect.Reflection")
-      val m = c.getMethod("getCallerClass", Array(classOf[Int]): _*)
-      Some((i: Int) => m.invoke(null, 
Array[AnyRef](i.asInstanceOf[java.lang.Integer]): _*).asInstanceOf[Class[?]])
+      val walker = java.lang.StackWalker.getInstance(
+        java.util.Set.of(java.lang.StackWalker.Option.RETAIN_CLASS_REFERENCE))

Review Comment:
   why do we need `java.lang.StackWalker` instead of using `StackWalker`?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to