How to use getDeclaredConstructor if my constructor accepts a primitive type?

I am finding a constructor like this:

type.getDeclaredConstructor(Integer.class);

This works when type is

MyType {
public MyType(Integer a);
}

However, this does not work when type is

MyType {
public MyType(int a);
}

And I do not want to replace int with Integer as I was told it may incur unnecessary overhead.

What do I do?

Jon Skeet
people
quotationmark

You can use

type.getDeclaredConstructor(int.class);

From section 15.8.2 of the JLS:

A class literal is an expression consisting of the name of a class, interface, array, or primitive type, or the pseudo-type void, followed by a '.' and the token class.

people

See more on this question at Stackoverflow