langtools/test/tools/javac/meth/InvokeDyn.java
changeset 6592 dc56420a69bc
parent 5738 c24b113fe4ac
child 7330 7c670eebe55c
equal deleted inserted replaced
6591:a953c8c6b85e 6592:dc56420a69bc
     1 /*
     1 /*
     2  * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 6754038
    26  * @bug 6754038 6979327
    27  * @summary Generate call sites for method handle
    27  * @summary Generate call sites for method handle
    28  * @author jrose
    28  * @author jrose
    29  *
    29  *
    30  * @library ..
    30  * @library ..
    31  * @compile -source 7 -target 7 InvokeDyn.java
    31  * @compile -source 7 -target 7 -XDinvokedynamic -XDallowTransitionalJSR292=no InvokeDyn.java
    32  */
    32  */
    33 //No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn
    33 //No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn
    34 
    34 
    35 /*
    35 /*
    36  * Standalone testing:
    36  * Standalone testing:
    42  * </code>
    42  * </code>
    43  */
    43  */
    44 
    44 
    45 package meth;
    45 package meth;
    46 
    46 
    47 import java.dyn.InvokeDynamic;
    47 import java.dyn.*;
    48 
    48 
    49 public class InvokeDyn {
    49 public class InvokeDyn {
       
    50     class CS extends CallSite {
       
    51         CS(Object x, Object y, Object z) { throw new RuntimeException(); }
       
    52     }
       
    53     //@BootstrapMethod(CS.class)  //note: requires 6964498
    50     void test() throws Throwable {
    54     void test() throws Throwable {
    51         Object x = "hello";
    55         Object x = "hello";
    52         InvokeDynamic.greet(x, "world", 123);
    56         Object ojunk; int ijunk;
    53         InvokeDynamic.greet(x, "mundus", 456);
    57         ojunk = InvokeDynamic.greet(x, "world", 123);
    54         InvokeDynamic.greet(x, "kosmos", 789);
    58         ojunk = InvokeDynamic.greet(x, "mundus", 456);
    55         InvokeDynamic.<String>cogitate(10.11121, 3.14);
    59         ojunk = InvokeDynamic.greet(x, "kosmos", 789);
    56         InvokeDynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null);
    60         ojunk = (String) InvokeDynamic.cogitate(10.11121, 3.14);
    57         InvokeDynamic.<int>invoke("goodbye");
    61         InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null);
       
    62         ijunk = (int) InvokeDynamic.invoke("goodbye");
    58     }
    63     }
    59 }
    64 }