< prev index next >
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java
Print this page
*** 198,211 ****
private TreeMaker make;
private final Resolve rs;
private final JCDiagnostic.Factory diags;
private Env<AttrContext> attrEnv;
private Lint lint;
- private final boolean allowImprovedRethrowAnalysis;
- private final boolean allowImprovedCatchAnalysis;
private final boolean allowEffectivelyFinalInInnerClasses;
- private final boolean enforceThisDotInit;
public static Flow instance(Context context) {
Flow instance = context.get(flowKey);
if (instance == null)
instance = new Flow(context);
--- 198,208 ----
*** 292,305 ****
chk = Check.instance(context);
lint = Lint.instance(context);
rs = Resolve.instance(context);
diags = JCDiagnostic.Factory.instance(context);
Source source = Source.instance(context);
- allowImprovedRethrowAnalysis = Feature.IMPROVED_RETHROW_ANALYSIS.allowedInSource(source);
- allowImprovedCatchAnalysis = Feature.IMPROVED_CATCH_ANALYSIS.allowedInSource(source);
allowEffectivelyFinalInInnerClasses = Feature.EFFECTIVELY_FINAL_IN_INNER_CLASSES.allowedInSource(source);
- enforceThisDotInit = Feature.ENFORCE_THIS_DOT_INIT.allowedInSource(source);
}
/**
* Base visitor class for all visitors implementing dataflow analysis logic.
* This class define the shared logic for handling jumps (break/continue statements).
--- 289,299 ----
*** 1104,1116 ****
}
}
}
}
scan(tree.body);
! List<Type> thrownInTry = allowImprovedCatchAnalysis ?
! chk.union(thrown, List.of(syms.runtimeExceptionType, syms.errorType)) :
! thrown;
thrown = thrownPrev;
caught = caughtPrev;
List<Type> caughtInTry = List.nil();
for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
--- 1098,1108 ----
}
}
}
}
scan(tree.body);
! List<Type> thrownInTry = chk.union(thrown, List.of(syms.runtimeExceptionType, syms.errorType));
thrown = thrownPrev;
caught = caughtPrev;
List<Type> caughtInTry = List.nil();
for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
*** 1175,1185 ****
log.error(pos, Errors.ExceptAlreadyCaught(exc));
} else if (!chk.isUnchecked(pos, exc) &&
!isExceptionOrThrowable(exc) &&
!chk.intersects(exc, thrownInTry)) {
log.error(pos, Errors.ExceptNeverThrownInTry(exc));
! } else if (allowImprovedCatchAnalysis) {
List<Type> catchableThrownTypes = chk.intersect(List.of(exc), thrownInTry);
// 'catchableThrownTypes' cannnot possibly be empty - if 'exc' was an
// unchecked exception, the result list would not be empty, as the augmented
// thrown set includes { RuntimeException, Error }; if 'exc' was a checked
// exception, that would have been covered in the branch above
--- 1167,1177 ----
log.error(pos, Errors.ExceptAlreadyCaught(exc));
} else if (!chk.isUnchecked(pos, exc) &&
!isExceptionOrThrowable(exc) &&
!chk.intersects(exc, thrownInTry)) {
log.error(pos, Errors.ExceptNeverThrownInTry(exc));
! } else {
List<Type> catchableThrownTypes = chk.intersect(List.of(exc), thrownInTry);
// 'catchableThrownTypes' cannnot possibly be empty - if 'exc' was an
// unchecked exception, the result list would not be empty, as the augmented
// thrown set includes { RuntimeException, Error }; if 'exc' was a checked
// exception, that would have been covered in the branch above
*** 1215,1226 ****
scan(tree.expr);
Symbol sym = TreeInfo.symbol(tree.expr);
if (sym != null &&
sym.kind == VAR &&
(sym.flags() & (FINAL | EFFECTIVELY_FINAL)) != 0 &&
! preciseRethrowTypes.get(sym) != null &&
! allowImprovedRethrowAnalysis) {
for (Type t : preciseRethrowTypes.get(sym)) {
markThrown(tree, t);
}
}
else {
--- 1207,1217 ----
scan(tree.expr);
Symbol sym = TreeInfo.symbol(tree.expr);
if (sym != null &&
sym.kind == VAR &&
(sym.flags() & (FINAL | EFFECTIVELY_FINAL)) != 0 &&
! preciseRethrowTypes.get(sym) != null) {
for (Type t : preciseRethrowTypes.get(sym)) {
markThrown(tree, t);
}
}
else {
*** 2399,2410 ****
// check fields accessed through this.<field> are definitely
// assigned before reading their value
public void visitSelect(JCFieldAccess tree) {
super.visitSelect(tree);
! if (enforceThisDotInit &&
! TreeInfo.isThisQualifier(tree.selected) &&
tree.sym.kind == VAR) {
checkInit(tree.pos(), (VarSymbol)tree.sym);
}
}
--- 2390,2400 ----
// check fields accessed through this.<field> are definitely
// assigned before reading their value
public void visitSelect(JCFieldAccess tree) {
super.visitSelect(tree);
! if (TreeInfo.isThisQualifier(tree.selected) &&
tree.sym.kind == VAR) {
checkInit(tree.pos(), (VarSymbol)tree.sym);
}
}
< prev index next >