diff options
author | Mathieu Chartier <mathieuc@google.com> | 2015-03-29 18:27:50 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2015-03-29 18:54:20 -0700 |
commit | ca239af73e512df5eeb80fe6c09c2ca614649e06 (patch) | |
tree | cee8641c42385f40b567c686cd5053fde152a088 /test | |
parent | f381645a336f7092ab6f5900c0a2cf183a9dbdf7 (diff) | |
download | art-ca239af73e512df5eeb80fe6c09c2ca614649e06.zip art-ca239af73e512df5eeb80fe6c09c2ca614649e06.tar.gz art-ca239af73e512df5eeb80fe6c09c2ca614649e06.tar.bz2 |
Fix some reflection errors
Fixed incorrectly using 2nd frame instead of 1st in VerifyAccess.
Added regression test to ART. Fixed broken setShort,
getDeclaredFieldInternal.
Change-Id: I4b21d52d998cb768fe9503b8bccec506b7b972e5
Diffstat (limited to 'test')
-rw-r--r-- | test/046-reflect/src/Main.java | 65 |
1 files changed, 42 insertions, 23 deletions
diff --git a/test/046-reflect/src/Main.java b/test/046-reflect/src/Main.java index 5c6ca13..59f7001 100644 --- a/test/046-reflect/src/Main.java +++ b/test/046-reflect/src/Main.java @@ -720,6 +720,10 @@ public class Main { } } + static void checkPrivateFieldAccess() { + (new OtherClass()).test(); + } + public static void main(String[] args) throws Exception { Main test = new Main(); test.run(); @@ -733,6 +737,7 @@ public class Main { checkUnique(); checkParametrizedTypeEqualsAndHashCode(); checkGenericArrayTypeEqualsAndHashCode(); + checkPrivateFieldAccess(); } } @@ -804,41 +809,41 @@ class Target extends SuperTarget { } class FieldNoisyInit { - static { - System.out.println("FieldNoisyInit is initializing"); - //Throwable th = new Throwable(); - //th.printStackTrace(); - } + static { + System.out.println("FieldNoisyInit is initializing"); + //Throwable th = new Throwable(); + //th.printStackTrace(); + } } class FieldNoisyInitUser { - static { - System.out.println("FieldNoisyInitUser is initializing"); - } - public static int staticField; - public static FieldNoisyInit noisy; + static { + System.out.println("FieldNoisyInitUser is initializing"); + } + public static int staticField; + public static FieldNoisyInit noisy; } class MethodNoisyInit { - static { - System.out.println("MethodNoisyInit is initializing"); - //Throwable th = new Throwable(); - //th.printStackTrace(); - } + static { + System.out.println("MethodNoisyInit is initializing"); + //Throwable th = new Throwable(); + //th.printStackTrace(); + } } class MethodNoisyInitUser { - static { - System.out.println("MethodNoisyInitUser is initializing"); - } - public static void staticMethod() {} - public void createMethodNoisyInit(MethodNoisyInit ni) {} + static { + System.out.println("MethodNoisyInitUser is initializing"); + } + public static void staticMethod() {} + public void createMethodNoisyInit(MethodNoisyInit ni) {} } class Thrower { - public Thrower() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } + public Thrower() throws UnsupportedOperationException { + throw new UnsupportedOperationException(); + } } class ParametrizedTypeTest { @@ -850,3 +855,17 @@ class GenericArrayTypeTest<T> { public void aMethod(T[] names) {} public void aMethodIdentical(T[] names) {} } + +class OtherClass { + private static final long LONG = 1234; + public void test() { + try { + Field field = getClass().getDeclaredField("LONG"); + if (1234 != field.getLong(null)) { + System.out.println("ERROR: values don't match"); + } + } catch (Exception e) { + System.out.println(e); + } + } +}
\ No newline at end of file |