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

RFE: More explicit error msg on ClassCastException

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.1
    • hotspot
    • x86
    • windows_2000



      Name: yyT116575 Date: 08/06/2001


      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      When executing

      > Object obj = new Integer(0);
      > String s = (String) obj;

      the current error message is as follows:

      > Exception in thread "main" java.lang.ClassCastException: java.lang.Integer
      > at T.main(T.java:13)

      It would be better to have a more explicit error message like:

      > Exception in thread "main" java.lang.ClassCastException: cannot cast from
      java.lang.Integer to java.lang.String
      > at T.main(T.java:13)

      This is especially true in a distributed environment where some classes
      (stubs/skeletons) are generated and not all source code is available.
      (Review ID: 129472)
      ======================================================================

            hhuangsunw Hui Huang (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: