-
Enhancement
-
Resolution: Duplicate
-
P5
-
None
-
1.1.3
-
x86
-
windows_95
Name: joT67522 Date: 10/14/97
import java.lang.reflect.Method;
/**
* Test ease of debugging exceptions in deep invocations.
* Invocation is useful in loosely coupled systems where
* method calls are parameter driven services.
*
* Note that in the exception stack trace there is no
* mention of where the initial exception occured. This
* makes it very hard to debug deep invocations, as one
* must resort to embedding print() to isolate the bug.
*
* SUGGESTION:
* Since the Method must be created before invoke(), the
* greatest exception risk is already past when invoke()
* is called. One solution would be to add:
* Method.invokeNoCatch(Object obj, Object args[])
* which throws no exceptions but does throw errors.
*
* @author Jack Harich - 8/30/97 - ###@###.###
*/
public class TestInvoke {
//---------- Private Fields ------------------------------
// (none)
//---------- Initialization ------------------------------
public static void main(String args[]) {
new TestInvoke();
}
public TestInvoke() {
try {
// Create method
Class[] classes = { }; // No arg
Method method = this.getClass().getMethod("logonRequested", classes);
// Call method
Object[] args = { }; // No arg
method.invoke(this, args);
} catch(Exception ex) {
print("TestInvoke exception");
ex.printStackTrace();
}
}
//---------- Public Methods ------------------------------
public void logonRequested() {
print("TestInvoke.logonRequested() - entered");
// Create test exception
int divisor = 0;
int test = 5 / divisor; // <-----<<< EXCEPTION
}
//---------- Private Methods -----------------------------
//--- Std
private static void print(String text) {
System.out.println(text);
}
} // End class
company - Consultant , email - ###@###.###
======================================================================
- duplicates
-
JDK-4086279 {ExceptionInInitializer/InvocationTarget} exceptions must show 2 stack traces
-
- Closed
-