meth: update test project to match sources
authorjrose
Tue Aug 26 03:01:02 2008 -0700 (15 months ago)
changeset 18b34dace3af6f
parent 1715cb6a10af43
child 1916ad46462338
meth: update test project to match sources
meth.proj.patch
--- a/meth.proj.patch Tue Aug 26 03:00:50 2008 -0700
+++ b/meth.proj.patch Tue Aug 26 03:01:02 2008 -0700
@@ -2,7 +2,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/src/share/projects/MethodHandle/README.txt
-@@ -0,0 +1,21 @@
+@@ -0,0 +1,22 @@
+Standalone NetBeans project of JSR 292 RI
+
+(Not yet merged with the JDK; use -Xbootclasspath.)
@@ -19,8 +19,9 @@ new file mode 100644
+ #junit="$NetBeansResources/NetBeans/java2/modules/ext/junit-3.8.2.jar"
+ export junit=$HOME/env/jars/junit-3.8.2.jar
+ export mhproj="$HOME/Projects/MethodHandle" #(pwd -P)
-+ export cpath="$mhproj/build/classes:$mhproj/build/test/classes:$junit"
-+ gamma -Xbootclasspath/a:"$cpath" jsr292.dyn.MethodHandleBytecodeTest
++ 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:+{MethodHandles,InvokeDynamic} -Xbootclasspath/p:"$cpath" jdk.java.dyn.MethodHandleBytecodeTest
+
+Simpler (currently broken) demo:
+ gamma -Xbootclasspath/a:dist/MethodHandle.jar MethodHandleDemo
@@ -172,7 +173,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/src/share/projects/MethodHandle/nbproject/project.properties
-@@ -0,0 +1,75 @@
+@@ -0,0 +1,74 @@
+application.args=
+application.title=MethodHandle
+application.vendor=jrose
@@ -194,8 +195,8 @@ new file mode 100644
+dist.dir=dist
+dist.jar=${dist.dir}/MethodHandle.jar
+dist.javadoc.dir=${dist.dir}/javadoc
-+excludes=
-+includes=java/dyn/**,jdk/java/dyn/**,sun/misc/Unsafe.java
++excludes=java/dyn/Anonymous*.java,java/dyn/*ConstantPool*.java,jdk/java/dyn/Anonymous*.java
++includes=java/dyn/**,jdk/java/dyn/**
+#includes=**
+jar.compress=false
+javac.classpath=\
@@ -233,6 +234,7 @@ new file mode 100644
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
++run.jvmargs=-Xbootclasspath/a:"${build.classes.dir}:${reference.AnonymousClass.jar}:${libs.junit.classpath}"
+# 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):
@@ -242,12 +244,10 @@ new file mode 100644
+source.encoding=UTF-8
+# One or both refs probably need fixing:
+file.reference.projects=${env.HOME}/Projects
-+file.reference.davinci.sources.jdk=${file.reference.projects}/davinci/sources/jdk
-+src.classes.dir=${file.reference.davinci.sources.jdk}/src/share/classes
++#file.reference.davinci.sources.jdk=${file.reference.projects}/davinci/sources/jdk
++src.src.dir=src
+test.src.dir=test
+project.license=openjdk
-+##platform.bootclasspath=${build.classes.dir}:${libs.junit.classpath}
-+run.jvmargs=-Xbootclasspath/a:"${build.classes.dir}:${reference.AnonymousClass.jar}:${libs.junit.classpath}"
diff --git a/src/share/projects/MethodHandle/nbproject/project.xml b/src/share/projects/MethodHandle/nbproject/project.xml
new file mode 100644
--- /dev/null
@@ -262,7 +262,7 @@ new file mode 100644
+ <minimum-ant-version>1.6.5</minimum-ant-version>
+ <explicit-platform explicit-source-supported="true"/>
+ <source-roots>
-+ <root id="src.classes.dir" name="Source Packages"/>
++ <root id="src.src.dir" name="Source Packages"/>
+ </source-roots>
+ <test-roots>
+ <root id="test.src.dir"/>
@@ -284,7 +284,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/src/share/projects/MethodHandle/test/jdk/java/dyn/MethodHandleBytecodeTest.java
-@@ -0,0 +1,87 @@
+@@ -0,0 +1,83 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -313,40 +313,35 @@ new file mode 100644
+package jdk.java.dyn;
+
+import java.dyn.*;
-+import java.dyn.MethodHandles;
-+import java.dyn.MethodType;
-+import java.dyn.MethodHandle;
-+import java.dyn.util.MethodHandleInvoker;
++import java.dyn.util.*;
+import java.lang.reflect.Method;
++import junit.framework.JUnit4TestAdapter;
+import junit.framework.TestCase;
++import org.junit.*;
++import static org.junit.Assert.*;
+
+/**
+ *
+ * @author jrose
+ */
-+public class MethodHandleBytecodeTest extends TestCase {
-+ public MethodHandleBytecodeTest(String testName) {
-+ super(testName);
-+ }
-+
++public class MethodHandleBytecodeTest {
+ private Method toString, compareTo, getBytes;
+
-+ @Override
-+ protected void setUp() throws Exception {
-+ super.setUp();
++ @Before
++ public void setUp() throws Exception {
+ toString = Object.class.getDeclaredMethod("toString");
+ compareTo = Comparable.class.getDeclaredMethod("compareTo", Object.class);
+ getBytes = String.class.getDeclaredMethod("getBytes", String.class);
+ }
+
-+ @Override
-+ protected void tearDown() throws Exception {
-+ super.tearDown();
++ @After
++ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test make invoke pseudo-method, make class MethodHandle.
+ */
++ @Test
+ public void testToString() {
+ System.out.println("invoke toString");
+ MethodHandle instance = MethodHandles.findVirtual(
@@ -364,30 +359,47 @@ new file mode 100644
+ return (String) inv.invoke_LL(mh, obj);
+ }
+
-+ // Extra entry point for manual invocation. Use as follows:
-+ //junit="$NetBeansResources/NetBeans/java2/modules/ext/junit-3.8.2.jar"
-+ //cpath="build/classes:build/test/classes:$junit"
-+ //java -cp "$cpath" jsr292.dyn.MethodHandleBytecodeTest
++ // Extra entry point for standalone use. Use as follows:
++ //junit="$NetBeansResources/NetBeans/java2/modules/ext/junit-4.1.jar"
++ //anonk="../AnonymousClass/dist/AnonymousClass.jar"
++ //cpath="$anonk:build/classes:build/test/classes:$junit"
++ //java -Xbootclasspath/p:"$cpath" jdk.java.dyn.MethodHandleBytecodeTest
+ public static void main(String... av) throws Throwable {
-+ new MethodHandleBytecodeTest("testToString").runBare();
++ new JUnit4TestAdapter(MethodHandleBytecodeTest.class).run(null);
+ }
+}
diff --git a/src/share/projects/MethodHandle/test/jdk/java/dyn/MethodHandleDemo.java b/src/share/projects/MethodHandle/test/jdk/java/dyn/MethodHandleDemo.java
new file mode 100644
--- /dev/null
+++ b/src/share/projects/MethodHandle/test/jdk/java/dyn/MethodHandleDemo.java
-@@ -0,0 +1,113 @@
+@@ -0,0 +1,122 @@
++/*
++ * Copyright 2008 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. Sun designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Sun in the LICENSE file that accompanied this code.
++ *
++ * 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.
++ */
++
+package jdk.java.dyn;
+
-+//
-+// MethodHandleDemo.java
-+// MethodHandle
-+//
-+// Created by John Rose on 6/12/07.
-+// Copyright 2007 __MyCompanyName__. All rights reserved.
-+//
-+
-+import com.sun.source.tree.MethodInvocationTree;
+import java.dyn.*;
+import java.dyn.util.MethodHandleInvoker;
+
@@ -482,19 +494,12 @@ new file mode 100644
+ public void testMain() {
+ main();
+ }
-+ @BeforeClass
-+ public static void setUpClass() throws Exception {
-+ }
-+ @AfterClass
-+ public static void tearDownClass() throws Exception {
-+ }
-+
+}
diff --git a/src/share/projects/MethodHandle/test/jdk/java/dyn/MethodTypeTest.java b/src/share/projects/MethodHandle/test/jdk/java/dyn/MethodTypeTest.java
new file mode 100644
--- /dev/null
+++ b/src/share/projects/MethodHandle/test/jdk/java/dyn/MethodTypeTest.java
-@@ -0,0 +1,401 @@
+@@ -0,0 +1,422 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -527,17 +532,15 @@ new file mode 100644
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
-+import junit.framework.TestCase;
++
++import org.junit.*;
++import static org.junit.Assert.*;
+
+/**
+ *
+ * @author jrose
+ */
-+public class MethodTypeTest extends TestCase {
-+
-+ public MethodTypeTest(String testName) {
-+ super(testName);
-+ }
++public class MethodTypeTest {
+
+ private Class<?> rtype;
+ private Class<?>[] ptypes;
@@ -547,9 +550,8 @@ new file mode 100644
+ private MethodType mt_VIO, mt_IO2, mt_OOI, mt_IOI, mt_VIS;
+ private Method compareTo;
+
-+ @Override
-+ protected void setUp() throws Exception {
-+ super.setUp();
++ @Before
++ public void setUp() throws Exception {
+ rtype = void.class;
+ ptypes = new Class<?>[] { int.class, String.class };
+
@@ -578,14 +580,14 @@ new file mode 100644
+
+ }
+
-+ @Override
-+ protected void tearDown() throws Exception {
-+ super.tearDown();
++ @After
++ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test of make method, of class MethodType.
+ */
++ @Test
+ public void testMake_Class_ClassArr() {
+ System.out.println("make (from type array)");
+ MethodType result = MethodType.make(rtype, ptypes);
@@ -595,6 +597,7 @@ new file mode 100644
+ /**
+ * Test of make method, of class MethodType.
+ */
++ @Test
+ public void testMake_Class_List() {
+ System.out.println("make (from type list)");
+ MethodType result = MethodType.make(rtype, Arrays.asList(ptypes));
@@ -604,6 +607,7 @@ new file mode 100644
+ /**
+ * Test of make method, of class MethodType.
+ */
++ @Test
+ public void testMake_3args() {
+ System.out.println("make (from type with varargs)");
+ MethodType result = MethodType.make(rtype, ptypes[0], ptypes[1]);
@@ -613,6 +617,7 @@ new file mode 100644
+ /**
+ * Test of make method, of class MethodType.
+ */
++ @Test
+ public void testMake_Class() {
+ System.out.println("make (from single type)");
+ Class<?> rt = Integer.class;
@@ -621,6 +626,7 @@ new file mode 100644
+ assertEquals(expResult, result);
+ }
+
++ @Test
+ public void testMakeGeneric() {
+ System.out.println("makeGeneric");
+ int objectArgCount = 2;
@@ -632,6 +638,7 @@ new file mode 100644
+ /**
+ * Test of make method, of class MethodType.
+ */
++ @Test
+ public void testMake_Method() {
+ System.out.println("make (from Method)");
+ MethodType expResult = MethodType.make(int.class, String.class, String.class);
@@ -642,6 +649,7 @@ new file mode 100644
+ /**
+ * Test of make method, of class MethodType.
+ */
++ @Test
+ public void testMake_MethodType() {
+ System.out.println("make (from rtype, MethodType)");
+ MethodType expResult = mt_iO2;
@@ -652,6 +660,7 @@ new file mode 100644
+ /**
+ * Test of make method, of class MethodType.
+ */
++ @Test
+ public void testMake_String_ClassLoader() {
+ System.out.println("make (from bytecode signature)");
+ ClassLoader loader = null;
@@ -693,6 +702,7 @@ new file mode 100644
+ return sb.toString().replace('.', '/');
+ }
+
++ @Test
+ public void testHasPrimitives() {
+ System.out.println("hasPrimitives");
+ MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
@@ -703,6 +713,7 @@ new file mode 100644
+ }
+ }
+
++ @Test
+ public void testHasWrappers() {
+ System.out.println("hasWrappers");
+ MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
@@ -713,6 +724,7 @@ new file mode 100644
+ }
+ }
+
++ @Test
+ public void testErase() {
+ System.out.println("erase");
+ MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
@@ -723,6 +735,7 @@ new file mode 100644
+ }
+ }
+
++ @Test
+ public void testEraseWrap() {
+ System.out.println("eraseWrap");
+ MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
@@ -733,6 +746,7 @@ new file mode 100644
+ }
+ }
+
++ @Test
+ public void testGeneric() {
+ System.out.println("generic");
+ MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
@@ -743,6 +757,7 @@ new file mode 100644
+ }
+ }
+
++ @Test
+ public void testWrap() {
+ System.out.println("wrap");
+ MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
@@ -753,6 +768,7 @@ new file mode 100644
+ }
+ }
+
++ @Test
+ public void testUnwrap() {
+ System.out.println("unwrap");
+ MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
@@ -766,6 +782,7 @@ new file mode 100644
+ /**
+ * Test of parameterType method, of class MethodType.
+ */
++ @Test
+ public void testParameterType() {
+ System.out.println("parameterType");
+ for (int num = 0; num < ptypes.length; num++) {
@@ -779,6 +796,7 @@ new file mode 100644
+ /**
+ * Test of parameterCount method, of class MethodType.
+ */
++ @Test
+ public void testParameterCount() {
+ System.out.println("parameterCount");
+ MethodType instance = mt_viS;
@@ -790,6 +808,7 @@ new file mode 100644
+ /**
+ * Test of returnType method, of class MethodType.
+ */
++ @Test
+ public void testReturnType() {
+ System.out.println("returnType");
+ MethodType instance = mt_viS;
@@ -801,6 +820,7 @@ new file mode 100644
+ /**
+ * Test of parameterList method, of class MethodType.
+ */
++ @Test
+ public void testParameterList() {
+ System.out.println("parameterList");
+ MethodType instance = mt_viS;
@@ -812,6 +832,7 @@ new file mode 100644
+ /**
+ * Test of parameterArray method, of class MethodType.
+ */
++ @Test
+ public void testParameterArray() {
+ System.out.println("parameterArray");
+ MethodType instance = mt_viS;
@@ -823,6 +844,7 @@ new file mode 100644
+ /**
+ * Test of equals method, of class MethodType.
+ */
++ @Test
+ public void testEquals_Object() {
+ System.out.println("equals");
+ Object x = null;
@@ -835,6 +857,7 @@ new file mode 100644
+ /**
+ * Test of equals method, of class MethodType.
+ */
++ @Test
+ public void testEquals_MethodType() {
+ System.out.println("equals");
+ MethodType that = mt_viS;
@@ -847,6 +870,7 @@ new file mode 100644
+ /**
+ * Test of hashCode method, of class MethodType.
+ */
++ @Test
+ public void testHashCode() {
+ System.out.println("hashCode");
+ MethodType instance = mt_viS;
@@ -861,6 +885,7 @@ new file mode 100644
+ /**
+ * Test of toString method, of class MethodType.
+ */
++ @Test
+ public void testToString() {
+ System.out.println("toString");
+ MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
@@ -883,6 +908,7 @@ new file mode 100644
+ }
+ }
+
++ @Test
+ public void testToString_va() {
+ System.out.println("toString");
+ MethodType instance = MethodType.make(Object.class, int[].class);