langtools/test/tools/javac/importscope/ImportInaccessible.java
author jlahoda
Tue, 24 Feb 2015 16:11:59 +0100
changeset 29149 3fa94aad0264
permissions -rw-r--r--
8067886: Inaccessible nested classes can be incorrectly imported Summary: Check type accessibility at the point of import when importing the type using type-import-on-demand. Reviewed-by: mcimadamore, jfranck
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29149
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
     1
/*
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
     4
 *
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
     8
 *
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    14
 *
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    18
 *
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    21
 * questions.
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    22
 */
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    23
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    24
/**
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    25
 * @test
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    26
 * @bug 8067886
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    27
 * @summary Verify that type import on demand won't put inaccessible types into the Scope
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    28
 * @compile/fail/ref=ImportInaccessible.out -XDrawDiagnostics ImportInaccessible.java
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    29
 */
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    30
package p;
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    31
import p.ImportInaccessible.Nested.*;
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    32
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    33
class ImportInaccessible {
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    34
    static class Nested<X extends Inner> {
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    35
        private static class Inner{}
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    36
     }
3fa94aad0264 8067886: Inaccessible nested classes can be incorrectly imported
jlahoda
parents:
diff changeset
    37
}