Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4379804

There should be a way to get a primitive class from its name.

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • core-libs



      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)
      ======================================================================

            darcy Joe Darcy
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: