StackTraceElement question
Christos Zoulas
christos at zoulas.com
Fri Oct 5 12:04:47 PDT 2012
Hi,
I don't know if this belongs to this list, but if it does not,
please point me to where it does. I think that it would be nice if
StackTraceElement which currently contains:
boolean equals(Object obj)
String getClassName()
String getFileName()
int getLineNumber()
String getMethodName()
int hashCode()
boolean isNativeMethod()
String toString()
It would be more useful for it to also contain:
Class<?> getClass()
The reason I am asking, is because I have an application where I
would like to find the enclosing class from where the exception is
thrown not the superclass, but I cannot deduce that from the class
name. If STE contained the above method, I could do:
Class<?> c = ste.getClass();
while (c.getEnclosingClass() != null) {
c = c.getEnclosingClass();
}
return c.getName();
to find the class I want, and getClassName() could be just a wrapper:
String getClassName() {
return getClass().getName();
}
Is there any reason to store the name instead of the Class<?>? Is it
possible to fix this in a future version of the jdk?
thanks
christos
More information about the hotspot-compiler-dev
mailing list