--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Nov 30 15:14:25 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Nov 30 15:14:36 2012 +0000
@@ -2458,7 +2458,7 @@
}
//attrib type-arguments
- List<Type> typeargtypes = null;
+ List<Type> typeargtypes = List.nil();
if (that.typeargs != null) {
typeargtypes = attribTypes(that.typeargs, localEnv);
}
@@ -2528,6 +2528,26 @@
}
}
+ if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
+ if (refSym.isStatic() && TreeInfo.isStaticSelector(that.expr, names) &&
+ exprType.getTypeArguments().nonEmpty()) {
+ //static ref with class type-args
+ log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
+ diags.fragment("static.mref.with.targs"));
+ result = that.type = types.createErrorType(target);
+ return;
+ }
+
+ if (refSym.isStatic() && !TreeInfo.isStaticSelector(that.expr, names) &&
+ !lookupHelper.referenceKind(refSym).isUnbound()) {
+ //no static bound mrefs
+ log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
+ diags.fragment("static.bound.mref"));
+ result = that.type = types.createErrorType(target);
+ return;
+ }
+ }
+
if (desc.getReturnType() == Type.recoveryType) {
// stop here
result = that.type = target;