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

StackTraceElement doesn't contain Class objects but only the class names

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 1.4.2
    • core-libs
    • x86
    • windows_2000

      Name: rmT116609 Date: 10/23/2003


      A DESCRIPTION OF THE REQUEST :
      A StackTraceElement should contain a reference to a Class object.
      A new method would be needed too, let's say
        public Class getClassObject();



      JUSTIFICATION :
      When a Java program wants to take a closer look at a StackTrace returned by a Throwable object it cannot determine which classes were involved.
      The only why to get a Class object is to use getClassName(). Than i must use Class.forName() or such stuff, but as long i don't know the ClassLoader that the Class was loaded with, i cannot be sure you're loading the right one.

      Storing a Class object i a good sollution in my eyes.
      The stored Class object must be transient because Exception are expected to be Serializable and Class object are not (it wouldn't make sense to serialize them too).

      I don't know if storing Class object within Exception harms anything. It will keep Classes from beeing garbage collected.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      i'd like to be abled to get a Class object if a have a proper StackTraceElement object.
      ACTUAL -
      currently, only class names are stored in form of a String object.

      CUSTOMER SUBMITTED WORKAROUND :
      none exists except using Class.forName() - but that doesn't take care of the fact that the class may be loaded with a different ClassLoader.
      (Incident Review ID: 209811)
      ======================================================================

            mchung Mandy Chung (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: