Fri, 13 Dec 2013 14:13:03 +0000
8029721: javac crash for annotated parameter type of lambda in a field
Reviewed-by: rfield, jfranck
1 /*
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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.
8 *
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).
14 *
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.
18 *
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
21 * questions.
22 */
24 /*
25 * @test
26 * @bug 8008077 8029721
27 * @summary new type annotation location: lambda expressions
28 * javac crash for annotated parameter type of lambda in a field
29 * @compile Lambda.java
30 * @author Werner Dietl
31 */
33 import java.lang.annotation.*;
35 public class Lambda {
37 interface LambdaInt {
38 <S, T> void generic(S p1, T p2);
39 }
41 static class LambdaImpl implements LambdaInt {
42 <S, T> LambdaImpl(S p1, T p2) {}
43 public <S, T> void generic(S p1, T p2) {}
44 }
46 LambdaInt getMethodRefTA(LambdaImpl r) {
47 return r::<@TA Object, @TB Object>generic;
48 }
50 LambdaInt getConstructorRefTA() {
51 return LambdaImpl::<@TA Object, @TB Object>new;
52 }
54 interface LambdaInt2 {
55 void lambda(Object p1, Object p2);
56 }
58 LambdaInt2 getLambda() {
59 return (@TA Object x, @TB Object y) -> { @TA Object l = null; System.out.println("We have: " + (@TB Object) x); };
60 }
62 java.util.function.IntUnaryOperator x = (@TA int y) -> 1;
64 static java.util.function.IntUnaryOperator xx = (@TA int y) -> 1;
66 java.util.function.IntUnaryOperator foo() {
67 return (@TA int y) -> 2;
68 }
69 }
71 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
72 @interface TA { }
74 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
75 @interface TB { }