Class AggregateReflectiveHandle<T,H extends ReflectiveHandle<T>>

java.lang.Object
com.cryptomorin.xseries.reflection.AggregateReflectiveHandle<T,H>
Type Parameters:
T - the JVM type of AggregateReflectiveHandle
H - the types of handles that are going to be checked.
All Implemented Interfaces:
ReflectiveHandle<T>, Cloneable

public class AggregateReflectiveHandle<T,H extends ReflectiveHandle<T>> extends Object implements ReflectiveHandle<T>
Most reflection APIs already provide a name-based fallback system that can be used (like DynamicClassHandle.named(String...)) but sometimes the signature of certain JVM declarations just change entirely, that's where this class could be useful.

It simply tries the reflect() method of each handle until one of them returns without throwing an exception (order matters).

Usage


    MethodMemberHandle profileByName = XReflection.of(GameProfileCache.class).method().named("getProfile", "a");
    MethodHandle getProfileByName = XReflection.anyOf(
        () -> profileByName.signature("public GameProfile get(String username);"),
        () -> profileByName.signature("public Optional<GameProfile> get(String username);")
    ).reflect();
 
See Also: