1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Sep 01 11:35:00 2009 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Sep 02 10:20:46 2009 -0700 1.3 @@ -60,8 +60,6 @@ 1.4 private final Log log; 1.5 private final Symtab syms; 1.6 private final Infer infer; 1.7 - private final Target target; 1.8 - private final Source source; 1.9 private final Types types; 1.10 private final JCDiagnostic.Factory diags; 1.11 private final boolean skipAnnotations; 1.12 @@ -90,18 +88,20 @@ 1.13 this.types = Types.instance(context); 1.14 diags = JCDiagnostic.Factory.instance(context); 1.15 Options options = Options.instance(context); 1.16 - target = Target.instance(context); 1.17 - source = Source.instance(context); 1.18 lint = Lint.instance(context); 1.19 treeinfo = TreeInfo.instance(context); 1.20 1.21 Source source = Source.instance(context); 1.22 allowGenerics = source.allowGenerics(); 1.23 allowAnnotations = source.allowAnnotations(); 1.24 + allowCovariantReturns = source.allowCovariantReturns(); 1.25 complexInference = options.get("-complexinference") != null; 1.26 skipAnnotations = options.get("skipAnnotations") != null; 1.27 warnOnSyntheticConflicts = options.get("warnOnSyntheticConflicts") != null; 1.28 1.29 + Target target = Target.instance(context); 1.30 + syntheticNameChar = target.syntheticNameChar(); 1.31 + 1.32 boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION); 1.33 boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED); 1.34 boolean verboseSunApi = lint.isEnabled(LintCategory.SUNAPI); 1.35 @@ -123,10 +123,18 @@ 1.36 */ 1.37 boolean allowAnnotations; 1.38 1.39 + /** Switch: covariant returns enabled? 1.40 + */ 1.41 + boolean allowCovariantReturns; 1.42 + 1.43 /** Switch: -complexinference option set? 1.44 */ 1.45 boolean complexInference; 1.46 1.47 + /** Character for synthetic names 1.48 + */ 1.49 + char syntheticNameChar; 1.50 + 1.51 /** A table mapping flat names of all compiled classes in this run to their 1.52 * symbols; maintained from outside. 1.53 */ 1.54 @@ -343,7 +351,7 @@ 1.55 for (int i=1; ; i++) { 1.56 Name flatname = names. 1.57 fromString("" + c.owner.enclClass().flatname + 1.58 - target.syntheticNameChar() + i + 1.59 + syntheticNameChar + i + 1.60 c.name); 1.61 if (compiled.get(flatname) == null) return flatname; 1.62 } 1.63 @@ -536,7 +544,7 @@ 1.64 while (args.nonEmpty()) { 1.65 if (args.head.tag == WILDCARD) 1.66 return typeTagError(pos, 1.67 - log.getLocalizedString("type.req.exact"), 1.68 + Log.getLocalizedString("type.req.exact"), 1.69 args.head); 1.70 args = args.tail; 1.71 } 1.72 @@ -794,8 +802,10 @@ 1.73 this.specialized = false; 1.74 }; 1.75 1.76 + @Override 1.77 public void visitTree(JCTree tree) { /* no-op */ } 1.78 1.79 + @Override 1.80 public void visitVarDef(JCVariableDecl tree) { 1.81 if ((tree.mods.flags & ENUM) != 0) { 1.82 if (tree.init instanceof JCNewClass && 1.83 @@ -867,10 +877,12 @@ 1.84 */ 1.85 class Validator extends JCTree.Visitor { 1.86 1.87 + @Override 1.88 public void visitTypeArray(JCArrayTypeTree tree) { 1.89 validate(tree.elemtype, env); 1.90 } 1.91 1.92 + @Override 1.93 public void visitTypeApply(JCTypeApply tree) { 1.94 if (tree.type.tag == CLASS) { 1.95 List<Type> formals = tree.type.tsym.type.allparams(); 1.96 @@ -930,6 +942,7 @@ 1.97 } 1.98 } 1.99 1.100 + @Override 1.101 public void visitTypeParameter(JCTypeParameter tree) { 1.102 validate(tree.bounds, env); 1.103 checkClassBounds(tree.pos(), tree.type); 1.104 @@ -941,6 +954,7 @@ 1.105 validate(tree.inner, env); 1.106 } 1.107 1.108 + @Override 1.109 public void visitSelect(JCFieldAccess tree) { 1.110 if (tree.type.tag == CLASS) { 1.111 visitSelectInternal(tree); 1.112 @@ -964,12 +978,14 @@ 1.113 } 1.114 } 1.115 1.116 + @Override 1.117 public void visitAnnotatedType(JCAnnotatedType tree) { 1.118 tree.underlyingType.accept(this); 1.119 } 1.120 1.121 /** Default visitor method: do nothing. 1.122 */ 1.123 + @Override 1.124 public void visitTree(JCTree tree) { 1.125 } 1.126 1.127 @@ -1241,7 +1257,7 @@ 1.128 boolean resultTypesOK = 1.129 types.returnTypeSubstitutable(mt, ot, otres, overrideWarner); 1.130 if (!resultTypesOK) { 1.131 - if (!source.allowCovariantReturns() && 1.132 + if (!allowCovariantReturns && 1.133 m.owner != origin && 1.134 m.owner.isSubClass(other.owner, types)) { 1.135 // allow limited interoperability with covariant returns 1.136 @@ -2349,6 +2365,7 @@ 1.137 this.expected = expected; 1.138 } 1.139 1.140 + @Override 1.141 public void warnUnchecked() { 1.142 boolean warned = this.warned; 1.143 super.warnUnchecked();