Thu, 02 Aug 2012 18:24:01 +0100
7187104: Inference cleanup: remove redundant exception classes in Infer.java
Summary: Remove unused exception classes in Infer.java
Reviewed-by: jjg
src/share/classes/com/sun/tools/javac/comp/Infer.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Aug 02 18:23:21 2012 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Aug 02 18:24:01 2012 +0100 1.3 @@ -75,12 +75,7 @@ 1.4 log = Log.instance(context); 1.5 chk = Check.instance(context); 1.6 diags = JCDiagnostic.Factory.instance(context); 1.7 - ambiguousNoInstanceException = 1.8 - new NoInstanceException(true, diags); 1.9 - unambiguousNoInstanceException = 1.10 - new NoInstanceException(false, diags); 1.11 - invalidInstanceException = 1.12 - new InvalidInstanceException(diags); 1.13 + inferenceException = new InferenceException(diags); 1.14 1.15 } 1.16 1.17 @@ -92,28 +87,7 @@ 1.18 } 1.19 } 1.20 1.21 - public static class NoInstanceException extends InferenceException { 1.22 - private static final long serialVersionUID = 1; 1.23 - 1.24 - boolean isAmbiguous; // exist several incomparable best instances? 1.25 - 1.26 - NoInstanceException(boolean isAmbiguous, JCDiagnostic.Factory diags) { 1.27 - super(diags); 1.28 - this.isAmbiguous = isAmbiguous; 1.29 - } 1.30 - } 1.31 - 1.32 - public static class InvalidInstanceException extends InferenceException { 1.33 - private static final long serialVersionUID = 2; 1.34 - 1.35 - InvalidInstanceException(JCDiagnostic.Factory diags) { 1.36 - super(diags); 1.37 - } 1.38 - } 1.39 - 1.40 - private final NoInstanceException ambiguousNoInstanceException; 1.41 - private final NoInstanceException unambiguousNoInstanceException; 1.42 - private final InvalidInstanceException invalidInstanceException; 1.43 + private final InferenceException inferenceException; 1.44 1.45 /*************************************************************************** 1.46 * Auxiliary type values and classes 1.47 @@ -144,7 +118,7 @@ 1.48 /** Instantiate undetermined type variable to its minimal upper bound. 1.49 * Throw a NoInstanceException if this not possible. 1.50 */ 1.51 - void maximizeInst(UndetVar that, Warner warn) throws NoInstanceException { 1.52 + void maximizeInst(UndetVar that, Warner warn) throws InferenceException { 1.53 List<Type> hibounds = Type.filter(that.hibounds, errorFilter); 1.54 if (that.eq.isEmpty()) { 1.55 if (hibounds.isEmpty()) 1.56 @@ -158,7 +132,7 @@ 1.57 } 1.58 if (that.inst == null || 1.59 that.inst.isErroneous()) 1.60 - throw ambiguousNoInstanceException 1.61 + throw inferenceException 1.62 .setMessage("no.unique.maximal.instance.exists", 1.63 that.qtype, hibounds); 1.64 } 1.65 @@ -173,7 +147,7 @@ 1.66 /** Instantiate undetermined type variable to the lub of all its lower bounds. 1.67 * Throw a NoInstanceException if this not possible. 1.68 */ 1.69 - void minimizeInst(UndetVar that, Warner warn) throws NoInstanceException { 1.70 + void minimizeInst(UndetVar that, Warner warn) throws InferenceException { 1.71 List<Type> lobounds = Type.filter(that.lobounds, errorFilter); 1.72 if (that.eq.isEmpty()) { 1.73 if (lobounds.isEmpty()) 1.74 @@ -184,7 +158,7 @@ 1.75 that.inst = types.lub(lobounds); 1.76 } 1.77 if (that.inst == null || that.inst.tag == ERROR) 1.78 - throw ambiguousNoInstanceException 1.79 + throw inferenceException 1.80 .setMessage("no.unique.minimal.instance.exists", 1.81 that.qtype, lobounds); 1.82 } else { 1.83 @@ -228,7 +202,7 @@ 1.84 Type qtype1 = types.subst(mtype.getReturnType(), tvars, undetvars); 1.85 if (!types.isSubtype(qtype1, 1.86 qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) { 1.87 - throw unambiguousNoInstanceException 1.88 + throw inferenceException 1.89 .setMessage("infer.no.conforming.instance.exists", 1.90 tvars, mtype.getReturnType(), to); 1.91 } 1.92 @@ -382,17 +356,17 @@ 1.93 } 1.94 1.95 public InapplicableMethodException arityMismatch() { 1.96 - return unambiguousNoInstanceException.setMessage("infer.arg.length.mismatch", inferenceVars(undetvars)); 1.97 + return inferenceException.setMessage("infer.arg.length.mismatch", inferenceVars(undetvars)); 1.98 } 1.99 public InapplicableMethodException argumentMismatch(boolean varargs, JCDiagnostic details) { 1.100 String key = varargs ? 1.101 "infer.varargs.argument.mismatch" : 1.102 "infer.no.conforming.assignment.exists"; 1.103 - return unambiguousNoInstanceException.setMessage(key, 1.104 + return inferenceException.setMessage(key, 1.105 inferenceVars(undetvars), details); 1.106 } 1.107 public InapplicableMethodException inaccessibleVarargs(Symbol location, Type expected) { 1.108 - return unambiguousNoInstanceException.setMessage("inaccessible.varargs.type", 1.109 + return inferenceException.setMessage("inaccessible.varargs.type", 1.110 expected, Kinds.kindName(location), location); 1.111 } 1.112 } 1.113 @@ -405,7 +379,7 @@ 1.114 } 1.115 catch (InapplicableMethodException ex) { 1.116 // inferred method is not applicable 1.117 - throw invalidInstanceException.setMessage(ex.getDiagnostic()); 1.118 + throw inferenceException.setMessage(ex.getDiagnostic()); 1.119 } 1.120 } 1.121 1.122 @@ -415,7 +389,7 @@ 1.123 List<Type> undetvars, 1.124 List<Type> arguments, 1.125 Warner warn) 1.126 - throws InvalidInstanceException { 1.127 + throws InferenceException { 1.128 List<Type> args = arguments; 1.129 for (Type t : undetvars) { 1.130 UndetVar uv = (UndetVar)t; 1.131 @@ -496,7 +470,7 @@ 1.132 } 1.133 //where 1.134 void reportBoundError(UndetVar uv, BoundErrorKind bk) { 1.135 - throw bk.setMessage(uv.inst == null ? ambiguousNoInstanceException : invalidInstanceException, uv); 1.136 + throw bk.setMessage(inferenceException, uv); 1.137 } 1.138 1.139 /**