Fix stack trace for proxy methods and added test case.
Bug: 11861564
Change-Id: I9513359ff9e5d345ee71d84388afed02bd114ecf
(cherry picked from 228d6b8a4f0a21c1e9b2372c3104ce4ee19f65b4)
diff --git a/test/044-proxy/src/BasicTest.java b/test/044-proxy/src/BasicTest.java
index 46aa3fe..ea46f49 100644
--- a/test/044-proxy/src/BasicTest.java
+++ b/test/044-proxy/src/BasicTest.java
@@ -51,6 +51,8 @@
colors.blue(777);
colors.mauve("sorry");
colors.blob();
+ Trace trace = (Trace) proxy;
+ trace.getTrace();
try {
shapes.upChuck();
@@ -96,7 +98,7 @@
/* create the proxy class */
Class proxyClass = Proxy.getProxyClass(Shapes.class.getClassLoader(),
- new Class[] { Quads.class, Colors.class });
+ new Class[] { Quads.class, Colors.class, Trace.class });
/* create a proxy object, passing the handler object in */
Object proxy = null;
@@ -156,6 +158,10 @@
public R0aa checkMe();
}
+interface Trace {
+ public void getTrace();
+}
+
/*
* Some return types.
*/
@@ -248,6 +254,20 @@
throw new RuntimeException("huh?");
}
+ if (method.getDeclaringClass() == Trace.class) {
+ if (method.getName().equals("getTrace")) {
+ StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+ for (int i = 0; i < stackTrace.length; i++) {
+ StackTraceElement ste = stackTrace[i];
+ if (ste.getMethodName().equals("getTrace")) {
+ System.out.println(ste.getClassName() + "." + ste.getMethodName() + " " +
+ ste.getFileName() + ":" + ste.getLineNumber());
+ }
+ }
+ return null;
+ }
+ }
+
System.out.println("Invoke " + method);
if (args == null || args.length == 0) {
System.out.println(" (no args)");