test/tools/javac/meth/InvokeMH.java

changeset 674
584365f256a7
parent 573
005bec70ca27
child 957
46d720734db3
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 * @compile -source 7 -target 7 InvokeMH.java 30 * @compile -source 7 -target 7 -XDallowTransitionalJSR292=no InvokeMH.java
31 */ 31 */
32 32
33 /* 33 /*
34 * Standalone testing: 34 * Standalone testing:
35 * <code> 35 * <code>
55 mh_SiO.invokeExact("world", 123); 55 mh_SiO.invokeExact("world", 123);
56 mh_SiO.invokeExact("mundus", 456); 56 mh_SiO.invokeExact("mundus", 456);
57 Object k = "kosmos"; 57 Object k = "kosmos";
58 mh_SiO.invokeExact((String)k, 789); 58 mh_SiO.invokeExact((String)k, 789);
59 o = mh_SiO.invokeExact((String)null, 000); 59 o = mh_SiO.invokeExact((String)null, 000);
60 o = mh_SiO.<Object>invokeExact("arda", -123); 60 o = (Object) mh_SiO.invokeExact("arda", -123);
61 61
62 // sig = ()String 62 // sig = ()String
63 s = mh_vS.<String>invokeExact(); 63 s = (String) mh_vS.invokeExact();
64 64
65 // sig = ()int 65 // sig = ()int
66 i = mh_vi.<int>invokeExact(); 66 i = (int) mh_vi.invokeExact();
67 o = mh_vi.<int>invokeExact(); 67 o = (int) mh_vi.invokeExact();
68 //s = mh_vi.<int>invokeExact(); //BAD
69 mh_vi.<int>invokeExact();
70 68
71 // sig = ()void 69 // sig = ()void
72 //o = mh_vv.<void>invokeExact(); //BAD 70 mh_vv.invokeExact();
73 mh_vv.<void>invokeExact();
74 } 71 }
75 72
76 void testGen(MethodHandle mh_SiO, 73 void testGen(MethodHandle mh_SiO,
77 MethodHandle mh_vS, 74 MethodHandle mh_vS,
78 MethodHandle mh_vi, 75 MethodHandle mh_vi,
79 MethodHandle mh_vv) throws Throwable { 76 MethodHandle mh_vv) throws Throwable {
80 Object o; String s; int i; // for return type testing 77 Object o; String s; int i; // for return type testing
81 78
82 // next five must have sig = (*,*)* 79 // next five must have sig = (*,*)*
83 mh_SiO.invokeGeneric((Object)"world", (Object)123); 80 o = mh_SiO.invokeGeneric((Object)"world", (Object)123);
84 mh_SiO.<void>invokeGeneric((Object)"mundus", (Object)456); 81 mh_SiO.invokeGeneric((Object)"mundus", (Object)456);
85 Object k = "kosmos"; 82 Object k = "kosmos";
86 mh_SiO.invokeGeneric(k, 789); 83 o = mh_SiO.invokeGeneric(k, 789);
87 o = mh_SiO.invokeGeneric(null, 000); 84 o = mh_SiO.invokeGeneric(null, 000);
88 o = mh_SiO.<Object>invokeGeneric("arda", -123); 85 o = mh_SiO.invokeGeneric("arda", -123);
89 86
90 // sig = ()String 87 // sig = ()String
91 o = mh_vS.invokeGeneric(); 88 o = mh_vS.invokeGeneric();
92 89
93 // sig = ()int 90 // sig = ()int
94 i = mh_vi.<int>invokeGeneric(); 91 i = (int) mh_vi.invokeGeneric();
95 o = mh_vi.invokeGeneric(); 92 o = (int) mh_vi.invokeGeneric();
96 //s = mh_vi.<int>invokeGeneric(); //BAD 93 mh_vi.invokeGeneric();
97 mh_vi.<void>invokeGeneric();
98 94
99 // sig = ()void 95 // sig = ()void
100 //o = mh_vv.<void>invokeGeneric(); //BAD 96 mh_vv.invokeGeneric();
101 o = mh_vv.invokeGeneric(); 97 o = mh_vv.invokeGeneric();
102 } 98 }
103 } 99 }

mercurial