--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Oct 31 13:48:15 2012 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Nov 01 10:48:36 2012 +0100
@@ -27,6 +27,7 @@
import java.util.*;
import java.util.Set;
+import javax.tools.JavaFileManager;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.jvm.*;
@@ -77,6 +78,7 @@
private boolean suppressAbortOnBadClassFile;
private boolean enableSunApiLintControl;
private final TreeInfo treeinfo;
+ private final JavaFileManager fileManager;
// The set of lint options currently in effect. It is initialized
// from the context, and then is set/reset as needed by Attr as it
@@ -109,6 +111,7 @@
Options options = Options.instance(context);
lint = Lint.instance(context);
treeinfo = TreeInfo.instance(context);
+ fileManager = context.get(JavaFileManager.class);
Source source = Source.instance(context);
allowGenerics = source.allowGenerics();
@@ -3230,6 +3233,19 @@
return true;
}
+ /** Check that an auxiliary class is not accessed from any other file than its own.
+ */
+ void checkForBadAuxiliaryClassAccess(DiagnosticPosition pos, Env<AttrContext> env, ClassSymbol c) {
+ if (lint.isEnabled(Lint.LintCategory.AUXILIARYCLASS) &&
+ (c.flags() & AUXILIARY) != 0 &&
+ rs.isAccessible(env, c) &&
+ !fileManager.isSameFile(c.sourcefile, env.toplevel.sourcefile))
+ {
+ log.warning(pos, "auxiliary.class.accessed.from.outside.of.its.source.file",
+ c, c.sourcefile);
+ }
+ }
+
private class ConversionWarner extends Warner {
final String uncheckedKey;
final Type found;