Interface ReflectiveProxyObject


@Experimental public interface ReflectiveProxyObject
All interfaces used for XReflection.proxify(Class) must extend this interface. Instances of this class can be thought as a dynamic Class object that contains methods, fields and constructors, whether final or static, but all in forms of public methods.

The first instance of this class should be used for only calling constructors, static methods and fields, and bindTo(Object) method. However, it's possible to create two separate classes for constructors and static members and one for non-static members without constructors.

Since:
13.0.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    bindTo(@NotNull Object instance)
    Returns a new ReflectiveProxyObject that's linked to a new ReflectiveProxy with the given instance.
    @NotNull Class<?>
    Get the real class object that this proxy object is referencing.
    @NotNull Object
    Gets the instance that the methods are delegating to.
    default @org.jetbrains.annotations.NotNull boolean
    isInstance(@Nullable Object object)
    Equivalent to the code:
    default @NotNull Object[]
    newArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int length)
    Equivalent to the code:
    default @NotNull Object[]
    newArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int... dimensions)
    Equivalent to the code:
  • Method Details

    • instance

      @NotNull @NonExtendable @Contract(pure=true) @NotNull Object instance()
      Gets the instance that the methods are delegating to. Throw an exception if used on the factory object.
    • getTargetClass

      @NotNull @NonExtendable @Contract(pure=true) @NotNull Class<?> getTargetClass()
      Get the real class object that this proxy object is referencing.
      Since:
      14.0.0
    • isInstance

      @NotNull @NonExtendable @Contract(pure=true) default @org.jetbrains.annotations.NotNull boolean isInstance(@Nullable @Nullable Object object)
      Equivalent to the code:
      object instanceof TargetClass
      This results in more performance in generated code instead of doing:
      getTargetClass().isInstance(object.getClass())
      So do note that this will never return true if you pass a ReflectiveProxyObject to it.
      Since:
      14.0.0
    • newArray

      @NotNull @NonExtendable @Contract(pure=true) default @NotNull Object[] newArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int length)
      Equivalent to the code:
      new TargetClass[length]
      This results in a slight performance improvement in generated code instead of doing:
      Array.newInstance(getTargetClass(), length)
      So do note that this will never return true if you pass a ReflectiveProxyObject to it.
      Since:
      14.1.0
    • newArray

      @NotNull @NonExtendable @Contract(pure=true) default @NotNull Object[] newArray(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int... dimensions)
      Equivalent to the code:
      new TargetClass[length0][length1][...]
      This results in a slight performance improvement in generated code instead of doing:
      Array.newInstance(getTargetClass(), length)
      So do note that this will never return true if you pass a ReflectiveProxyObject to it.
      Since:
      14.1.0
    • bindTo

      @NotNull @OverrideOnly @Contract(value="_ -> new", pure=true) @NotNull ReflectiveProxyObject bindTo(@NotNull @NotNull Object instance)
      Returns a new ReflectiveProxyObject that's linked to a new ReflectiveProxy with the given instance.
      Parameters:
      instance - the instance to bind.