langtools/test/tools/javac/processing/model/type/IntersectionPropertiesTest.java
author jjg
Wed, 29 Oct 2014 17:25:23 -0700
changeset 27319 030080f03e4f
parent 22152 aec1999bb1fa
child 30730 d3ce7619db2c
permissions -rw-r--r--
8062348: langtools tests should close file manager (group 1) Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
     1
/*
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 22152
diff changeset
     2
 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
     4
 *
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
     8
 *
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    13
 * accompanied this code).
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    14
 *
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    18
 *
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    21
 * questions.
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    22
 */
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    23
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    24
/*
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    25
 * @test
22152
aec1999bb1fa 8029715: test needs bugID added to @bug tag
jlahoda
parents: 21890
diff changeset
    26
 * @bug 6499673 6557966
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    27
 * @library /tools/javac/lib
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    28
 * @build JavacTestingAbstractProcessor IntersectionPropertiesTest
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    29
 * @run main IntersectionPropertiesTest
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    30
 * @summary Assertion check for TypeVariable.getUpperBound() fails
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    31
 */
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    32
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    33
import com.sun.source.util.*;
21890
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
    34
import com.sun.tools.javac.util.Assert;
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    35
import javax.annotation.processing.*;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    36
import javax.lang.model.type.*;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    37
import javax.lang.model.util.ElementFilter;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    38
import javax.lang.model.element.*;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    39
import javax.tools.*;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    40
import java.util.*;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    41
import java.io.*;
21890
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
    42
import javax.lang.model.util.Types;
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    43
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    44
public class IntersectionPropertiesTest {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    45
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    46
    private int errors = 0;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    47
    private static final String Intersection_name = "IntersectionTest.java";
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    48
    private static final String Intersection_contents =
21890
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
    49
        "import java.util.AbstractList;\n" +
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    50
        "import java.util.List;\n" +
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    51
        "import java.io.Serializable;\t" +
21890
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
    52
        "public class IntersectionTest<S extends List & Serializable, One extends AbstractList & Runnable & Serializable, Two extends AbstractList & Serializable & Runnable> {\n" +
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
    53
        "  void method(S s, One o, Two t) { }\n" +
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
    54
        "  public static abstract class SubType extends AbstractList implements Runnable, Serializable { } \n" +
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    55
        "}";
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    56
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    57
    private static final File classesdir = new File("intersectionproperties");
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    58
    private static final JavaCompiler comp =
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    59
        ToolProvider.getSystemJavaCompiler();
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    60
    private static final StandardJavaFileManager fm =
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    61
        comp.getStandardFileManager(null, null, null);
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    62
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    63
    public void runOne(final String Test_name, final String Test_contents)
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    64
        throws IOException {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    65
        System.err.println("Testing " + Test_name);
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    66
        final Iterable<? extends JavaFileObject> files =
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    67
            fm.getJavaFileObjectsFromFiles(Collections.singleton(writeFile(classesdir, Test_name, Test_contents)));
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    68
        final JavacTask ct =
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    69
            (JavacTask)comp.getTask(null, fm, null, null, null, files);
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    70
        ct.setProcessors(Collections.singleton(new TestProcessor()));
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    71
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    72
        if (!ct.call()) {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    73
            System.err.println("Compilation unexpectedly failed");
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    74
            errors++;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    75
        }
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    76
    }
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    77
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    78
    public void run() throws IOException {
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 22152
diff changeset
    79
        try {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 22152
diff changeset
    80
            runOne(Intersection_name, Intersection_contents);
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    81
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 22152
diff changeset
    82
            if (0 != errors)
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 22152
diff changeset
    83
                throw new RuntimeException(errors + " errors occurred");
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 22152
diff changeset
    84
        } finally {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 22152
diff changeset
    85
            fm.close();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 22152
diff changeset
    86
        }
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    87
    }
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    88
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    89
    public static void main(String... args) throws IOException {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    90
        new IntersectionPropertiesTest().run();
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    91
    }
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    92
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    93
    private static File writeFile(File dir, String path, String body)
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    94
        throws IOException {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    95
        File f = new File(dir, path);
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    96
        f.getParentFile().mkdirs();
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    97
        try (FileWriter out = new FileWriter(f)) {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    98
            out.write(body);
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
    99
        }
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   100
        return f;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   101
    }
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   102
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   103
    private class TestProcessor extends JavacTestingAbstractProcessor {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   104
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   105
        private Set<? extends Element> rootElements;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   106
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   107
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   108
            rootElements = roundEnv.getRootElements();
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   109
            if (!rootElements.isEmpty()) {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   110
                performCheck();
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   111
            }
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   112
            return true;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   113
        }
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   114
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   115
        private void performCheck() {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   116
            TypeElement typeElement = (TypeElement) rootElements.iterator().next();
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   117
            ExecutableElement method = ElementFilter.methodsIn(typeElement.getEnclosedElements()).get(0);
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   118
            TypeVariable typeVariable = (TypeVariable) method.getParameters().get(0).asType();
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   119
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   120
            final TypeMirror upperBound = typeVariable.getUpperBound();
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   121
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   122
            TypeParameterElement typeParameterElement = ((TypeParameterElement) typeVariable.asElement());
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   123
            final List<? extends TypeMirror> bounds = typeParameterElement.getBounds();
21890
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   124
            Types types = processingEnv.getTypeUtils();
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   125
            final HashSet<TypeMirror> actual = new HashSet<TypeMirror>(types.directSupertypes(upperBound));
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   126
            final HashSet<TypeMirror> expected = new HashSet<TypeMirror>(bounds);
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   127
            if (!expected.equals(actual)) {
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   128
                System.err.println("Mismatched expected and actual bounds.");
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   129
                System.err.println("Expected:");
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   130
                for(TypeMirror tm : expected)
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   131
                    System.err.println("  " + tm);
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   132
                System.err.println("Actual:");
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   133
                for(TypeMirror tm : actual)
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   134
                    System.err.println("  " + tm);
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   135
                errors++;
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   136
            }
21890
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   137
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   138
            TypeVariable oneTypeVariable = (TypeVariable) method.getParameters().get(1).asType();
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   139
            TypeMirror oneUpperBound = oneTypeVariable.getUpperBound();
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   140
            TypeVariable twoTypeVariable = (TypeVariable) method.getParameters().get(2).asType();
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   141
            TypeMirror twoUpperBound = twoTypeVariable.getUpperBound();
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   142
            TypeElement oneUpperBoundElement = (TypeElement) types.asElement(oneUpperBound);
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   143
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   144
            Assert.checkNonNull(oneUpperBoundElement);
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   145
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   146
            Assert.check("java.util.AbstractList".equals(oneUpperBoundElement.getSuperclass().toString()),
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   147
                         oneUpperBoundElement.getSuperclass().toString());
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   148
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   149
            List<String> superInterfaces = new java.util.ArrayList<>();
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   150
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   151
            for (TypeMirror tm : oneUpperBoundElement.getInterfaces()) {
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   152
                superInterfaces.add(tm.toString());
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   153
            }
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   154
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   155
            Assert.check(java.util.Arrays.asList("java.lang.Runnable",
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   156
                                                 "java.io.Serializable").equals(superInterfaces),
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   157
                         superInterfaces);
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   158
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   159
            Assert.check(types.isSameType(upperBound, types.capture(upperBound)));
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   160
            Assert.check(types.isSameType(types.erasure(typeVariable), types.erasure(upperBound)));
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   161
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   162
            TypeElement subTypeClass = processingEnv.getElementUtils().getTypeElement("IntersectionTest.SubType");
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   163
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   164
            Assert.checkNonNull(subTypeClass);
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   165
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   166
            Assert.check(types.isAssignable(subTypeClass.asType(), oneUpperBound));
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   167
            Assert.check(types.isSameType(oneUpperBound, twoUpperBound));
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   168
            Assert.check(!types.isSameType(upperBound, twoUpperBound));
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   169
            Assert.check(types.isSubtype(subTypeClass.asType(), oneUpperBound));
a627c91c71db 6557966: Multiple upper bounds of the TypeVariable
jlahoda
parents: 20252
diff changeset
   170
            Assert.check(types.isSubtype(oneUpperBound, upperBound));
20252
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   171
        }
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   172
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   173
    }
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   174
fae5c47ba7a4 6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff changeset
   175
}