langtools/test/tools/javac/T8013394/CompileErrorWithIteratorTest.java
author ssides
Wed, 09 Jul 2014 15:14:06 +0400
changeset 25760 7955db32d6b0
parent 19495 0a4337ec0592
child 26100 bb7dd001d190
permissions -rw-r--r--
8046597: fix doclint issues in swing classes, part 4 of 4 Reviewed-by: pchelko
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
/*
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
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
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    10
 *
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    11
 * 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
    12
 * 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
    13
 * 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
    14
 * 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
    15
 * accompanied this code).
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    16
 *
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    17
 * 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
    18
 * 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
    19
 * 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
    20
 *
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    21
 * 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
    22
 * 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
    23
 * questions.
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
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    26
/*
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    27
 * @test
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    28
 * @bug 8013394
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    29
 * @summary compile of iterator use fails with error "defined in an inaccessible class or interface"
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    30
 * @library /tools/javac/lib
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    31
 * @build ToolBox
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    32
 * @run main CompileErrorWithIteratorTest
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    33
 */
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
public class CompileErrorWithIteratorTest {
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    36
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    37
    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
    38
        "package pkg;\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    39
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    40
        "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
    41
        "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
    42
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    43
        "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
    44
        "    public testCollectionIterator iterator() {\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    45
        "        return  new testCollectionIterator();\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    46
        "    }\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    47
        "    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
    48
        "        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
    49
        "        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
    50
        "        {\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    51
        "            return null;\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    52
        "        }\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    53
        "        public void remove() {}\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    54
        "    }\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    55
        "}";
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
    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
    58
        "import pkg.TestCollection;\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    59
        "\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    60
        "public class Test {\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    61
        "\n" +
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    62
        "    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
    63
        "        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
    64
        "        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
    65
        "            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
    66
        "        }\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
        "}";
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
    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
    71
        new CompileErrorWithIteratorTest().run();
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    72
    }
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
    void run() throws Exception {
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    75
        compile();
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    76
    }
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    77
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    78
    void compile() throws Exception {
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    79
        ToolBox.JavaToolArgs javacParams =
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    80
                new ToolBox.JavaToolArgs()
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    81
                .setSources(TestCollectionSrc, TestSrc);
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    82
        ToolBox.javac(javacParams);
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    83
    }
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    84
0a4337ec0592 8013394: compile of iterator use fails with error \"defined in an inaccessible class or interface\"
vromero
parents:
diff changeset
    85
}