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. |
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 } |