langtools/test/tools/javac/T8013394/CompileErrorWithIteratorTest.java
author alundblad
Wed, 26 Aug 2015 09:02:02 +0200
changeset 32337 c9d3ab9f601c
parent 30730 d3ce7619db2c
child 36526 3b41f1c69604
permissions -rw-r--r--
8133671: langtools tests have bad license Summary: Dropped classpath exception from copyright notice in tests. Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19495
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26100
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
19495
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     4
 *
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
32337
c9d3ab9f601c 8133671: langtools tests have bad license
alundblad
parents: 30730
diff changeset
     7
 * published by the Free Software Foundation.
19495
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     8
 *
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    13
 * accompanied this code).
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    14
 *
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    18
 *
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    21
 * questions.
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    22
 */
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    23
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    24
/*
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    25
 * @test
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    26
 * @bug 8013394
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    27
 * @summary compile of iterator use fails with error "defined in an inaccessible class or interface"
26100
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 19495
diff changeset
    28
 * @library /tools/lib
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26100
diff changeset
    29
 * @modules jdk.compiler/com.sun.tools.javac.api
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26100
diff changeset
    30
 *          jdk.compiler/com.sun.tools.javac.file
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26100
diff changeset
    31
 *          jdk.compiler/com.sun.tools.javac.main
19495
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    32
 * @build ToolBox
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    33
 * @run main CompileErrorWithIteratorTest
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    34
 */
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    35
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    36
public class CompileErrorWithIteratorTest {
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    37
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    38
    private static final String TestCollectionSrc =
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    39
        "package pkg;\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    40
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    41
        "import java.util.Iterator;\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    42
        "import java.util.NoSuchElementException;\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    43
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    44
        "public class TestCollection<E> implements Iterable<E> {\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    45
        "    public testCollectionIterator iterator() {\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    46
        "        return  new testCollectionIterator();\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    47
        "    }\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    48
        "    class testCollectionIterator implements Iterator<E> {\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    49
        "        public boolean hasNext() { return true; }\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    50
        "        public E next() throws NoSuchElementException\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    51
        "        {\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    52
        "            return null;\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    53
        "        }\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    54
        "        public void remove() {}\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    55
        "    }\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    56
        "}";
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    57
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    58
    private static final String TestSrc =
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    59
        "import pkg.TestCollection;\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    60
        "\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    61
        "public class Test {\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    62
        "\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    63
        "    public static void main(String[] args) {\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    64
        "        TestCollection<String>  tc1 = new TestCollection<String>();\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    65
        "        for (String s : tc1) {\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    66
        "            System.out.println(s);\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    67
        "        }\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    68
        "      }\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    69
        "}";
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    70
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    71
    public static void main(String args[]) throws Exception {
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    72
        new CompileErrorWithIteratorTest().run();
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    73
    }
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    74
26100
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 19495
diff changeset
    75
    ToolBox tb = new ToolBox();
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 19495
diff changeset
    76
19495
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    77
    void run() throws Exception {
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    78
        compile();
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    79
    }
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    80
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    81
    void compile() throws Exception {
26100
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 19495
diff changeset
    82
        tb.new JavacTask()
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 19495
diff changeset
    83
                .sources(TestCollectionSrc, TestSrc)
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 19495
diff changeset
    84
                .run();
19495
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    85
    }
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    86
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    87
}