Make test 1939 not depend on total number of proxies allocated
Test 1939 would previously only pass if no proxies had been allocated
by the time it started. This made it not work for CTS runs.
We changed the test to filter its output to prevent this problem.
Test: ./test/run-test --host 1939
Bug: 73252141
Change-Id: I6643c9ee8e8d57398a2a5baf0871d69941e07dcd
diff --git a/test/1939-proxy-frames/expected.txt b/test/1939-proxy-frames/expected.txt
index a4c97c9..3aafd16 100644
--- a/test/1939-proxy-frames/expected.txt
+++ b/test/1939-proxy-frames/expected.txt
@@ -5,4 +5,4 @@
Running public abstract void art.Test1939$Foo.InterfaceProxyMethod(java.lang.Runnable) with "GetProxyFrameLocation" on remote thread.
"GetProxyFrameLocation" on public abstract void art.Test1939$Foo.InterfaceProxyMethod(java.lang.Runnable) got value: -1
Running public abstract void art.Test1939$Foo.InterfaceProxyMethod(java.lang.Runnable) with "GetProxyFrameMethod" on remote thread.
-"GetProxyFrameMethod" on public abstract void art.Test1939$Foo.InterfaceProxyMethod(java.lang.Runnable) got value: public final void $Proxy0.InterfaceProxyMethod(java.lang.Runnable)
+"GetProxyFrameMethod" on public abstract void art.Test1939$Foo.InterfaceProxyMethod(java.lang.Runnable) got value: public final void $__PROXY__.InterfaceProxyMethod(java.lang.Runnable)
diff --git a/test/1939-proxy-frames/src/art/Test1939.java b/test/1939-proxy-frames/src/art/Test1939.java
index 83d0d2c..5e86e54 100644
--- a/test/1939-proxy-frames/src/art/Test1939.java
+++ b/test/1939-proxy-frames/src/art/Test1939.java
@@ -44,12 +44,22 @@
public Object GetVar(Thread t, int depth);
}
+ public static String SafeToString(Object o) {
+ if (o instanceof Method && Proxy.isProxyClass(((Method)o).getDeclaringClass())) {
+ // TODO This currently only really works on ART. It would be good if we could make it work for
+ // the RI as well.
+ return o.toString().replaceFirst("Proxy[0-9]+", "__PROXY__");
+ } else {
+ return o.toString();
+ }
+ }
+
public static SafepointFunction NamedGet(final String type, final GetterFunction get) {
return new SafepointFunction() {
public void invoke(Thread t, Method method, int depth) {
try {
Object res = get.GetVar(t, depth);
- System.out.println(this + " on " + method + " got value: " + res);
+ System.out.println(this + " on " + method + " got value: " + SafeToString(res));
} catch (Exception e) {
System.out.println(this + " on " + method + " failed due to " + e.getMessage());
}