langtools/test/tools/javac/T8029002/MultipleUpperBoundsIncorporationTest.java
author vromero
Fri, 18 Apr 2014 17:50:30 +0100
changeset 24063 3e3c18700277
permissions -rw-r--r--
8029002: javac should take multiple upper bounds into account in incorporation Reviewed-by: dlsmith, jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24063
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
     1
/*
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
     4
 *
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
     8
 *
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    13
 * accompanied this code).
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    14
 *
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    18
 *
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    21
 * questions.
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    22
 */
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    23
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    24
/*
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    25
 * @test
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    26
 * @bug 8029002
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    27
 * @summary javac should take multiple upper bounds into account in incorporation
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    28
 * @compile MultipleUpperBoundsIncorporationTest.java
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    29
 */
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    30
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    31
import java.util.ArrayList;
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    32
import java.util.List;
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    33
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    34
public class MultipleUpperBoundsIncorporationTest {
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    35
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    36
    static class TestCase1 {
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    37
        interface Task<E extends Exception> {}
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    38
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    39
        class Comparator<T> {}
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    40
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    41
        class CustomException extends Exception {}
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    42
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    43
        class TaskQueue<E extends Exception, T extends Task<E>> {}
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    44
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    45
        abstract class Test {
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    46
            abstract <E extends Exception, T extends Task<E>> TaskQueue<E, T> create(Comparator<? super T> comparator);
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    47
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    48
            void f(Comparator<Task<CustomException>> comp) {
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    49
                TaskQueue<CustomException, Task<CustomException>> queue = create(comp);
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    50
                queue.getClass();
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    51
            }
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    52
        }
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    53
    }
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    54
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    55
    static class TestCase2 {
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    56
        public <T, E extends List<T>> E typedNull() {
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    57
            return null;
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    58
        }
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    59
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    60
        public void call() {
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    61
            ArrayList<String> list = typedNull();
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    62
        }
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    63
    }
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    64
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    65
    static class TestCase3 {
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    66
        interface I extends Iterable<String> {}
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    67
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    68
        <T, Exp extends Iterable<T>> Exp typedNull() { return null; }
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    69
        I i = typedNull();
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    70
    }
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    71
3e3c18700277 8029002: javac should take multiple upper bounds into account in incorporation
vromero
parents:
diff changeset
    72
}