1/* 2 * Copyright (c) 2011, 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 */ 23 24import java.util.*; 25 26@interface ExpectInterfaces { 27 String value(); 28} 29 30@interface ExpectSupertype { 31 String value(); 32} 33 34interface OK { 35 void m(); 36} 37 38class InvalidSource { 39 /* 40 * The following annotations contain a simple description of the expected 41 * representation of the superclass and superinterfaces of the corresponding 42 * elements. 43 * The strings contain a comma-separated list of descriptions. 44 * Descriptions are composed as follows: 45 * A leading "!:" indicates the type mirror has kind ERROR. 46 * "empty" means that the corresponding element has no enclosed elements. 47 * "clss", "intf" and "tvar" indicate the name refers to a class, interface 48 * or type variable. Each is followed by the declared name of the element. 49 * "pkg" indicates the name of a package element. 50 * An enclosing element is shown in parentheses. 51 * A trailing "!" indicates that the element's type has kind ERROR. 52 */ 53 54 @ExpectSupertype("!:empty clss A!") 55 class TestClassMissingClassA extends A { } 56 57 @ExpectSupertype("!:empty clss (pkg A).B!") 58 class TestClassMissingClassAB extends A.B { } 59 60 @ExpectSupertype("!:empty clss (pkg java.util).A!") 61 class TestClassMissingClass_juA extends java.util.A { } 62 63 @ExpectSupertype("!:empty clss A!<tvar T>") 64 class TestClassTMissingClassAT<T> extends A<T> { } 65 66 @ExpectInterfaces("!:empty intf A!") 67 class TestClassMissingIntfA implements A { } 68 69 @ExpectInterfaces("!:empty intf (pkg A).B!") 70 class TestClassMissingIntfAB implements A.B { } 71 72 @ExpectInterfaces("!:empty intf A!, intf OK") 73 abstract class TestClassMissingIntfAOK implements A, OK { } 74 75 @ExpectInterfaces("intf OK, !:empty intf A!") 76 abstract class TestClassOKMissingIntfA implements OK, A { } 77 78 @ExpectInterfaces("!:empty intf A!, !:empty intf B!") 79 class TestClassMissingIntfA_B implements A, B { } 80 81 @ExpectInterfaces("!:empty intf A!") 82 interface TestIntfMissingIntfA extends A { } 83 84 @ExpectInterfaces("!:empty intf A!, intf OK") 85 interface TestIntfMissingIntfAOK extends A, OK { } 86 87 @ExpectInterfaces("intf OK, !:empty intf A!") 88 interface TestIntfOKMissingIntfA extends OK, A { } 89 90 @ExpectInterfaces("!:empty intf A!, !:empty intf B!") 91 interface TestIntfMissingIntfAB extends A, B { } 92 93 @ExpectInterfaces("!:empty intf A!<tvar T>") 94 class TestClassTMissingIntfAT<T> implements A<T> { } 95 96 @ExpectInterfaces("!:empty intf A!<tvar T>, !:empty intf B!") 97 class TestClassTMissingIntfAT_B<T> implements A<T>, B { } 98 99 @ExpectInterfaces("!:empty intf A!<tvar T>") 100 interface TestIntfTMissingIntfAT<T> extends A<T> { } 101 102 @ExpectInterfaces("!:empty intf A!<tvar T>, !:empty intf B!") 103 interface TestIntfTMissingIntfAT_B<T> extends A<T>, B { } 104 105 @ExpectInterfaces("intf (pkg java.util).List<!:empty clss X!>") 106 abstract class TestClassListMissingX implements List<X> { } 107} 108 109