test/tools/javac/meth/InvokeDyn.java

changeset 674
584365f256a7
parent 573
005bec70ca27
child 752
03177f49411d
equal deleted inserted replaced
673:7ae4016c5938 674:584365f256a7
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 }

mercurial