aboutsummaryrefslogtreecommitdiffstats
path: root/dcevm/src
diff options
context:
space:
mode:
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);
id='n77' href='#n77'>77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>vaadin-liferay-integration</artifactId>
    <packaging>jar</packaging>
    <url>https://vaadin.com/</url>
    <description>Liferay 7+ OSGi portlet support</description>

    <parent>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-root</artifactId>
        <version>8.0-SNAPSHOT</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <liferay.version>7.0.2-ga3</liferay.version>
    </properties>

    <dependencies>

        <!-- OSGi Dependencies -->
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.annotation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.cmpn</artifactId>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-shared</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-server</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-push</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- Liferay dependencies -->

        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>checkstyle</goal>
                        </goals>
                        <phase>process-sources</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
            </plugin>
            <!-- This is required to copy the bnd generated MANIFEST.MF to the jar.
                https://issues.apache.org/jira/browse/MJAR-193 is supposed to address this
                issue, but at the time of writing this the configuration is necessary. Check
                https://github.com/bndtools/bnd/tree/master/maven/bnd-maven-plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                        <index>false</index>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>