All Downloads are FREE. Search and download functionalities are using the official Maven repository.

icasue.reflect.handles.string.StringO Maven / Gradle / Ivy

package icasue.reflect.handles.string;

import lombok.SneakyThrows;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;

/**
 * @Author: Qiao Hang
 * @CreateDate: 2020/12/2 上午10:43
 * @UpdateDate:
 * @Description:
 */
public class StringO {

    static {
        try {
            Class loadHandleOperate = StringO.class.getClassLoader().loadClass("icasue.reflect.handles.HandleSupplier");
            StringO.lookup = (MethodHandles.Lookup)loadHandleOperate.getDeclaredField("methodLookup").get(null);
        }catch (Throwable e){
            throw new RuntimeException("ObjectO init error.",e);
        }
    }

    static {
        findHandles();
    }

    public static MethodHandles.Lookup lookup;

    //static
    public static MethodHandle valueOf;
    public static MethodHandle join_List;

    @SneakyThrows(Throwable.class)
    private static void findHandles() {
        valueOf = lookup.findStatic(String.class,"valueOf", MethodType.methodType(String.class,Object.class));
        join_List = lookup.findStatic(String.class,"join",MethodType.methodType(String.class,CharSequence.class,Iterable.class));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy