Interface ReflectionService

All Known Implementing Classes:
DefaultReflectionService

@API(status=MAINTAINED) public interface ReflectionService
A low-level service responsible for generating, instantiating, and invoking methods on arbitrary interface implementations.

This service provides two APIs, the Instantiator and the MethodMirror. The purpose of separating these interfaces is to make it easy for different reflection service implementations to re-share one or the other object.

API status

Because of this API's status as a service provider, it may require updating to keep in sync with the library's minor versions. Some minor versions might offer new features, which would need to be implemented by this interface and its Instantiator/MethodMirror implementations.

If implementations of ReflectionService are not updated, they will still be compatible with the library in a strict sense. Existing code will never break. However, newer features may be disabled or refuse to work.

Lookup

Both the methods on this interface take a lookup parameter. By default, ths library will pass a lookup representing its own space.arim.dazzleconf module. If the library user specifies another lookup, it will be passed instead.

Implementors can rely on this lookup having full privileged access, however. Thus, the implementor may rely on it for reflective access to an interface that is to be implemented, invokespecial on one of its methods, or for loading or defining classes implementing that interface.

  • Method Details

    • makeInstantiator

      @NonNull Instantiator makeInstantiator(@NonNull MethodHandles.Lookup lookup)
      Gets the instantiator this service provides.

      The instantiator is responsible for generating and instantiating implementations of the configuration interface.

      Parameters:
      lookup - the lookup to use for privileged access
      Returns:
      an instantiator
    • makeMethodMirror

      @NonNull MethodMirror makeMethodMirror(@NonNull MethodHandles.Lookup lookup)
      Gets the MethodMirror this service provides.

      The method mirror is responsible for

      The method mirror is supplied by this function, and it may share resources and techniques with the instantiator. In particular, MethodMirror.makeInvoker(Object, Class) can be more efficient when used with objects generated by the same instantiator in makeInstantiator(MethodHandles.Lookup).

      Parameters:
      lookup - the lookup to use for privileged access
      Returns:
      a method mirror