summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-05-13 13:13:24 -0700
committerMathieu Chartier <mathieuc@google.com>2015-05-13 14:06:27 -0700
commit3beb245da9392818e3154d47593f82cf0ef69aac (patch)
tree3e43a6fb9dedf1a1c7f868cf5148ab4b579e25b3 /test
parente8ff50df01c89e1b5264a5a900cfebdde87a9b44 (diff)
downloadart-3beb245da9392818e3154d47593f82cf0ef69aac.zip
art-3beb245da9392818e3154d47593f82cf0ef69aac.tar.gz
art-3beb245da9392818e3154d47593f82cf0ef69aac.tar.bz2
Also print class for NoSuchFieldException
Example message: Caused by: java.lang.NoSuchFieldException: No field value in class Ljava/lang/String; Added test. Bug: 20881251 Change-Id: I4043cbf26c3077952b6c151da0d0edd980da26b1
Diffstat (limited to 'test')
-rw-r--r--test/046-reflect/src/Main.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/046-reflect/src/Main.java b/test/046-reflect/src/Main.java
index 59f7001..0d8e576 100644
--- a/test/046-reflect/src/Main.java
+++ b/test/046-reflect/src/Main.java
@@ -233,6 +233,20 @@ public class Main {
field.set(instance, null);
/*
+ * Try getDeclaredField on a non-existant field.
+ */
+ try {
+ field = target.getDeclaredField("nonExistant");
+ System.out.println("ERROR: Expected NoSuchFieldException");
+ } catch (NoSuchFieldException nsfe) {
+ String msg = nsfe.getMessage();
+ if (!msg.contains("Target;")) {
+ System.out.println(" NoSuchFieldException '" + msg +
+ "' didn't contain class");
+ }
+ }
+
+ /*
* Do some stuff with long.
*/
long longVal;
@@ -868,4 +882,4 @@ class OtherClass {
System.out.println(e);
}
}
-} \ No newline at end of file
+}