Package akka.util

Class Reflect


  • public class Reflect
    extends java.lang.Object
    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.

    Hint: when comparing to Thread.currentThread.getStackTrace, add two levels.

    • Constructor Summary

      Constructors 
      Constructor Description
      Reflect()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.ClassLoader findClassLoader()
      INTERNAL API
      static <T> java.lang.reflect.Constructor<T> findConstructor​(java.lang.Class<T> clazz, scala.collection.immutable.Seq<java.lang.Object> args)
      INTERNAL API Implements a primitive form of overload resolution a.k.a.
      static java.lang.reflect.Type findMarker​(java.lang.Class<?> root, java.lang.Class<?> marker)  
      static scala.Option<scala.Function1<java.lang.Object,​java.lang.Class<?>>> getCallerClass()  
      static <T> T instantiate​(java.lang.Class<T> clazz)
      INTERNAL API
      static <T> T instantiate​(java.lang.Class<T> clazz, scala.collection.immutable.Seq<java.lang.Object> args)
      INTERNAL API Calls findConstructor and invokes it with the given arguments.
      static <T> T instantiate​(java.lang.reflect.Constructor<T> constructor, scala.collection.immutable.Seq<java.lang.Object> args)
      INTERNAL API Invokes the constructor with the given arguments.
      static <T> scala.Function0<T> instantiator​(java.lang.Class<T> clazz)
      INTERNAL API
      protected static boolean lookupAndSetField​(java.lang.Class<?> clazz, java.lang.Object instance, java.lang.String name, java.lang.Object value)
      INTERNAL API Set a val inside a class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Reflect

        public Reflect()
    • Method Detail

      • getCallerClass

        public static scala.Option<scala.Function1<java.lang.Object,​java.lang.Class<?>>> getCallerClass()
      • instantiate

        public static <T> T instantiate​(java.lang.Class<T> clazz)
        INTERNAL API
        Parameters:
        clazz - the class which to instantiate an instance of
        Returns:
        a new instance from the default constructor of the given class
      • instantiate

        public static <T> T instantiate​(java.lang.Class<T> clazz,
                                        scala.collection.immutable.Seq<java.lang.Object> args)
        INTERNAL API Calls findConstructor and invokes it with the given arguments.
        Parameters:
        clazz - (undocumented)
        args - (undocumented)
        Returns:
        (undocumented)
      • instantiate

        public static <T> T instantiate​(java.lang.reflect.Constructor<T> constructor,
                                        scala.collection.immutable.Seq<java.lang.Object> args)
        INTERNAL API Invokes the constructor with the given arguments.
        Parameters:
        constructor - (undocumented)
        args - (undocumented)
        Returns:
        (undocumented)
      • findConstructor

        public static <T> java.lang.reflect.Constructor<T> findConstructor​(java.lang.Class<T> clazz,
                                                                           scala.collection.immutable.Seq<java.lang.Object> args)
        INTERNAL API Implements a primitive form of overload resolution a.k.a. finding the right constructor.
        Parameters:
        clazz - (undocumented)
        args - (undocumented)
        Returns:
        (undocumented)
      • instantiator

        public static <T> scala.Function0<T> instantiator​(java.lang.Class<T> clazz)
        INTERNAL API
        Parameters:
        clazz - the class which to instantiate an instance of
        Returns:
        a function which when applied will create a new instance from the default constructor of the given class
      • findMarker

        public static java.lang.reflect.Type findMarker​(java.lang.Class<?> root,
                                                        java.lang.Class<?> marker)
      • lookupAndSetField

        protected static final boolean lookupAndSetField​(java.lang.Class<?> clazz,
                                                         java.lang.Object instance,
                                                         java.lang.String name,
                                                         java.lang.Object value)
        INTERNAL API Set a val inside a class.
        Parameters:
        clazz - (undocumented)
        instance - (undocumented)
        name - (undocumented)
        value - (undocumented)
        Returns:
        (undocumented)
      • findClassLoader

        public static java.lang.ClassLoader findClassLoader()
        INTERNAL API
        Returns:
        (undocumented)