src/share/classes/com/sun/tools/javac/comp/Check.java

changeset 1384
bf54daa9dcd8
parent 1374
c002fdee76fd
child 1393
d7d932236fee
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Oct 31 13:48:15 2012 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Nov 01 10:48:36 2012 +0100
     1.3 @@ -27,6 +27,7 @@
     1.4  
     1.5  import java.util.*;
     1.6  import java.util.Set;
     1.7 +import javax.tools.JavaFileManager;
     1.8  
     1.9  import com.sun.tools.javac.code.*;
    1.10  import com.sun.tools.javac.jvm.*;
    1.11 @@ -77,6 +78,7 @@
    1.12      private boolean suppressAbortOnBadClassFile;
    1.13      private boolean enableSunApiLintControl;
    1.14      private final TreeInfo treeinfo;
    1.15 +    private final JavaFileManager fileManager;
    1.16  
    1.17      // The set of lint options currently in effect. It is initialized
    1.18      // from the context, and then is set/reset as needed by Attr as it
    1.19 @@ -109,6 +111,7 @@
    1.20          Options options = Options.instance(context);
    1.21          lint = Lint.instance(context);
    1.22          treeinfo = TreeInfo.instance(context);
    1.23 +        fileManager = context.get(JavaFileManager.class);
    1.24  
    1.25          Source source = Source.instance(context);
    1.26          allowGenerics = source.allowGenerics();
    1.27 @@ -3230,6 +3233,19 @@
    1.28              return true;
    1.29          }
    1.30  
    1.31 +    /** Check that an auxiliary class is not accessed from any other file than its own.
    1.32 +     */
    1.33 +    void checkForBadAuxiliaryClassAccess(DiagnosticPosition pos, Env<AttrContext> env, ClassSymbol c) {
    1.34 +        if (lint.isEnabled(Lint.LintCategory.AUXILIARYCLASS) &&
    1.35 +            (c.flags() & AUXILIARY) != 0 &&
    1.36 +            rs.isAccessible(env, c) &&
    1.37 +            !fileManager.isSameFile(c.sourcefile, env.toplevel.sourcefile))
    1.38 +        {
    1.39 +            log.warning(pos, "auxiliary.class.accessed.from.outside.of.its.source.file",
    1.40 +                        c, c.sourcefile);
    1.41 +        }
    1.42 +    }
    1.43 +
    1.44      private class ConversionWarner extends Warner {
    1.45          final String uncheckedKey;
    1.46          final Type found;

mercurial