Wed, 02 Mar 2011 21:13:55 -0800
6639645: Modeling type implementing missing interfaces
Reviewed-by: darcy, mcimadamore
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | */ |
aoqi@0 | 23 | |
aoqi@0 | 24 | import java.util.*; |
aoqi@0 | 25 | |
aoqi@0 | 26 | @interface ExpectInterfaces { |
aoqi@0 | 27 | String value(); |
aoqi@0 | 28 | } |
aoqi@0 | 29 | |
aoqi@0 | 30 | @interface ExpectSupertype { |
aoqi@0 | 31 | String value(); |
aoqi@0 | 32 | } |
aoqi@0 | 33 | |
aoqi@0 | 34 | interface OK { |
aoqi@0 | 35 | void m(); |
aoqi@0 | 36 | } |
aoqi@0 | 37 | |
aoqi@0 | 38 | class InvalidSource { |
aoqi@0 | 39 | /* |
aoqi@0 | 40 | * The following annotations contain a simple description of the expected |
aoqi@0 | 41 | * representation of the superclass and superinterfaces of the corresponding |
aoqi@0 | 42 | * elements. |
aoqi@0 | 43 | * The strings contain a comma-separated list of descriptions. |
aoqi@0 | 44 | * Descriptions are composed as follows: |
aoqi@0 | 45 | * A leading "!:" indicates the type mirror has kind ERROR. |
aoqi@0 | 46 | * "empty" means that the corresponding element has no enclosed elements. |
aoqi@0 | 47 | * "clss", "intf" and "tvar" indicate the name refers to a class, interface |
aoqi@0 | 48 | * or type variable. Each is followed by the declared name of the element. |
aoqi@0 | 49 | * "pkg" indicates the name of a package element. |
aoqi@0 | 50 | * An enclosing element is shown in parentheses. |
aoqi@0 | 51 | * A trailing "!" indicates that the element's type has kind ERROR. |
aoqi@0 | 52 | */ |
aoqi@0 | 53 | |
aoqi@0 | 54 | @ExpectSupertype("!:empty clss A!") |
aoqi@0 | 55 | class TestClassMissingClassA extends A { } |
aoqi@0 | 56 | |
aoqi@0 | 57 | @ExpectSupertype("!:empty clss (pkg A).B!") |
aoqi@0 | 58 | class TestClassMissingClassAB extends A.B { } |
aoqi@0 | 59 | |
aoqi@0 | 60 | @ExpectSupertype("!:empty clss (pkg java.util).A!") |
aoqi@0 | 61 | class TestClassMissingClass_juA extends java.util.A { } |
aoqi@0 | 62 | |
aoqi@0 | 63 | @ExpectSupertype("!:empty clss A!<tvar T>") |
aoqi@0 | 64 | class TestClassTMissingClassAT<T> extends A<T> { } |
aoqi@0 | 65 | |
aoqi@0 | 66 | @ExpectInterfaces("!:empty intf A!") |
aoqi@0 | 67 | class TestClassMissingIntfA implements A { } |
aoqi@0 | 68 | |
aoqi@0 | 69 | @ExpectInterfaces("!:empty intf (pkg A).B!") |
aoqi@0 | 70 | class TestClassMissingIntfAB implements A.B { } |
aoqi@0 | 71 | |
aoqi@0 | 72 | @ExpectInterfaces("!:empty intf A!, intf OK") |
aoqi@0 | 73 | abstract class TestClassMissingIntfAOK implements A, OK { } |
aoqi@0 | 74 | |
aoqi@0 | 75 | @ExpectInterfaces("intf OK, !:empty intf A!") |
aoqi@0 | 76 | abstract class TestClassOKMissingIntfA implements OK, A { } |
aoqi@0 | 77 | |
aoqi@0 | 78 | @ExpectInterfaces("!:empty intf A!, !:empty intf B!") |
aoqi@0 | 79 | class TestClassMissingIntfA_B implements A, B { } |
aoqi@0 | 80 | |
aoqi@0 | 81 | @ExpectInterfaces("!:empty intf A!") |
aoqi@0 | 82 | interface TestIntfMissingIntfA extends A { } |
aoqi@0 | 83 | |
aoqi@0 | 84 | @ExpectInterfaces("!:empty intf A!, intf OK") |
aoqi@0 | 85 | interface TestIntfMissingIntfAOK extends A, OK { } |
aoqi@0 | 86 | |
aoqi@0 | 87 | @ExpectInterfaces("intf OK, !:empty intf A!") |
aoqi@0 | 88 | interface TestIntfOKMissingIntfA extends OK, A { } |
aoqi@0 | 89 | |
aoqi@0 | 90 | @ExpectInterfaces("!:empty intf A!, !:empty intf B!") |
aoqi@0 | 91 | interface TestIntfMissingIntfAB extends A, B { } |
aoqi@0 | 92 | |
aoqi@0 | 93 | @ExpectInterfaces("!:empty intf A!<tvar T>") |
aoqi@0 | 94 | class TestClassTMissingIntfAT<T> implements A<T> { } |
aoqi@0 | 95 | |
aoqi@0 | 96 | @ExpectInterfaces("!:empty intf A!<tvar T>, !:empty intf B!") |
aoqi@0 | 97 | class TestClassTMissingIntfAT_B<T> implements A<T>, B { } |
aoqi@0 | 98 | |
aoqi@0 | 99 | @ExpectInterfaces("!:empty intf A!<tvar T>") |
aoqi@0 | 100 | interface TestIntfTMissingIntfAT<T> extends A<T> { } |
aoqi@0 | 101 | |
aoqi@0 | 102 | @ExpectInterfaces("!:empty intf A!<tvar T>, !:empty intf B!") |
aoqi@0 | 103 | interface TestIntfTMissingIntfAT_B<T> extends A<T>, B { } |
aoqi@0 | 104 | |
aoqi@0 | 105 | @ExpectInterfaces("intf (pkg java.util).List<!:empty clss X!>") |
aoqi@0 | 106 | abstract class TestClassListMissingX implements List<X> { } |
aoqi@0 | 107 | } |
aoqi@0 | 108 |