Remove experimental flags from test options.
InvokeDynamic is now enabled by default in JDK 7/lambda repository.
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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
7 * published by the Free Software Foundation.
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
26 * @summary basic test for lambda conversion
28 * @author Maurizio Cimadamore
29 * @run main LambdaConv01
32 public class LambdaConv01 {
34 static int assertionCount = 0;
36 static void assertTrue(boolean cond) {
39 throw new AssertionError();
43 public int foo(int x);
47 public void foo(int x);
58 public static <T, U> T exec(TU<T, U> lambda, U x) {
63 //Assignment conversion:
65 assertTrue(3 == f1.foo());
67 TU<Number, Integer> f2 = #{ Integer x -> x };
68 assertTrue(3 == f2.foo(3));
69 //Method resolution with boxing:
70 int x = LambdaConv01.<Integer,Integer>exec(#{ Integer x -> x }, 3);
72 //Runtime exception transparency:
74 LambdaConv01.<Integer,Object>exec(#{ Object x -> x.hashCode() }, null);
76 catch (RuntimeException e) {
82 //Assignment conversion:
84 assertTrue(3 == f1.foo());
86 TU<Number, Integer> f2 = #{ Integer x -> x };
87 assertTrue(3 == f2.foo(3));
88 //Method resolution with boxing:
89 int x = LambdaConv01.<Integer,Integer>exec(#{ Integer x -> x }, 3);
91 //Runtime exception transparency:
93 LambdaConv01.<Integer,Object>exec(#{ Object x -> x.hashCode() }, null);
95 catch (RuntimeException e) {
100 public static void test1() {
101 //Assignment conversion:
103 assertTrue(3 == f1.foo());
105 TU<Number, Integer> f2 = #{ Integer x -> x };
106 assertTrue(3 == f2.foo(3));
107 //Method resolution with boxing:
108 int x = LambdaConv01.<Integer,Integer>exec(#{ Integer x -> x }, 3);
110 //Runtime exception transparency:
112 LambdaConv01.<Integer,Object>exec(#{ Object x -> x.hashCode() }, null);
114 catch (RuntimeException e) {
119 public void test2() {
120 //Assignment conversion:
122 assertTrue(3 == f1.foo());
124 TU<Number, Integer> f2 = #{ Integer x -> x };
125 assertTrue(3 == f2.foo(3));
126 //Method resolution with boxing:
127 int x = LambdaConv01.<Integer,Integer>exec(#{ Integer x -> x }, 3);
129 //Runtime exception transparency:
131 LambdaConv01.<Integer,Object>exec(#{ Object x -> x.hashCode() }, null);
133 catch (RuntimeException e) {
138 public static void main(String[] args) {
140 new LambdaConv01().test2();
141 assertTrue(assertionCount == 16);