changeset 42:bd8323fd8671

meth: remove unconverted tests
author jrose
date Fri, 24 Sep 2010 14:33:10 -0700
parents 82062030d68e
children 78d102a4afcb
files netbeans/meth/test/jdk/java/dyn/HelloDynamic.java netbeans/meth/test/jdk/java/dyn/InvokeDynamicDemo.java
diffstat 2 files changed, 0 insertions(+), 387 deletions(-) [+]
line wrap: on
line diff
--- a/netbeans/meth/test/jdk/java/dyn/HelloDynamic.java	Fri Sep 24 14:32:17 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * 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 HelloDynamic {
-    @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
-            Object x = whom;
-            InvokeDynamic.hail(x);            // weakly typed invokedynamic
-            // previous line generates invokedynamic MethodHandle.invoke(Object)Object
-        }
-        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.lookup().findStatic(HelloDynamic.class, "greeter",
-                                   MethodType.make(void.class, String.class));
-    //might be nice: MethodHandle greeter = Hello#greeter;
-
-    static Object greete5(String x) { System.out.println("H311o, "+x); return null; }
-    static MethodHandle greete5
-        = MethodHandles.lookup().findStatic(HelloDynamic.class, "greete5",
-                                   MethodType.make(Object.class, String.class));
-    // Set up a class-local bootstrap method.
-    static { Linkage.registerBootstrapMethod("bootstrapDynamic"); }
-    private static CallSite bootstrapDynamic(Class caller, String name, MethodType type) {
-        assert(type.parameterCount() == 1 && name == "hail");  // in lieu of MOP
-        System.out.println("set site target to "+greete5);
-        CallSite site = new CallSite(caller, name, type);
-        MethodHandle target = MethodHandles.convertArguments(greete5, site.type());
-        System.out.println("   with conversions: "+target);
-        site.setTarget(target);
-        return site;
-    }
-}
--- a/netbeans/meth/test/jdk/java/dyn/InvokeDynamicDemo.java	Fri Sep 24 14:32:17 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,300 +0,0 @@
-/*
- * 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;
-
-import sun.dyn.anon.ConstantPoolPatch;
-import sun.dyn.anon.AnonymousClassLoader;
-import java.dyn.*;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.regex.Pattern;
-import org.junit.*;
-//import static org.junit.Assert.*;
-import static jdk.java.dyn.JUnitAssert.*;
-
-public class InvokeDynamicDemo {
-
-    private interface FakeDynamic extends Dynamic {
-        int foo(int x);
-        String bar(String x, int y);
-    }
-
-    public static int myFoo(Object recv, int z) {
-        println("myFoo "+recv+" "+z);
-        return z * 1000000;
-    }
-
-    public static String myBar(Object recv, String x, int y) {
-        println("myBar "+recv+" "+x+" "+y);
-        return "myBar"+Arrays.asList(recv, x, y);
-    }
-
-    static class IDUser implements Runnable {
-        static String options = "FAKE_OPTIONS";
-        static boolean hasOption(String x) {
-            return options.indexOf(x) >= 0;
-        }
-
-        @Override
-        public void run() {
-            useit("baz", "bat", 123);
-        }
-
-        void useit(Object x, Object y, int z) {
-            int fooval = fakeIdentity(x).foo(z);
-            println("foo => "+fooval);
-            assertEquals(myFoo(x, z), fooval);
-            String barval = fakeIdentity(x).bar((String)y, z);
-            println("bar => "+barval);
-            assertEquals(myBar(x, (String)y, z), barval);
-        }
-
-        public // %%% FIXME: findStatic only finds public methods right now
-        static Object bootstrap(CallSite site, Object... args) {
-            println("bootstrap "+site+Arrays.asList(args));
-            // a bootstrap method can be very stupid:
-            if (hasOption("boot-gc"))
-                Runtime.getRuntime().gc();
-            if (hasOption("boot-null"))
-                return null;
-            if (hasOption("boot-bad"))
-                return Arrays.asList(args);   // neither a String nor an Integer
-            if (hasOption("boot-string"))
-                return "boot";
-            if (hasOption("boot-int"))
-                return 8007;
-            if (hasOption("boot-throw"))
-                throw new RuntimeException("boot-throw!");
-            // or it can actually look at the call site:
-            Object name = site.name();
-            if (name == "foo") {
-                if (hasOption("boot-con"))
-                    return 8007000;  // it does not need to set a target...
-                MethodHandle myFoo = MethodHandles.findStatic(InvokeDynamicDemo.class, "myFoo", site.type());
-                println("setTarget myFoo: "+myFoo);
-                site.setTarget(myFoo);
-                return myFoo(args[0], (Integer) args[1]);
-            }
-            if (name == "bar") {
-                if (hasOption("boot-con"))
-                    return "boot con!";  // it does not need to set a target...
-                MethodHandle myBar = MethodHandles.findStatic(InvokeDynamicDemo.class, "myBar", site.type());
-                println("setTarget myBar: "+myBar);
-                site.setTarget(myBar);
-                return myBar(args[0], (String) args[1], (Integer) args[2]);
-            }
-            throw new RuntimeException("name not recognized: "+name);
-        }
-
-        static {
-            println("options: "+options);
-            MethodType type = Linkage.BOOTSTRAP_METHOD_TYPE;
-            MethodHandle mh = MethodHandles.findStatic(IDUser.class, "bootstrap", type);
-            if (mh == null)
-                println("missing bootstrap"+type);
-            else
-                println("register bootstrap: "+mh);
-            Linkage.registerBootstrapMethod(IDUser.class, mh);
-        }
-    }
-    static FakeDynamic fakeIdentity(Object x) {
-        return (FakeDynamic)x;
-    }
-    static Object identity(Object x) {
-        return x;
-    }
-
-    static boolean verbose;
-    static void println(String x) {
-        if (verbose)  System.out.println(x);
-    }
-
-    @Test public void run() throws Exception { run(new String[0]); }
-
-    public static void run(String... av) throws Exception {
-        final HashMap<String,String> utf8Map = new HashMap<String,String>();
-        utf8Map.put("fakeIdentity", "identity");
-        String objbcn = Object.class.getName().replace('.', '/');
-        String objsig = "L"+objbcn+";";
-        String fdbcn = FakeDynamic.class.getName().replace('.', '/');
-        String rdbcn = Dynamic.class.getName().replace('.', '/');
-        utf8Map.put(fdbcn, rdbcn);
-        String fakesig = "("+objsig+")L"+fdbcn+";";
-        utf8Map.put(fakesig, fakesig.replaceAll(Pattern.quote(fdbcn), objbcn));
-        utf8Map.put("FAKE_OPTIONS", Arrays.asList(av).toString());
-        System.out.println("utf8Map: "+utf8Map);
-        final ConstantPoolPatch patch = new ConstantPoolPatch(IDUser.class);
-        patch.putPatches(utf8Map, null, null, true);
-        if (!utf8Map.isEmpty())
-            throw new AssertionError("Map not empty: "+utf8Map);
-        Class anonk = new AnonymousClassLoader(IDUser.class).loadClass(patch);
-        Object user = anonk.newInstance();
-        System.out.println("Running test on new object "+user);
-        int count = 1;
-        verbose = true;
-        for (String arg : av) {
-            if (arg.startsWith("count-"))
-                count = Integer.parseInt(arg.substring("count-".length(), arg.length()));
-        }
-        if (count != 1)  System.out.println("run count: "+count);
-        for (int i = 0; i < count; i++) {
-            if (i > 10) {
-                if (i > count - 10)
-                    verbose = true;
-                else if (verbose) {
-                    println("...shutting up...");
-                    verbose = false;
-                }
-            }
-            ((Runnable)user).run();
-        }
-    }
-
-    // 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 {
-        System.out.println("running ID demo");
-        run(av);
-        //new JUnit4TestAdapter(InvokeDynamicDemo.class).run(null);
-    }
-}
-
-/* --- SAMPLE OUTPUT ---
---------
-	./gamma -XX:+EnableInvokeDynamic -Xbootclasspath/p:"$cpath" jdk.java.dyn.InvokeDynamicDemo count-1000
-VM option '+PrintCompilation'
-VM option '+VerifyBeforeGC'
-VM option '+MethodHandles'
-VM option '+InvokeDynamic'
-[Verifying threads permgen tenured generation def new generation remset ref_proc syms strs zone dict hand C-heap ]
-running ID demo
-utf8Map: {fakeIdentity=identity, jdk/java/dyn/InvokeDynamicDemo$FakeDynamic=java/dyn/Dynamic, (Ljava/lang/Object;)Ljdk/java/dyn/InvokeDynamicDemo$FakeDynamic;=(Ljava/lang/Object;)Ljava/lang/Object;, FAKE_OPTIONS=[count-1000]}
-  1       java.lang.String::charAt (33 bytes)
-  2       java.lang.String::hashCode (60 bytes)
-Running test on new object jdk.java.dyn.InvokeDynamicDemo$IDUser/29596205@eb7859
-run count: 1000
-reporting bootstrap method to JVM: bootstrap:(java.dyn.CallSite,java.lang.Object...)java.lang.Object
-DynCallSite: CallSite#23491286[foo(java.lang.Object,int)int => null]
-bootstrap CallSite#23491286[foo(java.lang.Object,int)int => null][baz, 123]
-setTarget myFoo: myFoo:(java.lang.Object,int)int
-myFoo baz 123
-foo => 123000000
-DynCallSite: CallSite#21061094[bar(java.lang.Object,java.lang.String,int)java.lang.String => null]
-bootstrap CallSite#21061094[bar(java.lang.Object,java.lang.String,int)java.lang.String => null][baz, bat, 123]
-setTarget myBar: myBar:(java.lang.Object,java.lang.String,int)java.lang.String
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-...shutting up...
-  3       java.lang.Object::<init> (1 bytes)
- VerifyBeforeGC:[Verifying threads permgen tenured generation def new generation remset ref_proc syms strs zone dict hand C-heap ]
----   n   java.lang.System::arraycopy (static)
-  4       java.lang.String::getChars (66 bytes)
-  5       java.lang.AbstractStringBuilder::append (60 bytes)
-  6       java.lang.StringBuilder::append (8 bytes)
-  7       java.lang.Integer::getChars (131 bytes)
-  8       java.lang.AbstractStringBuilder::stringSizeOfInt (21 bytes)
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
-myFoo baz 123
-foo => 123000000
-myBar baz bat 123
-bar => myBar[baz, bat, 123]
---------
- * --- */