functionInt
will always be passed an Integer
, and there is no way to determine if that Integer
was created as a result of autoboxing or not.
What you could do is create overloaded functions:
void functionInt(Integer i);
void functionInt(int i);
/edit
If you have the following class:
public class Foo {
public Foo(int primitive) {
System.out.println("Created!");
}
}
You can call Foo.class.getConstructor(int.class).newInstance(new Integer(5))
without any problems. It should be fairly simple to check for a Constructor
that has int.class
as a parameter instead of java.util.Integer
if one with java.util.Integer
cannot be found.