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)
======================================================================
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)
======================================================================
- relates to
-
JDK-4485384 StackTraceElement should give access to full method signatures
-
- Closed
-
-
JDK-4751112 Add getArgumentTypes to StackTraceElement
-
- Closed
-