meth: update test project
authorjrose
Fri Apr 03 02:53:51 2009 -0700 (11 months ago)
changeset 403c642244cfb8
parent 39ef70a7045609
child 415c5527e09ffe
meth: update test project
meth.proj.patch
series
--- a/meth.proj.patch Fri Apr 03 00:59:13 2009 -0700
+++ b/meth.proj.patch Fri Apr 03 02:53:51 2009 -0700
@@ -2,7 +2,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/src/share/projects/meth/README.txt
-@@ -0,0 +1,200 @@
+@@ -0,0 +1,203 @@
+Standalone NetBeans project of JSR 292 RI
+
+(Not yet merged with the JDK; use -Xbootclasspath.)
@@ -21,18 +21,21 @@ new file mode 100644
+ export mhproj="$HOME/Projects/MethodHandle" #(pwd -P)
+ export acproj="$HOME/Projects/AnonymousClass" #(cd ../AnonymousClass; pwd -P)
+ export cpath="$acproj/dist/AnonymousClass.jar:$mhproj/build/classes:$mhproj/build/test/classes:$junit"
-+ gamma -XX:+MethodHandleSupport -Xbootclasspath/p:"$cpath" jdk.java.dyn.MethodHandleBytecodeTest
-+
-+Simpler (currently broken) demo:
-+ gamma -XX:+MethodHandleSupport -Xbootclasspath/p:"$cpath" -cp "$mhproj"/dist/MethodHandle.jar jdk.java.dyn.MethodHandleDemo
++ gamma -XX:+EnableMethodHandles -Xbootclasspath/p:"$cpath" jdk.java.dyn.MethodHandleBytecodeTest
++
++Simpler MH demo:
++ gamma -XX:+EnableMethodHandles -Xbootclasspath/p:"$cpath" jdk.java.dyn.MethodHandleDemo
++
++Simpler invokedynamic demo:
++ gamma -XX:+EnableInvokeDynamic -Xbootclasspath/p:"$cpath" jdk.java.dyn.Hello Moe Larry Curly
+
+Using JUnit 4:
-+ gamma -XX:+MethodHandleSupport -Xbootclasspath/p:"$cpath" org.junit.runner.JUnitCore jdk.java.dyn.MethodHandlesTest
++ gamma -XX:+EnableMethodHandles -Xbootclasspath/p:"$cpath" org.junit.runner.JUnitCore jdk.java.dyn.MethodHandlesTest
+
+Current output:
+
+-------- -------- -------- --------
-+VM option '+MethodHandleSupport'
++VM option '+EnableMethodHandles'
+JUnit version 4.1
+.findStatic
+findStatic class jdk.java.dyn.MethodHandlesTest$Example.s0/()void => jdk.java.dyn.MethodHandlesTest$Example.s0()void
@@ -217,14 +220,14 @@ new file mode 100755
+export akproj="$HOME/Projects/AnonymousClass"
+export mhproj="$HOME/Projects/MethodHandle"
+export cpath="$mhproj/build/classes:$mhproj/build/test/classes:$junit:$akproj/build/classes:"
-+java -XX:+MethodHandles -Xbootclasspath/p:"$cpath" jdk.java.dyn.MethodHandleDemo
++java -XX:+EnableMethodHandles -Xbootclasspath/p:"$cpath" jdk.java.dyn.MethodHandleDemo
+java -XX:+MethodHandles -Xbootclasspath/p:"$cpath" org.junit.runner.JUnitCore jdk.java.dyn.MethodHandlesTest
\ No newline at end of file
diff --git a/src/share/projects/meth/build.xml b/src/share/projects/meth/build.xml
new file mode 100644
--- /dev/null
+++ b/src/share/projects/meth/build.xml
-@@ -0,0 +1,104 @@
+@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
@@ -328,15 +331,23 @@ new file mode 100644
+ nbproject/build-impl.xml file.
+
+ -->
++
++<!--- hack to print props -->
++ <target depends="init" name="show-config">
++ <echoproperties regex="^(run|platform|config)(\.|$)"/>
++ </target>
++
+</project>
diff --git a/src/share/projects/meth/nbproject/project.properties b/src/share/projects/meth/nbproject/project.properties
new file mode 100644
--- /dev/null
+++ b/src/share/projects/meth/nbproject/project.properties
-@@ -0,0 +1,80 @@
+@@ -0,0 +1,89 @@
+application.args=
+application.title=MethodHandle
+application.vendor=jrose
++auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
++auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
+auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
@@ -356,6 +367,7 @@ new file mode 100644
+dist.jar=${dist.dir}/MethodHandle.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=java/dyn/Anonymous*.java,java/dyn/*ConstantPool*.java,jdk/java/dyn/Anonymous*.java,links/**
++file.reference.test-classes=build/test/classes
+includes=java/dyn/**,jdk/java/dyn/**,impl/java/dyn/**
+#includes=**
+jar.compress=true
@@ -363,9 +375,11 @@ new file mode 100644
+ ${reference.AnonymousClass.jar}
+# Space-separated list of extra javac options
+javac.compilerargs=-Xlint:unchecked -J-Xbootclasspath/p:${reference.langtools-javac.jar} -XDinvokedynamic
++# with full JDK7X could be:
++#javac.compilerargs=-Xlint:unchecked -XDinvokedynamic
+javac.deprecation=false
-+javac.source=1.5
-+javac.target=1.5
++javac.source=1.6
++javac.target=1.6
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
@@ -389,7 +403,7 @@ new file mode 100644
+jnlp.signed=false
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
-+platform.active=JDK_1.6
++platform.active=JDK_7X
+# ref http://ant.apache.org/manual/CoreTasks/javac.html (OpenJDK Notes)
+project.langtools=../langtools
+reference.langtools-javac.jar=${project.langtools}/dist/bootstrap/lib/javac.jar
@@ -397,17 +411,21 @@ new file mode 100644
+reference.AnonymousClass.jar=${project.AnonymousClass}/dist/AnonymousClass.jar
+run.classpath=\
+ ${javac.classpath}:\
-+ ${build.classes.dir}
-+run.jvmargs=-Xbootclasspath/a:"${build.classes.dir}:${reference.AnonymousClass.jar}:${libs.junit.classpath}"
++ ${build.classes.dir}:\
++ ${reference.AnonymousClass.jar}:\
++ ${file.reference.test-classes}
+# Space-separated list of JVM arguments used when running the project
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
+# or test-sys-prop.name=value to set system properties for unit tests):
++run.jvmargs=${config.run.jvmargs} -Xbootclasspath/p:"${run.classpath}:${libs.junit_4.classpath}"
++#manual hack: override ${config.run.jvmargs} in ${config}.properties
++config.run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+# One or both refs probably need fixing:
-+file.reference.projects=${env.HOME}/Projects
++file.reference.projects=${user.home}/Projects
+file.reference.davinci.sources.jdk=${file.reference.projects}/davinci/sources/jdk
+src.src.dir=${file.reference.davinci.sources.jdk}/src/share/classes
+src.src2.dir=src
@@ -447,6 +465,104 @@ new file mode 100644
+ </references>
+ </configuration>
+</project>
+diff --git a/src/share/projects/meth/test/jdk/java/dyn/Hello.java b/src/share/projects/meth/test/jdk/java/dyn/Hello.java
+new file mode 100644
+--- /dev/null
++++ b/src/share/projects/meth/test/jdk/java/dyn/Hello.java
+@@ -0,0 +1,93 @@
++/*
++ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/*
++ * @test
++ * @bug 6754038
++ * @summary Hello world, JSR 292 style
++ * @author jrose
++ *
++ * Standalone testing:
++ * <code>
++ * $ cd $MY_REPO_DIR/langtools
++ * $ (cd make; make)
++ * $ .../langtools/dist/bootstrap/bin/javac -d dist .../Hello.java
++ * $ javap -c -classpath dist jdk.java.dyn.Hello
++ * </code>
++ *
++ * @run Hello.java
++ */
++
++package jdk.java.dyn;
++import org.junit.*;
++
++import java.dyn.*;
++
++public class Hello {
++ @Test public void test() { main("Fred"); }
++
++ public static void main(String... av) {
++ if (av.length == 0) av = new String[] { "world" };
++ greeter(av[0] + " (from a statically linked call site)");
++ greete5(av[0] + " (from a statically linked call site)");
++ for (String whom : av) {
++ greeter.<void>invoke(whom); // strongly typed direct call
++ greete5.invoke(whom); // strongly typed direct call
++ // previous line generates invokevirtual MethodHandle.invoke(String)void
++ Dynamic x = whom;
++ x.hail(); // weakly typed invokedynamic
++ // previous line generates invokedynamic MethodHandle.invoke(Dynamic)Dynamic
++ }
++ System.out.println("Last call:");
++ try {
++ Dynamic loser = 911;
++ loser.hail(); // should fail in the adapter (Dynamic -> String cast)
++ } catch (RuntimeException ee) {
++ System.out.println("Caught the bullet: "+ee);
++ }
++ System.out.println("Bye!");
++ }
++
++ static void greeter(String x) { System.out.println("Hello, "+x); }
++ // intentionally pun between the method and its reified handle:
++ static MethodHandle greeter
++ = MethodHandles.findStatic(Hello.class, "greeter",
++ MethodType.make(void.class, String.class));
++ //might be nice: MethodHandle greeter = Hello#greeter;
++
++ static Dynamic greete5(String x) { System.out.println("H311o, "+x); return null; }
++ static MethodHandle greete5
++ = MethodHandles.findStatic(Hello.class, "greete5",
++ MethodType.make(Dynamic.class, String.class));
++ // Set up a class-local bootstrap method.
++ static { Linkage.registerBootstrapMethod("bootstrapDynamic"); }
++ private static Object bootstrapDynamic(CallSite site, Object... args) {
++ assert(args.length == 1 && site.name() == "hail"); // in lieu of MOP
++ System.out.println("set site target to "+greete5);
++ MethodHandle target = MethodHandles.convertArguments(greete5, site.type());
++ System.out.println(" with conversions: "+target);
++ site.setTarget(target);
++ System.out.println("calling the slow path; this should be the last time!");
++ return MethodHandles.invoke(target, args);
++ }
++}
diff --git a/src/share/projects/meth/test/jdk/java/dyn/InvokeDynamicDemo.java b/src/share/projects/meth/test/jdk/java/dyn/InvokeDynamicDemo.java
new file mode 100644
--- /dev/null
@@ -1767,13 +1883,13 @@ new file mode 100644
+ }
+
+ @Test @Ignore("unimplemented")
-+ public void testCheckArguments() {
++ public void testCombineArguments() {
+ System.out.println("checkArguments");
+ MethodHandle target = null;
+ MethodHandle checker = null;
+ int pos = 0;
+ MethodHandle expResult = null;
-+ MethodHandle result = MethodHandles.checkArguments(target, checker, pos);
++ MethodHandle result = MethodHandles.combineArguments(target, checker, pos);
+ assertEquals(expResult, result);
+ fail("The test case is a prototype.");
+ }
@@ -1784,7 +1900,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/src/share/projects/meth/test/jdk/java/dyn/MethodTypeTest.java
-@@ -0,0 +1,424 @@
+@@ -0,0 +1,412 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -1927,7 +2043,7 @@ new file mode 100644
+ @Test
+ public void testMake_Method() {
+ System.out.println("make (via MemberName.getMethodType)");
-+ MethodType expResult = MethodType.make(int.class, String.class, String.class);
++ MethodType expResult = MethodType.make(int.class, String.class);
+ MemberName name = new MemberName(compareTo);
+ MethodType result = name.getMethodType();
+ assertEquals(expResult, result);
@@ -2195,17 +2311,5 @@ new file mode 100644
+ }
+ }
+
-+ @Test
-+ public void testToString_va() {
-+ System.out.println("toString");
-+ MethodType instance = MethodType.make(Object.class, int[].class);
-+ for (int i = 0; i <= 1; i++) {
-+ boolean va = (i != 0);
-+ String expResult = "(int"+(va?"...":"[]")+")java.lang.Object";
-+ String result = instance.changeVarArgs(va).toString();
-+ System.out.println(result);
-+ assertEquals(expResult, result);
-+ }
-+ }
+
+}
--- a/series Fri Apr 03 00:59:13 2009 -0700
+++ b/series Fri Apr 03 02:53:51 2009 -0700
@@ -15,3 +15,5 @@ annot.patch #-/annot #+d1605a
#inti.patch #-/inti #+d1605aabd0a1 #+jdk7-b30 #-buildable
callcc.patch #-/callcc #+d1605aabd0a1 #+jdk7-b30 #-testable
tailc.patch #-/tailc #+a268411445d9 #+jdk7-b45 #-testable
+
+meth.proj.patch #-/meth #+projects