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

changeset 1384
bf54daa9dcd8
parent 1374
c002fdee76fd
child 1393
d7d932236fee
equal deleted inserted replaced
1383:b980e8e6aabf 1384:bf54daa9dcd8
25 25
26 package com.sun.tools.javac.comp; 26 package com.sun.tools.javac.comp;
27 27
28 import java.util.*; 28 import java.util.*;
29 import java.util.Set; 29 import java.util.Set;
30 import javax.tools.JavaFileManager;
30 31
31 import com.sun.tools.javac.code.*; 32 import com.sun.tools.javac.code.*;
32 import com.sun.tools.javac.jvm.*; 33 import com.sun.tools.javac.jvm.*;
33 import com.sun.tools.javac.tree.*; 34 import com.sun.tools.javac.tree.*;
34 import com.sun.tools.javac.util.*; 35 import com.sun.tools.javac.util.*;
75 private final JCDiagnostic.Factory diags; 76 private final JCDiagnostic.Factory diags;
76 private boolean warnOnSyntheticConflicts; 77 private boolean warnOnSyntheticConflicts;
77 private boolean suppressAbortOnBadClassFile; 78 private boolean suppressAbortOnBadClassFile;
78 private boolean enableSunApiLintControl; 79 private boolean enableSunApiLintControl;
79 private final TreeInfo treeinfo; 80 private final TreeInfo treeinfo;
81 private final JavaFileManager fileManager;
80 82
81 // The set of lint options currently in effect. It is initialized 83 // The set of lint options currently in effect. It is initialized
82 // from the context, and then is set/reset as needed by Attr as it 84 // from the context, and then is set/reset as needed by Attr as it
83 // visits all the various parts of the trees during attribution. 85 // visits all the various parts of the trees during attribution.
84 private Lint lint; 86 private Lint lint;
107 this.types = Types.instance(context); 109 this.types = Types.instance(context);
108 diags = JCDiagnostic.Factory.instance(context); 110 diags = JCDiagnostic.Factory.instance(context);
109 Options options = Options.instance(context); 111 Options options = Options.instance(context);
110 lint = Lint.instance(context); 112 lint = Lint.instance(context);
111 treeinfo = TreeInfo.instance(context); 113 treeinfo = TreeInfo.instance(context);
114 fileManager = context.get(JavaFileManager.class);
112 115
113 Source source = Source.instance(context); 116 Source source = Source.instance(context);
114 allowGenerics = source.allowGenerics(); 117 allowGenerics = source.allowGenerics();
115 allowVarargs = source.allowVarargs(); 118 allowVarargs = source.allowVarargs();
116 allowAnnotations = source.allowAnnotations(); 119 allowAnnotations = source.allowAnnotations();
3228 tree = s.selected; 3231 tree = s.selected;
3229 } 3232 }
3230 return true; 3233 return true;
3231 } 3234 }
3232 3235
3236 /** Check that an auxiliary class is not accessed from any other file than its own.
3237 */
3238 void checkForBadAuxiliaryClassAccess(DiagnosticPosition pos, Env<AttrContext> env, ClassSymbol c) {
3239 if (lint.isEnabled(Lint.LintCategory.AUXILIARYCLASS) &&
3240 (c.flags() & AUXILIARY) != 0 &&
3241 rs.isAccessible(env, c) &&
3242 !fileManager.isSameFile(c.sourcefile, env.toplevel.sourcefile))
3243 {
3244 log.warning(pos, "auxiliary.class.accessed.from.outside.of.its.source.file",
3245 c, c.sourcefile);
3246 }
3247 }
3248
3233 private class ConversionWarner extends Warner { 3249 private class ConversionWarner extends Warner {
3234 final String uncheckedKey; 3250 final String uncheckedKey;
3235 final Type found; 3251 final Type found;
3236 final Type expected; 3252 final Type expected;
3237 public ConversionWarner(DiagnosticPosition pos, String uncheckedKey, Type found, Type expected) { 3253 public ConversionWarner(DiagnosticPosition pos, String uncheckedKey, Type found, Type expected) {

mercurial