dimanche 5 juillet 2020

JAVA: Not sure about getting constructor with generic types in reflection

public class A<T, U> implements S<T, U> {
    private final T first;
    private final U second;

    public A(T first, U second) {
        this.first = first;
        this.second = second;
    }
}

Is there anyway to call the public constructor from reflection?

What I'm trying to do is

classLoader.loadClass("A").getConstructor(<Something Here>).newInstance()

Is it possible for me to do this?





Aucun commentaire:

Enregistrer un commentaire