Revert "Revert "Ensure Proxy frames work with JVMTI stack frame functions""
This reverts commit d108d9eaae26df9e4480cf46d26e8c75f142bd6a.
It seems we have a bug somewhere in our proxy or stack-visitor code
causing StackVisitor::GetThisObject to return an object with a null
klass_. Added a temporary skip for the test configurations that expose
this until it can be fixed.
Bug: 66903662
Bug: 67679263
Reason for revert: Added skip for test that exposes a pre-existing bug
in our stack-visitor/proxy-object support.
Test: ./test.py --host -j40
Test: ./test/testrunner/testrunner.py --host --gcstress -t 1939
Change-Id: I8a457112af404c3f4c94e3a2029b744d453ced5d
diff --git a/test/1914-get-local-instance/src/art/Test1914.java b/test/1914-get-local-instance/src/art/Test1914.java
index c09f519..e47f9cb 100644
--- a/test/1914-get-local-instance/src/art/Test1914.java
+++ b/test/1914-get-local-instance/src/art/Test1914.java
@@ -18,7 +18,9 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.nio.ByteBuffer;
import java.util.concurrent.Semaphore;
import java.util.Arrays;
@@ -35,7 +37,7 @@
public static void reportValue(Object val) {
System.out.println("\tValue is '" + val + "' (class: "
- + (val != null ? val.getClass() : "NULL") + ")");
+ + (val != null ? (val instanceof Proxy ? "PROXY CLASS" : val.getClass()) : "NULL") + ")");
}
public static void StaticMethod(Runnable safepoint) {
@@ -151,7 +153,10 @@
private StackTrace.StackFrameData findStackFrame(Thread thr) {
for (StackTrace.StackFrameData frame : StackTrace.GetStackTrace(thr)) {
- if (frame.method.equals(target)) {
+ if (frame.method.equals(target) ||
+ (frame.method.getName().equals(target.getName()) &&
+ Arrays.deepEquals(frame.method.getParameterTypes(), target.getParameterTypes()) &&
+ ((Method)frame.method).getReturnType().equals(target.getReturnType()))) {
return frame;
}
}
@@ -163,6 +168,25 @@
return klass.getDeclaredMethod(name, Runnable.class);
}
+ public static interface Foo {
+ public void InterfaceProxyMethod(Runnable r);
+ }
+
+ public static Object getProxyObject(final Class... k) {
+ return Proxy.newProxyInstance(
+ Test1914.class.getClassLoader(),
+ k,
+ (p, m, a) -> {
+ if (m.getName().equals("toString")) {
+ return "Proxy for " + Arrays.toString(k);
+ } else {
+ ((Runnable)a[0]).run();
+ reportValue(p);
+ return null;
+ }
+ });
+ }
+
public static void run() throws Exception {
Locals.EnableLocalVariableAccess();
final TestCase[] MAIN_TEST_CASES = new TestCase[] {
@@ -172,6 +196,8 @@
getMethod(TargetClass.class, "InstanceMethod")),
new TestCase(new TargetClass("NativeInstanceMethodObject"),
getMethod(TargetClass.class, "NativeInstanceMethod")),
+ new TestCase(getProxyObject(Foo.class),
+ getMethod(Foo.class, "InterfaceProxyMethod")),
};
for (TestCase t: MAIN_TEST_CASES) {