aboutsummaryrefslogtreecommitdiffstats
path: root/dcevm/src
diff options
context:
space:
mode:
authorIvan Dubrov <idubrov@guidewire.com>2015-07-09 23:19:55 -0700
committerIvan Dubrov <idubrov@guidewire.com>2015-07-10 10:50:54 -0700
commit3f9d18a4058fbe6958a6b7ec827af221e84f9792 (patch)
treee160fa2853c9af85b1fbcec945e7b6b32e75649b /dcevm/src
parent4d67683d0d7a5af417efa8f0d4da7d4b34d61863 (diff)
downloaddcevm-3f9d18a4058fbe6958a6b7ec827af221e84f9792.tar.gz
dcevm-3f9d18a4058fbe6958a6b7ec827af221e84f9792.zip
Support for Java7u79feature/jdk7u79-support
Diffstat (limited to 'dcevm/src')
-rw-r--r--dcevm/src/test/java7/com/github/dcevm/test/methods/MethodHandleTest.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/dcevm/src/test/java7/com/github/dcevm/test/methods/MethodHandleTest.java b/dcevm/src/test/java7/com/github/dcevm/test/methods/MethodHandleTest.java
index 1efbf0d3..53f4a256 100644
--- a/dcevm/src/test/java7/com/github/dcevm/test/methods/MethodHandleTest.java
+++ b/dcevm/src/test/java7/com/github/dcevm/test/methods/MethodHandleTest.java
@@ -46,6 +46,11 @@ public class MethodHandleTest {
// Version 0
public static class A {
+ public int field;
+ public A(int value) {
+ field = value;
+ }
+
public int method() {
return 1;
}
@@ -65,6 +70,11 @@ public class MethodHandleTest {
// Version 1
public static class A___1 {
+ public int field;
+ public A___1(int value) {
+ field = value * 10;
+ }
+
public int method() {
return 2;
}
@@ -95,7 +105,7 @@ public class MethodHandleTest {
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle handle = lookup.findVirtual(A.class, "method", MethodType.methodType(int.class));
- A a = new A();
+ A a = new A(3);
assertEquals(1, (int) handle.invokeExact(a));
__toVersion__(1);
@@ -114,7 +124,7 @@ public class MethodHandleTest {
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle handle = lookup.findVirtual(A.class, "method", MethodType.methodType(int.class));
- A a = new A();
+ A a = new A(3);
MethodHandle boundHandle = handle.bindTo(a);
assertEquals(1, (int) boundHandle.invokeExact());
@@ -145,6 +155,24 @@ public class MethodHandleTest {
}
@Test
+ public void testConstructorMethodHandleUpdated() throws Throwable {
+
+ assert __version__() == 0;
+
+ MethodHandles.Lookup lookup = MethodHandles.lookup();
+ MethodHandle handle = lookup.findConstructor(A.class, MethodType.methodType(void.class, int.class));
+
+ assertEquals(12, ((A) handle.invoke(12)).field);
+
+ __toVersion__(1);
+
+ assertEquals(120, ((A) handle.invoke(12)).field);
+
+ __toVersion__(0);
+ assert __version__() == 0;
+ }
+
+ @Test
public void testComplexMethodHandleUpdated() throws Throwable {
assert __version__() == 0;
@@ -154,7 +182,7 @@ public class MethodHandleTest {
MethodHandle filter = lookup.findVirtual(A.class, "filter", MethodType.methodType(int.class, int.class));
MethodHandle staticFilter = lookup.findStatic(A.class, "staticFilter", MethodType.methodType(int.class, int.class));
- A a = new A();
+ A a = new A(3);
MethodHandle boundFilter = filter.bindTo(a);
handle = MethodHandles.filterReturnValue(handle, staticFilter);
handle = MethodHandles.filterReturnValue(handle, boundFilter);