I'm using reflection in Java to call a Constructor.newInstance()
. Some of the time I encounter primitive types -- which give me trouble when I try to use Class<T>.cast()
from them.
Suppose I have this:
Class<?> argumentClass = /* obtain class through reflection */;
Is there a way to convert argumentClass
from primitive types (Integer.TYPE
) to their boxed equivalent (Integer.class
) when a primitive type is encountered?