-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
1.3.0
-
generic
-
generic
Name: rmT116609 Date: 10/16/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-beta)
Java HotSpot(TM) Client VM (build 1.3-beta, mixed mode)
Class.forName("int") throws a ClassNotFoundException. The API docs suggest that
this is because there might actually be a class named "int" in the default
package (although you'd have to use defineClass to make it since the compiler
won't let you make a class named "int"-- it causes a parse error). Fair
enough. However, I think there should be SOME way to get the Class object (in
this case Integer.TYPE) from the string containing its name, rather than having
to manually search a table that maps the names of primitive types to their Class
objects. Something like Class.getPrimitiveType(String) would be fine.
Otherwise one would have to add new primitive types to the table if they are
added to the language-- granted that's not very likely, but it can't hurt,
right?
(Review ID: 110934)
======================================================================
- duplicates
-
JDK-4207220 Add getPrimitiveClass() and getWrapperClass() methods to java.lang.Class.
-
- Closed
-