Reputation: 121998
Looking at source code of Integer class, just stumble at this below line
Class<Integer> TYPE = (Class<Integer>) Class.getPrimitiveClass("int");
And getPrimitiveClass
is a native method.
static native Class getPrimitiveClass(String name);
Why it became a native method ? really want to know.
How one can create an instance for Class
?? Does that differs with normal way of creating instance for ex : Ex e = new Ex()
?
Upvotes: 6
Views: 177
Reputation: 62864
The comment above the method definition says:
/*
* Return the Virtual Machine's Class object for the named
* primitive type.
*/
static native Class getPrimitiveClass(String name);
Since the (at least, Sun's) Virtual Machine is implemented in C, then I would assume that this is the reason for the method being native
.
Upvotes: 2