test/tools/javac/annotations/typeAnnotations/newlocations/Lambda.java

Fri, 13 Dec 2013 14:13:03 +0000

author
vromero
date
Fri, 13 Dec 2013 14:13:03 +0000
changeset 2222
8832b6048e65
parent 1755
ddb4a2bfcd82
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8029721: javac crash for annotated parameter type of lambda in a field
Reviewed-by: rfield, jfranck

jjg@1563 1 /*
jjg@1563 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
jjg@1563 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@1563 4 *
jjg@1563 5 * This code is free software; you can redistribute it and/or modify it
jjg@1563 6 * under the terms of the GNU General Public License version 2 only, as
jjg@1563 7 * published by the Free Software Foundation.
jjg@1563 8 *
jjg@1563 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@1563 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@1563 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@1563 12 * version 2 for more details (a copy is included in the LICENSE file that
jjg@1563 13 * accompanied this code).
jjg@1563 14 *
jjg@1563 15 * You should have received a copy of the GNU General Public License version
jjg@1563 16 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@1563 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@1563 18 *
jjg@1563 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jjg@1563 20 * or visit www.oracle.com if you need additional information or have any
jjg@1563 21 * questions.
jjg@1563 22 */
jjg@1563 23
jjg@1563 24 /*
jjg@1563 25 * @test
vromero@2222 26 * @bug 8008077 8029721
jjg@1563 27 * @summary new type annotation location: lambda expressions
vromero@2222 28 * javac crash for annotated parameter type of lambda in a field
jjg@1563 29 * @compile Lambda.java
jjg@1563 30 * @author Werner Dietl
jjg@1563 31 */
jjg@1563 32
jjg@1563 33 import java.lang.annotation.*;
jjg@1563 34
jjg@1563 35 public class Lambda {
jjg@1563 36
jjg@1563 37 interface LambdaInt {
jjg@1563 38 <S, T> void generic(S p1, T p2);
jjg@1563 39 }
jjg@1563 40
jjg@1563 41 static class LambdaImpl implements LambdaInt {
jjg@1563 42 <S, T> LambdaImpl(S p1, T p2) {}
jjg@1563 43 public <S, T> void generic(S p1, T p2) {}
jjg@1563 44 }
jjg@1563 45
jjg@1563 46 LambdaInt getMethodRefTA(LambdaImpl r) {
jjg@1563 47 return r::<@TA Object, @TB Object>generic;
jjg@1563 48 }
jjg@1563 49
jjg@1563 50 LambdaInt getConstructorRefTA() {
jjg@1563 51 return LambdaImpl::<@TA Object, @TB Object>new;
jjg@1563 52 }
jjg@1563 53
jjg@1755 54 interface LambdaInt2 {
jjg@1755 55 void lambda(Object p1, Object p2);
jjg@1755 56 }
jjg@1755 57
jjg@1755 58 LambdaInt2 getLambda() {
jjg@1755 59 return (@TA Object x, @TB Object y) -> { @TA Object l = null; System.out.println("We have: " + (@TB Object) x); };
jjg@1755 60 }
vromero@2222 61
vromero@2222 62 java.util.function.IntUnaryOperator x = (@TA int y) -> 1;
vromero@2222 63
vromero@2222 64 static java.util.function.IntUnaryOperator xx = (@TA int y) -> 1;
vromero@2222 65
vromero@2222 66 java.util.function.IntUnaryOperator foo() {
vromero@2222 67 return (@TA int y) -> 2;
vromero@2222 68 }
jjg@1563 69 }
jjg@1563 70
jjg@1563 71 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
jjg@1563 72 @interface TA { }
jjg@1563 73
jjg@1563 74 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
jjg@1563 75 @interface TB { }

mercurial