--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Jan 13 13:28:20 2009 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Jan 13 13:28:42 2009 +0000
@@ -1136,11 +1136,32 @@
scanExpr(tree.encl);
scanExprs(tree.args);
// scan(tree.def);
- for (List<Type> l = tree.constructor.type.getThrownTypes();
+ for (List<Type> l = tree.constructorType.getThrownTypes();
l.nonEmpty();
- l = l.tail)
+ l = l.tail) {
markThrown(tree, l.head);
- scan(tree.def);
+ }
+ List<Type> caughtPrev = caught;
+ try {
+ // If the new class expression defines an anonymous class,
+ // analysis of the anonymous constructor may encounter thrown
+ // types which are unsubstituted type variables.
+ // However, since the constructor's actual thrown types have
+ // already been marked as thrown, it is safe to simply include
+ // each of the constructor's formal thrown types in the set of
+ // 'caught/declared to be thrown' types, for the duration of
+ // the class def analysis.
+ if (tree.def != null)
+ for (List<Type> l = tree.constructor.type.getThrownTypes();
+ l.nonEmpty();
+ l = l.tail) {
+ caught = chk.incl(l.head, caught);
+ }
+ scan(tree.def);
+ }
+ finally {
+ caught = caughtPrev;
+ }
}
public void visitNewArray(JCNewArray tree) {