summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/988-method-trace/expected-stdout.txt44
-rw-r--r--test/988-method-trace/src/art/Test988.java34
2 files changed, 46 insertions, 32 deletions
diff --git a/test/988-method-trace/expected-stdout.txt b/test/988-method-trace/expected-stdout.txt
index b263308573..f82b392da5 100644
--- a/test/988-method-trace/expected-stdout.txt
+++ b/test/988-method-trace/expected-stdout.txt
@@ -166,10 +166,10 @@ fibonacci(5)=5
......=> private static java.lang.Object java.lang.Throwable.nativeFillInStackTrace()
......<= private static java.lang.Object java.lang.Throwable.nativeFillInStackTrace() -> <class [Ljava.lang.Object;: <non-deterministic>>
.....<= public synchronized java.lang.Throwable java.lang.Throwable.fillInStackTrace() -> <class java.lang.Error: java.lang.Error: Bad argument: -19 < 0
- art.Test988.iter_fibonacci(Test988.java:255)
- art.Test988$IterOp.applyAsInt(Test988.java:250)
- art.Test988.doFibTest(Test988.java:388)
- art.Test988.run(Test988.java:344)
+ art.Test988.iter_fibonacci(Test988.java:269)
+ art.Test988$IterOp.applyAsInt(Test988.java:264)
+ art.Test988.doFibTest(Test988.java:402)
+ art.Test988.run(Test988.java:358)
<additional hidden frames>
>
....<= public java.lang.Throwable(java.lang.String) -> <null: null>
@@ -186,10 +186,10 @@ fibonacci(5)=5
...<= private void java.util.ArrayList.ensureExplicitCapacity(int) -> <null: null>
..<= private void java.util.ArrayList.ensureCapacityInternal(int) -> <null: null>
fibonacci(-19) -> java.lang.Error: Bad argument: -19 < 0
- art.Test988.iter_fibonacci(Test988.java:255)
- art.Test988$IterOp.applyAsInt(Test988.java:250)
- art.Test988.doFibTest(Test988.java:388)
- art.Test988.run(Test988.java:344)
+ art.Test988.iter_fibonacci(Test988.java:269)
+ art.Test988$IterOp.applyAsInt(Test988.java:264)
+ art.Test988.doFibTest(Test988.java:402)
+ art.Test988.run(Test988.java:358)
<additional hidden frames>
.<= public boolean java.util.ArrayList.add(java.lang.Object) -> <class java.lang.Boolean: true>
@@ -269,10 +269,10 @@ fibonacci(-19) -> java.lang.Error: Bad argument: -19 < 0
......=> private static java.lang.Object java.lang.Throwable.nativeFillInStackTrace()
......<= private static java.lang.Object java.lang.Throwable.nativeFillInStackTrace() -> <class [Ljava.lang.Object;: <non-deterministic>>
.....<= public synchronized java.lang.Throwable java.lang.Throwable.fillInStackTrace() -> <class java.lang.Error: java.lang.Error: Bad argument: -19 < 0
- art.Test988.fibonacci(Test988.java:277)
- art.Test988$RecurOp.applyAsInt(Test988.java:272)
- art.Test988.doFibTest(Test988.java:388)
- art.Test988.run(Test988.java:345)
+ art.Test988.fibonacci(Test988.java:291)
+ art.Test988$RecurOp.applyAsInt(Test988.java:286)
+ art.Test988.doFibTest(Test988.java:402)
+ art.Test988.run(Test988.java:359)
<additional hidden frames>
>
....<= public java.lang.Throwable(java.lang.String) -> <null: null>
@@ -289,10 +289,10 @@ fibonacci(-19) -> java.lang.Error: Bad argument: -19 < 0
...<= private void java.util.ArrayList.ensureExplicitCapacity(int) -> <null: null>
..<= private void java.util.ArrayList.ensureCapacityInternal(int) -> <null: null>
fibonacci(-19) -> java.lang.Error: Bad argument: -19 < 0
- art.Test988.fibonacci(Test988.java:277)
- art.Test988$RecurOp.applyAsInt(Test988.java:272)
- art.Test988.doFibTest(Test988.java:388)
- art.Test988.run(Test988.java:345)
+ art.Test988.fibonacci(Test988.java:291)
+ art.Test988$RecurOp.applyAsInt(Test988.java:286)
+ art.Test988.doFibTest(Test988.java:402)
+ art.Test988.run(Test988.java:359)
<additional hidden frames>
.<= public boolean java.util.ArrayList.add(java.lang.Object) -> <class java.lang.Boolean: true>
@@ -315,9 +315,9 @@ fibonacci(-19) -> java.lang.Error: Bad argument: -19 < 0
......<= private static java.lang.Object java.lang.Throwable.nativeFillInStackTrace() -> <class [Ljava.lang.Object;: <non-deterministic>>
.....<= public synchronized java.lang.Throwable java.lang.Throwable.fillInStackTrace() -> <class java.lang.Error: java.lang.Error: bad argument
art.Test988.nativeFibonacci(Native Method)
- art.Test988$NativeOp.applyAsInt(Test988.java:287)
- art.Test988.doFibTest(Test988.java:388)
- art.Test988.run(Test988.java:346)
+ art.Test988$NativeOp.applyAsInt(Test988.java:301)
+ art.Test988.doFibTest(Test988.java:402)
+ art.Test988.run(Test988.java:360)
<additional hidden frames>
>
....<= public java.lang.Throwable(java.lang.String) -> <null: null>
@@ -335,9 +335,9 @@ fibonacci(-19) -> java.lang.Error: Bad argument: -19 < 0
..<= private void java.util.ArrayList.ensureCapacityInternal(int) -> <null: null>
fibonacci(-19) -> java.lang.Error: bad argument
art.Test988.nativeFibonacci(Native Method)
- art.Test988$NativeOp.applyAsInt(Test988.java:287)
- art.Test988.doFibTest(Test988.java:388)
- art.Test988.run(Test988.java:346)
+ art.Test988$NativeOp.applyAsInt(Test988.java:301)
+ art.Test988.doFibTest(Test988.java:402)
+ art.Test988.run(Test988.java:360)
<additional hidden frames>
.<= public boolean java.util.ArrayList.add(java.lang.Object) -> <class java.lang.Boolean: true>
diff --git a/test/988-method-trace/src/art/Test988.java b/test/988-method-trace/src/art/Test988.java
index 075e075c0f..9c8ce4a8bd 100644
--- a/test/988-method-trace/src/art/Test988.java
+++ b/test/988-method-trace/src/art/Test988.java
@@ -23,29 +23,43 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.function.IntUnaryOperator;
+import java.util.function.Predicate;
public class Test988 {
// Methods with non-deterministic output that should not be printed.
- static Set<Method> NON_DETERMINISTIC_OUTPUT_METHODS = new HashSet<>();
- static Set<Method> NON_DETERMINISTIC_OUTPUT_TYPE_METHODS = new HashSet<>();
+ static List<Predicate<Executable>> NON_DETERMINISTIC_OUTPUT_METHODS = new ArrayList<>();
+ static List<Predicate<Executable>> NON_DETERMINISTIC_OUTPUT_TYPE_METHODS = new ArrayList<>();
static List<Class<?>> NON_DETERMINISTIC_TYPE_NAMES = new ArrayList<>();
+ static Predicate<Executable> IS_NON_DETERMINISTIC_OUTPUT =
+ (x) -> NON_DETERMINISTIC_OUTPUT_METHODS.stream().anyMatch((pred) -> pred.test(x));
+ static Predicate<Executable> IS_NON_DETERMINISTIC_OUTPUT_TYPE =
+ (x) -> NON_DETERMINISTIC_OUTPUT_TYPE_METHODS.stream().anyMatch((pred) -> pred.test(x));
+
+ public static final Predicate<Executable> EqPred(Executable m) {
+ return (Executable n) -> n.equals(m);
+ }
+
static {
+ // Throwable.nativeFillInStackTrace is only on android and hiddenapi so we
+ // should avoid trying to find it at all.
+ NON_DETERMINISTIC_OUTPUT_METHODS.add(
+ (Executable ex) -> {
+ return ex.getDeclaringClass().equals(Throwable.class)
+ && ex.getName().equals("nativeFillInStackTrace");
+ });
try {
NON_DETERMINISTIC_OUTPUT_METHODS.add(
- Throwable.class.getDeclaredMethod("nativeFillInStackTrace"));
- } catch (Exception e) {}
- try {
- NON_DETERMINISTIC_OUTPUT_METHODS.add(Thread.class.getDeclaredMethod("currentThread"));
- NON_DETERMINISTIC_OUTPUT_TYPE_METHODS.add(Thread.class.getDeclaredMethod("currentThread"));
+ EqPred(Thread.class.getDeclaredMethod("currentThread")));
+ NON_DETERMINISTIC_OUTPUT_TYPE_METHODS.add(
+ EqPred(Thread.class.getDeclaredMethod("currentThread")));
} catch (Exception e) {}
try {
NON_DETERMINISTIC_TYPE_NAMES.add(
@@ -160,7 +174,7 @@ public class Test988 {
@Override
public void Print() {
String print;
- if (NON_DETERMINISTIC_OUTPUT_METHODS.contains(m)) {
+ if (IS_NON_DETERMINISTIC_OUTPUT.test(m)) {
print = "<non-deterministic>";
} else {
print = genericToString(val);
@@ -175,7 +189,7 @@ public class Test988 {
} else if (NON_DETERMINISTIC_TYPE_NAMES.contains(klass)) {
klass_print = "<non-deterministic-class " +
NON_DETERMINISTIC_TYPE_NAMES.indexOf(klass) + ">";
- } else if (NON_DETERMINISTIC_OUTPUT_TYPE_METHODS.contains(m)) {
+ } else if (IS_NON_DETERMINISTIC_OUTPUT_TYPE.test(m)) {
klass_print = "<non-deterministic>";
} else {
klass_print = klass.toString();