--- /dev/null Tue Apr 23 11:57:24 2013 +++ new/test/tools/javac/annotations/typeAnnotations/classfile/T8013065.java Tue Apr 23 11:57:23 2013 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @summary type-annotation written as regular annotation in anon classes + * @bug 8013065 + */ +import java.lang.annotation.*; +import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.ElementType.*; +import com.sun.tools.classfile.*; + +/* + * A type-annotations on a field in an inner class not in a lambda expression + * results in RuntimeTypeAnnotations_attibute and RuntimeAnnotations_attribute. + * On a field in an innner class in a lambda expression, it leaves off the + * RuntimeAnnotations_attribute. + */ +public class T8013065 extends ClassfileTestHelper{ + public static void main(String[] args) throws Exception { + new T8013065().run(); + } + + public void run() throws Exception { + expected_tvisibles = 1; + expected_tinvisibles = 1; + ClassFile cf = getClassFile("T8013065$Test$1$InnerAnon.class"); + for (Method m : cf.methods) { + test(cf, m); + } + countAnnotations(); + + if (errors > 0) + throw new Exception(errors + " errors found"); + System.out.println("PASSED"); + } + + /*********************** Test class **************************/ + class Test { + Object mtest( Test t){ return null; } + public void test() { + mtest( new Test() { + class InnerAnon { + @A @B String ia_m1(){ return null; }; + } + //comment below and they're written correctly. + InnerAnon IA = new InnerAnon< String>(); + }); + } + } + @Retention(CLASS) @Target(TYPE_USE) @interface A { } + @Retention(RUNTIME) @Target(TYPE_USE) @interface B { } +}