Wed, 27 Apr 2016 01:34:52 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17
1 /*
2 * Copyright (c) 2009, 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 * @summary Wrong classfile attribution in inner class of lambda expression.
27 * @bug 8010015
28 */
30 import java.lang.annotation.*;
31 import static java.lang.annotation.RetentionPolicy.*;
32 import static java.lang.annotation.ElementType.*;
33 import com.sun.tools.classfile.*;
35 /*
36 * A type-annotations on a field in an inner class not in a lambda expression
37 * results in RuntimeTypeAnnotations_attibute and RuntimeAnnotations_attribute.
38 * On a field in an innner class in a lambda expression, it leaves off the
39 * RuntimeAnnotations_attribute.
40 */
41 public class T8010015 extends ClassfileTestHelper{
42 public static void main(String[] args) throws Exception {
43 new T8010015().run();
44 }
46 public void run() throws Exception {
47 expected_tvisibles = 1;
48 expected_visibles = 1;
49 ClassFile cf = getClassFile("T8010015$Test$1innerClass.class");
50 for (Field f : cf.fields) {
51 test(cf, f);
52 }
53 countAnnotations();
55 if (errors > 0)
56 throw new Exception(errors + " errors found");
57 System.out.println("PASSED");
58 }
60 /*********************** Test class **************************/
61 interface MapFun<T, R> { R m( T n); }
62 static class Test {
63 MapFun<Class<?>,String> cs;
64 void test() {
65 cs = c -> {
66 class innerClass {
67 @A Class<?> icc = null;
68 innerClass(Class<?> _c) { icc = _c; }
69 String getString() { return icc.toString(); }
70 }
71 return new innerClass(c).getString();
72 };
73 System.out.println("cs.m : " + cs.m(Integer.class));
74 }
76 public static void main(String... args) {new Test().test(); }
77 }
78 @Retention(RUNTIME) @Target({TYPE_USE,FIELD}) @interface A { }
79 }