jrose@267: /* mcimadamore@674: * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. jrose@267: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jrose@267: * jrose@267: * This code is free software; you can redistribute it and/or modify it jrose@267: * under the terms of the GNU General Public License version 2 only, as jrose@267: * published by the Free Software Foundation. jrose@267: * jrose@267: * This code is distributed in the hope that it will be useful, but WITHOUT jrose@267: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jrose@267: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jrose@267: * version 2 for more details (a copy is included in the LICENSE file that jrose@267: * accompanied this code). jrose@267: * jrose@267: * You should have received a copy of the GNU General Public License version jrose@267: * 2 along with this work; if not, write to the Free Software Foundation, jrose@267: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jrose@267: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. jrose@267: */ jrose@267: jrose@267: /* jrose@267: * @test mcimadamore@674: * @bug 6754038 6979327 jrose@267: * @summary Generate call sites for method handle jrose@267: * @author jrose jrose@267: * jrose@267: * @library .. mcimadamore@674: * @compile -source 7 -target 7 -XDinvokedynamic -XDallowTransitionalJSR292=no InvokeDyn.java jrose@267: */ jrose@267: //No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn jrose@267: jrose@267: /* jrose@267: * Standalone testing: jrose@267: * jrose@267: * $ cd $MY_REPO_DIR/langtools jrose@267: * $ (cd make; make) jrose@267: * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeDyn.java jrose@267: * $ javap -c -classpath dist meth.InvokeDyn jrose@267: * jrose@267: */ jrose@267: jrose@267: package meth; jrose@267: mcimadamore@674: import java.dyn.*; jrose@267: jrose@267: public class InvokeDyn { mcimadamore@674: class CS extends CallSite { mcimadamore@674: CS(Object x, Object y, Object z) { throw new RuntimeException(); } mcimadamore@674: } mcimadamore@674: //@BootstrapMethod(CS.class) //note: requires 6964498 jrose@571: void test() throws Throwable { jrose@267: Object x = "hello"; mcimadamore@674: Object ojunk; int ijunk; mcimadamore@674: ojunk = InvokeDynamic.greet(x, "world", 123); mcimadamore@674: ojunk = InvokeDynamic.greet(x, "mundus", 456); mcimadamore@674: ojunk = InvokeDynamic.greet(x, "kosmos", 789); mcimadamore@674: ojunk = (String) InvokeDynamic.cogitate(10.11121, 3.14); mcimadamore@674: InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null); mcimadamore@674: ijunk = (int) InvokeDynamic.invoke("goodbye"); jrose@267: } jrose@267: }