mardi 14 mars 2017

How can I determine amount of constructor parameters for a generic type using reflections in java?

I need to determine how many arguments a constructor accepts during runtime in a generic method. I know every type T extends the same baseclass and they only have one constructor each, but they take different amount of parameters.

public T someMethod() {
    // get amount of parameters T constructor takes
}

Is there a simple way of achieving this?





Aucun commentaire:

Enregistrer un commentaire