1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Sep 29 11:48:09 2008 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Sep 29 12:00:29 2008 +0100 1.3 @@ -764,26 +764,32 @@ 1.4 /** Visitor method: Validate a type expression, if it is not null, catching 1.5 * and reporting any completion failures. 1.6 */ 1.7 - void validate(JCTree tree) { 1.8 + void validate(JCTree tree, Env<AttrContext> env) { 1.9 try { 1.10 - if (tree != null) tree.accept(validator); 1.11 + if (tree != null) { 1.12 + validator.env = env; 1.13 + tree.accept(validator); 1.14 + checkRaw(tree, env); 1.15 + } 1.16 } catch (CompletionFailure ex) { 1.17 completionError(tree.pos(), ex); 1.18 } 1.19 } 1.20 + //where 1.21 + void checkRaw(JCTree tree, Env<AttrContext> env) { 1.22 + if (lint.isEnabled(Lint.LintCategory.RAW) && 1.23 + tree.type.tag == CLASS && 1.24 + !env.enclClass.name.isEmpty() && //anonymous or intersection 1.25 + tree.type.isRaw()) { 1.26 + log.warning(tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type); 1.27 + } 1.28 + } 1.29 1.30 /** Visitor method: Validate a list of type expressions. 1.31 */ 1.32 - void validate(List<? extends JCTree> trees) { 1.33 + void validate(List<? extends JCTree> trees, Env<AttrContext> env) { 1.34 for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) 1.35 - validate(l.head); 1.36 - } 1.37 - 1.38 - /** Visitor method: Validate a list of type parameters. 1.39 - */ 1.40 - void validateTypeParams(List<JCTypeParameter> trees) { 1.41 - for (List<JCTypeParameter> l = trees; l.nonEmpty(); l = l.tail) 1.42 - validate(l.head); 1.43 + validate(l.head, env); 1.44 } 1.45 1.46 /** A visitor class for type validation. 1.47 @@ -791,7 +797,7 @@ 1.48 class Validator extends JCTree.Visitor { 1.49 1.50 public void visitTypeArray(JCArrayTypeTree tree) { 1.51 - validate(tree.elemtype); 1.52 + validate(tree.elemtype, env); 1.53 } 1.54 1.55 public void visitTypeApply(JCTypeApply tree) { 1.56 @@ -805,7 +811,7 @@ 1.57 // For matching pairs of actual argument types `a' and 1.58 // formal type parameters with declared bound `b' ... 1.59 while (args.nonEmpty() && forms.nonEmpty()) { 1.60 - validate(args.head); 1.61 + validate(args.head, env); 1.62 1.63 // exact type arguments needs to know their 1.64 // bounds (for upper and lower bound 1.65 @@ -849,14 +855,14 @@ 1.66 } 1.67 1.68 public void visitTypeParameter(JCTypeParameter tree) { 1.69 - validate(tree.bounds); 1.70 + validate(tree.bounds, env); 1.71 checkClassBounds(tree.pos(), tree.type); 1.72 } 1.73 1.74 @Override 1.75 public void visitWildcard(JCWildcard tree) { 1.76 if (tree.inner != null) 1.77 - validate(tree.inner); 1.78 + validate(tree.inner, env); 1.79 } 1.80 1.81 public void visitSelect(JCFieldAccess tree) { 1.82 @@ -870,7 +876,7 @@ 1.83 } 1.84 } 1.85 public void visitSelectInternal(JCFieldAccess tree) { 1.86 - if (tree.type.getEnclosingType().tag != CLASS && 1.87 + if (tree.type.tsym.isStatic() && 1.88 tree.selected.type.isParameterized()) { 1.89 // The enclosing type is not a class, so we are 1.90 // looking at a static member type. However, the 1.91 @@ -878,7 +884,7 @@ 1.92 log.error(tree.pos(), "cant.select.static.class.from.param.type"); 1.93 } else { 1.94 // otherwise validate the rest of the expression 1.95 - validate(tree.selected); 1.96 + tree.selected.accept(this); 1.97 } 1.98 } 1.99 1.100 @@ -886,6 +892,8 @@ 1.101 */ 1.102 public void visitTree(JCTree tree) { 1.103 } 1.104 + 1.105 + Env<AttrContext> env; 1.106 } 1.107 1.108 /* *************************************************************************