summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2011-12-16 15:25:15 -0800
committerElliott Hughes <enh@google.com>2011-12-16 15:25:15 -0800
commita5c0c21ac37756698374d233210cfd5b8e8b4436 (patch)
treed628a75b8b60d1580d00cfb2d9bd3c059564162f
parentc3b77c7c2971124cbf3b2d9da64e7a8a9a649f2e (diff)
downloadart-a5c0c21ac37756698374d233210cfd5b8e8b4436.tar.gz
art-a5c0c21ac37756698374d233210cfd5b8e8b4436.tar.bz2
art-a5c0c21ac37756698374d233210cfd5b8e8b4436.zip
Ensure that 055 checks we don't cheat on the library side...
Class.isEnum is expensive, but we need to make sure that it's cached rather than skipped. Change-Id: I130c683e3b48ccb2fd93dfca8e6ae3e73c8393f6
-rw-r--r--test/055-enum-performance/src/Main.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/055-enum-performance/src/Main.java b/test/055-enum-performance/src/Main.java
index 43f45f1a8b..d5903af697 100644
--- a/test/055-enum-performance/src/Main.java
+++ b/test/055-enum-performance/src/Main.java
@@ -1,10 +1,30 @@
import otherpackage.OtherPackagePublicEnum;
+import java.lang.reflect.*;
+
public class Main {
/** used by {@link #basisCall} */
static private int basisTestValue = 12;
static public void main(String[] args) throws Exception {
+ try {
+ Class<?> enumClass = Enum.class;
+ Method enumValueOf = null;
+ for (Method m : enumClass.getDeclaredMethods()) {
+ if (m.getName().equals("valueOf")) {
+ enumValueOf = m;
+ break;
+ }
+ }
+ enumValueOf.invoke(null, String.class, "blah");
+ throw new AssertionError();
+ } catch (InvocationTargetException expected) {
+ IllegalArgumentException iae = (IllegalArgumentException) expected.getCause();
+ if (!iae.getMessage().equals("class java.lang.String is not an enum type")) {
+ throw new AssertionError();
+ }
+ }
+
boolean timing = (args.length >= 1) && args[0].equals("--timing");
run(timing);
}