1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jan 28 12:01:07 2011 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jan 28 12:03:49 2011 +0000 1.3 @@ -331,7 +331,7 @@ 1.4 throws Infer.InferenceException { 1.5 boolean polymorphicSignature = m.isPolymorphicSignatureGeneric() && allowMethodHandles; 1.6 if (useVarargs && (m.flags() & VARARGS) == 0) 1.7 - throw inapplicableMethodException.setMessage(null); 1.8 + throw inapplicableMethodException.setMessage(); 1.9 Type mt = types.memberType(site, m); 1.10 1.11 // tvars is the list of formal type variables for which type arguments 1.12 @@ -386,7 +386,7 @@ 1.13 useVarargs, 1.14 warn); 1.15 1.16 - checkRawArgumentsAcceptable(argtypes, mt.getParameterTypes(), 1.17 + checkRawArgumentsAcceptable(env, argtypes, mt.getParameterTypes(), 1.18 allowBoxing, useVarargs, warn); 1.19 return mt; 1.20 } 1.21 @@ -411,19 +411,21 @@ 1.22 1.23 /** Check if a parameter list accepts a list of args. 1.24 */ 1.25 - boolean argumentsAcceptable(List<Type> argtypes, 1.26 + boolean argumentsAcceptable(Env<AttrContext> env, 1.27 + List<Type> argtypes, 1.28 List<Type> formals, 1.29 boolean allowBoxing, 1.30 boolean useVarargs, 1.31 Warner warn) { 1.32 try { 1.33 - checkRawArgumentsAcceptable(argtypes, formals, allowBoxing, useVarargs, warn); 1.34 + checkRawArgumentsAcceptable(env, argtypes, formals, allowBoxing, useVarargs, warn); 1.35 return true; 1.36 } catch (InapplicableMethodException ex) { 1.37 return false; 1.38 } 1.39 } 1.40 - void checkRawArgumentsAcceptable(List<Type> argtypes, 1.41 + void checkRawArgumentsAcceptable(Env<AttrContext> env, 1.42 + List<Type> argtypes, 1.43 List<Type> formals, 1.44 boolean allowBoxing, 1.45 boolean useVarargs, 1.46 @@ -460,6 +462,14 @@ 1.47 elt); 1.48 argtypes = argtypes.tail; 1.49 } 1.50 + //check varargs element type accessibility 1.51 + if (!isAccessible(env, elt)) { 1.52 + Symbol location = env.enclClass.sym; 1.53 + throw inapplicableMethodException.setMessage("inaccessible.varargs.type", 1.54 + elt, 1.55 + Kinds.kindName(location), 1.56 + location); 1.57 + } 1.58 } 1.59 return; 1.60 } 1.61 @@ -474,6 +484,10 @@ 1.62 this.diagnostic = null; 1.63 this.diags = diags; 1.64 } 1.65 + InapplicableMethodException setMessage() { 1.66 + this.diagnostic = null; 1.67 + return this; 1.68 + } 1.69 InapplicableMethodException setMessage(String key) { 1.70 this.diagnostic = key != null ? diags.fragment(key) : null; 1.71 return this; 1.72 @@ -482,6 +496,10 @@ 1.73 this.diagnostic = key != null ? diags.fragment(key, args) : null; 1.74 return this; 1.75 } 1.76 + InapplicableMethodException setMessage(JCDiagnostic diag) { 1.77 + this.diagnostic = diag; 1.78 + return this; 1.79 + } 1.80 1.81 public JCDiagnostic getDiagnostic() { 1.82 return diagnostic;