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

Tue, 14 May 2013 15:04:06 -0700

author
jjg
date
Tue, 14 May 2013 15:04:06 -0700
changeset 1755
ddb4a2bfcd82
parent 1563
bc456436c613
child 2222
8832b6048e65
permissions
-rw-r--r--

8013852: update reference impl for type-annotations
Reviewed-by: jjg
Contributed-by: wdietl@gmail.com, steve.sides@oracle.com, joel.franck@oracle.com, alex.buckley@oracle.com

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
jjg@1563 26 * @bug 8008077
jjg@1563 27 * @summary new type annotation location: lambda expressions
jjg@1563 28 * @compile Lambda.java
jjg@1563 29 * @author Werner Dietl
jjg@1563 30 */
jjg@1563 31
jjg@1563 32 import java.lang.annotation.*;
jjg@1563 33
jjg@1563 34 public class Lambda {
jjg@1563 35
jjg@1563 36 interface LambdaInt {
jjg@1563 37 <S, T> void generic(S p1, T p2);
jjg@1563 38 }
jjg@1563 39
jjg@1563 40 static class LambdaImpl implements LambdaInt {
jjg@1563 41 <S, T> LambdaImpl(S p1, T p2) {}
jjg@1563 42 public <S, T> void generic(S p1, T p2) {}
jjg@1563 43 }
jjg@1563 44
jjg@1563 45 LambdaInt getMethodRefTA(LambdaImpl r) {
jjg@1563 46 return r::<@TA Object, @TB Object>generic;
jjg@1563 47 }
jjg@1563 48
jjg@1563 49 LambdaInt getConstructorRefTA() {
jjg@1563 50 return LambdaImpl::<@TA Object, @TB Object>new;
jjg@1563 51 }
jjg@1563 52
jjg@1755 53 interface LambdaInt2 {
jjg@1755 54 void lambda(Object p1, Object p2);
jjg@1755 55 }
jjg@1755 56
jjg@1755 57 LambdaInt2 getLambda() {
jjg@1755 58 return (@TA Object x, @TB Object y) -> { @TA Object l = null; System.out.println("We have: " + (@TB Object) x); };
jjg@1755 59 }
jjg@1563 60 }
jjg@1563 61
jjg@1563 62 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
jjg@1563 63 @interface TA { }
jjg@1563 64
jjg@1563 65 @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
jjg@1563 66 @interface TB { }

mercurial