jdk/test/java/beans/Introspector/TestTypeResolver.java
author kshefov
Wed, 20 Mar 2013 14:02:25 +0400
changeset 16468 8675645c0757
parent 15332 aa02ac4b20b7
child 21274 238365b3e98a
permissions -rw-r--r--
8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again Reviewed-by: malenkov, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
16468
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
     2
 * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @summary Tests com.sun.beans.TypeResolver
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @author Eamonn McManus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import com.sun.beans.TypeResolver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
11092
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
    32
import java.lang.annotation.Annotation;
16468
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
    33
import java.lang.reflect.AnnotatedType;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.lang.reflect.Field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.lang.reflect.GenericDeclaration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.lang.reflect.Type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.lang.reflect.TypeVariable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.lang.reflect.WildcardType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.util.Comparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public class TestTypeResolver {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    static final List<Class<?>> failedCases = new ArrayList<Class<?>>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        test(TestTypeResolver.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        if (failedCases.isEmpty())
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            System.out.println("TEST PASSED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            System.out.println("TEST FAILED: failed cases: " + failedCases);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            throw new Error("TEST FAILED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private static void test(Class<?> c) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        /* Every public nested class represents a test.  In each case, either
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
         * the class contains further nested classes, in which case we
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
         * call this method recursively; or it declares or inherits a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
         * method called getThing() and it declares a static field
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
         * called "expect" which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
         * is the Type of that method's return value.  The test consists
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
         * of checking that the value returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
         * TypeResolver.resolveInClass is indeed this Type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        System.out.println("Test " + c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        Class<?>[] nested = c.getClasses();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        Arrays.sort(nested, classNameComparator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        for (Class<?> n : nested)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            test(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        final Method m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            m = c.getMethod("getThing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        } catch (NoSuchMethodException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            if (nested.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                System.out.println(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                        "TEST ERROR: class " + c.getName() + " has neither " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                                "nested classes nor getThing() method");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                failedCases.add(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        Object expect = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            Field f = c.getDeclaredField("expect");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            expect = f.get(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        } catch (NoSuchFieldException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            Class<?> outer = c.getDeclaringClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            if (outer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                    Field f = outer.getDeclaredField("expect" + c.getSimpleName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                    expect = f.get(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                } catch (NoSuchFieldException e1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if (expect == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            System.out.println(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                    "TEST ERROR: class " + c.getName() + " has getThing() method " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                            "but not expect field");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            failedCases.add(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        Type t = m.getGenericReturnType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
//        t = FixType.fixType(t, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        t = TypeResolver.resolveInClass(c, t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        System.out.print("..." + t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // check expected value, and incidentally equals method defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        // by private implementations of the various Type interfaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        if (expect.equals(t) && t.equals(expect))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            System.out.println(", as expected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            System.out.println(" BUT SHOULD BE " + expect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            failedCases.add(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private static class ClassNameComparator implements Comparator<Class<?>> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        public int compare(Class<?> a, Class<?> b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            return a.getName().compareTo(b.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    private static final Comparator<Class<?>> classNameComparator =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            new ClassNameComparator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    private static abstract class TypeVariableImpl<D extends GenericDeclaration>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            implements TypeVariable<D> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        private final String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        private final D gd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        private final Type[] bounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        TypeVariableImpl(String name, D gd, Type... bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            this.gd = gd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            if (bounds.length == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                bounds = new Type[] {Object.class};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            this.bounds = bounds.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        public Type[] getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            return bounds.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        public D getGenericDeclaration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            return gd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            if (!(o instanceof TypeVariable))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            TypeVariable tv = (TypeVariable) o;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            return equal(name, tv.getName()) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    equal(gd, tv.getGenericDeclaration()) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                    Arrays.equals(bounds, tv.getBounds());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            return hash(name) ^ hash(gd) ^ Arrays.hashCode(bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
11092
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   175
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   176
        public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   177
            return false; // not used
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   178
        }
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   179
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   180
        public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   181
            return null; // not used
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   182
        }
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   183
15332
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   184
        public <T extends Annotation> T[] getAnnotations(Class<T> annotationClass) {
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   185
            return null; // not used
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   186
        }
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   187
11092
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   188
        public Annotation[] getAnnotations() {
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   189
            return null; // not used
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   190
        }
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   191
15332
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   192
        public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) {
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   193
            return null; // not used
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   194
        }
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   195
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   196
        public <T extends Annotation> T[] getDeclaredAnnotations(Class<T> annotationClass) {
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   197
            return null; // not used
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   198
        }
aa02ac4b20b7 8005138: test/java/beans/Introspector/TestTypeResolver.java fails
malenkov
parents: 11092
diff changeset
   199
11092
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   200
        public Annotation[] getDeclaredAnnotations() {
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   201
            return null; // not used
6c49e728d427 7110521: Regression test failed: Introspector/TestTypeResolver.java
malenkov
parents: 5506
diff changeset
   202
        }
16468
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   203
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   204
        public AnnotatedType[] getAnnotatedBounds() {
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   205
            return null; // not used
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   206
        }
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   207
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   208
        public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   209
            return null; // not used
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   210
        }
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   211
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   212
        public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   213
            return null; // not used
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   214
        }
8675645c0757 8009880: TEST_BUG: Test java/beans/Introspector/TestTypeResolver.java should be modified again
kshefov
parents: 15332
diff changeset
   215
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    private static class ClassTypeVariable extends TypeVariableImpl<Class<?>> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        ClassTypeVariable(String name, Class<?> gd, Type... bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            super(name, gd, bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    private static class MethodTypeVariable extends TypeVariableImpl<Method> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        MethodTypeVariable(String name, Method gd, Type... bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            super(name, gd, bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    private static class WildcardTypeImpl implements WildcardType {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        private final Type[] upperBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        private final Type[] lowerBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            if (upperBounds == null || upperBounds.length == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                upperBounds = new Type[] {Object.class};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            if (lowerBounds == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                lowerBounds = new Type[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            this.upperBounds = upperBounds.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            this.lowerBounds = lowerBounds.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        public Type[] getUpperBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            return upperBounds.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        public Type[] getLowerBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            return lowerBounds.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            if (o instanceof WildcardType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                WildcardType wt = (WildcardType) o;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                return Arrays.equals(upperBounds, wt.getUpperBounds()) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                        Arrays.equals(lowerBounds, wt.getLowerBounds());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            return Arrays.hashCode(upperBounds) ^ Arrays.hashCode(lowerBounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            StringBuilder sb = new StringBuilder("?");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            if (upperBounds.length > 1 || upperBounds[0] != Object.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                sb.append(" extends");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                appendBounds(sb, upperBounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            if (lowerBounds.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                sb.append(" super");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                appendBounds(sb, lowerBounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            return sb.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        private static void appendBounds(StringBuilder sb, Type[] bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            boolean and = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            for (Type bound : bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                if (and)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                    sb.append(" &");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                sb.append(" ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                if (bound instanceof Class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                    sb.append(((Class<?>) bound).getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                    sb.append(bound);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                and = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    static boolean equal(Object x, Object y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        if (x == y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        if (x == null || y == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        return x.equals(y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    static int hash(Object x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        return (x == null) ? null : x.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    public static class Outer<T> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        public class Inner {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            public T getThing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        static final Type expectInner = new ClassTypeVariable("T", Outer.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    public static class Super<T> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        static final Type expect = new ClassTypeVariable("T", Super.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        public T getThing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    public static class Int extends Super<Integer> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        static final Type expect = Integer.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public static class IntOverride extends Int {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        static final Type expect = Integer.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        public Integer getThing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    public static class Mid<X> extends Super<X> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        static final Type expect = new ClassTypeVariable("X", Mid.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    public static class Str extends Mid<String> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        static final Type expect = String.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    public static class ListInt extends Super<List<Integer>> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                List.class, new Type[] {Integer.class}, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    public static class ListIntSub extends ListInt {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                List.class, new Type[] {Integer.class}, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        public List<Integer> getThing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    public static class ListU<U> extends Super<List<U>> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                List.class, new Type[] {new ClassTypeVariable("U", ListU.class)}, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    public static class ListUInt extends ListU<Integer> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                List.class, new Type[] {Integer.class}, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    public static class ListUSub<V> extends ListU<V> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                List.class, new Type[] {new ClassTypeVariable("V", ListUSub.class)}, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        public List<V> getThing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    public static class ListUSubInt extends ListUSub<Integer> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                List.class, new Type[] {Integer.class}, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    public static class TwoParams<S, T> extends Super<S> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        static final Type expect = new ClassTypeVariable("S", TwoParams.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    public static class TwoParamsSub<T> extends TwoParams<T, Integer> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        static final Type expect = new ClassTypeVariable("T", TwoParamsSub.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    public static class TwoParamsSubSub extends TwoParamsSub<String> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        static final Type expect = String.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    public static interface Intf<T> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        static final Type expect = new ClassTypeVariable("T", Intf.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        public T getThing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    public static abstract class Impl implements Intf<String> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        static final Type expect = String.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    public static class Impl2 extends Super<String> implements Intf<String> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        static final Type expect = String.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    public static class Bound<T extends Number> extends Super<T> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        static final Type expect = new ClassTypeVariable("T", Bound.class, Number.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    public static class BoundInt extends Bound<Integer> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        static final Type expect = Integer.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    public static class RawBound extends Bound {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        static final Type expect = Number.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    public static class RawBoundInt extends BoundInt {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        static final Type expect = Integer.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    public static class MethodParam<T> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        private static final Method m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                m = MethodParam.class.getMethod("getThing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                throw new AssertionError(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        static final Type expect = new MethodTypeVariable("T", m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        public <T> T getThing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    public static class Raw extends Super {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        static final Type expect = Object.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    public static class RawSub extends Raw {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        static final Type expect = Object.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    public static class SimpleArray extends Super<String[]> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        static final Type expect = String[].class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    public static class GenericArray extends Super<List<String>[]> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        static final Type expect = GenericArrayTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                ParameterizedTypeImpl.make(List.class, new Type[] {String.class}, null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    public static class GenericArrayT<T> extends Super<T[]> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        static final Type expect = GenericArrayTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                new ClassTypeVariable("T", GenericArrayT.class));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    public static class GenericArrayTSub extends GenericArrayT<String[]> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        static final Type expect = String[][].class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    public static class Wildcard extends Super<List<?>> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                List.class, new Type[] {new WildcardTypeImpl(null, null)}, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    public static class WildcardT<T> extends Super<List<? extends T>> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                List.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                new Type[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                        new WildcardTypeImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                                new Type[] {new ClassTypeVariable("T", WildcardT.class)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                                null)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    public static class WildcardTSub extends WildcardT<Integer> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                List.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                new Type[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                        new WildcardTypeImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                                new Type[] {Integer.class},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                                null)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    public static class WildcardTSubSub<X> extends WildcardTSub {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        // X is just so we can have a raw subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        static final Type expect = WildcardTSub.expect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    public static class RawWildcardTSubSub extends WildcardTSubSub {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        static final Type expect = List.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    public static class WildcardTSuper<T> extends Super<List<? super T>> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                List.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                new Type[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                        new WildcardTypeImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                                null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                                new Type[] {new ClassTypeVariable("T", WildcardTSuper.class)})},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    public static class WildcardTSuperSub extends WildcardTSuper<Integer> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                List.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                new Type[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                        new WildcardTypeImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                                null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                                new Type[] {Integer.class})},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    public static class SuperMap<K, V> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                Map.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                new Type[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                        new ClassTypeVariable("K", SuperMap.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                        new ClassTypeVariable("V", SuperMap.class)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        public Map<K, V> getThing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    public static class SubMap extends SuperMap<String, Integer> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                Map.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                new Type[] {String.class, Integer.class},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    public static class ListListT<T> extends Super<List<List<T>>> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                List.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                new Type[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                        ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                                List.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                                new Type[] {new ClassTypeVariable("T", ListListT.class)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                                null)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    public static class ListListString extends ListListT<String> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        static final Type expect = ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                List.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                new Type[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                        ParameterizedTypeImpl.make(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                                List.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                                new Type[] {String.class},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                                null)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    public static class UExtendsT<T, U extends T> extends Super<U> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        static final Type expect = new ClassTypeVariable(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                "U", UExtendsT.class, new ClassTypeVariable("T", UExtendsT.class));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    public static class UExtendsTSub extends UExtendsT<Number, Integer> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        static final Type expect = Integer.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    public static class SelfRef<T extends SelfRef<T>> extends Super<T> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        static final Type expect =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                SelfRef.class.getTypeParameters()[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    public static class SelfRefSub extends SelfRef<SelfRefSub> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        static final Type expect = SelfRefSub.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
}