diff --git a/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/EnsuresNonNull.java b/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/EnsuresNonNull.java index 81c371eb032..011a9ffa9ef 100644 --- a/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/EnsuresNonNull.java +++ b/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/EnsuresNonNull.java @@ -9,10 +9,9 @@ import org.checkerframework.framework.qual.InheritedAnnotation; import org.checkerframework.framework.qual.PostconditionAnnotation; -// TODO: In a fix for https://tinyurl.com/cfissue/1917, add the text: -// Every prefix expression is also non-null; for example, {@code -// @EnsuresNonNull(expression="a.b.c")} implies that both {@code a.b} and {@code a.b.c} are -// non-null. +// TODO: In a fix for https://tinyurl.com/cfissue/1917, add the text: Every prefix expression is +// also non-null; for example, {@code @EnsuresNonNull(expression="a.b.c")} implies that both {@code +// a.b} and {@code a.b.c} are non-null. /** * Indicates that the value expressions are non-null just after a method call, if the method * terminates successfully. diff --git a/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/EnsuresNonNullIf.java b/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/EnsuresNonNullIf.java index 5fe0f831630..2d216cc141c 100644 --- a/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/EnsuresNonNullIf.java +++ b/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/EnsuresNonNullIf.java @@ -9,10 +9,9 @@ import org.checkerframework.framework.qual.ConditionalPostconditionAnnotation; import org.checkerframework.framework.qual.InheritedAnnotation; -// TODO: In a fix for https://tinyurl.com/cfissue/1917, add the text: -// Every prefix expression is also non-null; for example, -// {@code @EnsuresNonNullIf(expression="a.b.c", results=true)} implies that both {@code a.b} and -// {@code a.b.c} are non-null if the method returns {@code true}. +// TODO: In a fix for https://tinyurl.com/cfissue/1917, add the text: Every prefix expression is +// also non-null; for example, {@code @EnsuresNonNullIf(expression="a.b.c", results=true)} implies +// that both {@code a.b} and {@code a.b.c} are non-null if the method returns {@code true}. /** * Indicates that the given expressions are non-null, if the method returns the given result (either * true or false). diff --git a/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/RequiresNonNull.java b/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/RequiresNonNull.java index 64570f76fc0..e1a73e546af 100644 --- a/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/RequiresNonNull.java +++ b/checker-qual/src/main/java/org/checkerframework/checker/nullness/qual/RequiresNonNull.java @@ -7,10 +7,9 @@ import java.lang.annotation.Target; import org.checkerframework.framework.qual.PreconditionAnnotation; -// TODO: In a fix for https://tinyurl.com/cfissue/1917, add the text: -// Every prefix expression must also be non-null; for example, {@code -// @RequiresNonNull(expression="a.b.c")} implies that both {@code a.b} and {@code a.b.c} must be -// non-null. +// TODO: In a fix for https://tinyurl.com/cfissue/1917, add the text: Every prefix expression must +// also be non-null; for example, {@code @RequiresNonNull(expression="a.b.c")} implies that both +// {@code a.b} and {@code a.b.c} must be non-null. /** * Indicates a method precondition: the method expects the specified expressions to be non-null when * the annotated method is invoked. diff --git a/checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/LeakedToResult.java b/checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/LeakedToResult.java index 4916eaa4885..1e692e3745a 100644 --- a/checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/LeakedToResult.java +++ b/checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/LeakedToResult.java @@ -21,9 +21,9 @@ * @checker_framework.manual #aliasing-checker Aliasing Checker */ -// This is a type qualifier because of a checker framework limitation (Issue 383), but its -// hierarchy is ignored. Once the stub parser gets updated to read non-type-qualifiers -// annotations on stub files, this annotation won't be a type qualifier anymore. +// This is a type qualifier because of a checker framework limitation (Issue 383), but its hierarchy +// is ignored. Once the stub parser gets updated to read non-type-qualifiers annotations on stub +// files, this annotation won't be a type qualifier anymore. @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/NonLeaked.java b/checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/NonLeaked.java index e43b5a791ae..3fca72cdf66 100644 --- a/checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/NonLeaked.java +++ b/checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/NonLeaked.java @@ -20,9 +20,9 @@ * @checker_framework.manual #aliasing-checker Aliasing Checker */ -// This is a type qualifier because of a checker framework limitation (Issue 383), but its -// hierarchy is ignored. Once the stub parser gets updated to read non-type-qualifiers -// annotations on stub files, this annotation won't be a type qualifier anymore. +// This is a type qualifier because of a checker framework limitation (Issue 383), but its hierarchy +// is ignored. Once the stub parser gets updated to read non-type-qualifiers annotations on stub +// files, this annotation won't be a type qualifier anymore. @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/checker/jtreg/nullness/Issue347-con.out b/checker/jtreg/nullness/Issue347-con.out index 949921c7132..471c499a942 100644 --- a/checker/jtreg/nullness/Issue347-con.out +++ b/checker/jtreg/nullness/Issue347-con.out @@ -1,2 +1,2 @@ -Issue347.java:33:5: compiler.err.proc.messager: [dereference.of.nullable] dereference of possibly-null reference nble +Issue347.java:32:5: compiler.err.proc.messager: [dereference.of.nullable] dereference of possibly-null reference nble 1 error diff --git a/checker/jtreg/nullness/Issue347.java b/checker/jtreg/nullness/Issue347.java index 583d53d4b9d..0ebc27dba7b 100644 --- a/checker/jtreg/nullness/Issue347.java +++ b/checker/jtreg/nullness/Issue347.java @@ -19,9 +19,8 @@ void testMono() { if (mono == null) { return; } - // The object referenced by mono might change, but - // it can't become null again, even in concurrent - // semantics. + // The object referenced by mono might change, but it can't become null again, even in + // concurrent semantics. mono.toString(); } diff --git a/checker/jtreg/nullness/inheritDeclAnnoPersist/Extends.java b/checker/jtreg/nullness/inheritDeclAnnoPersist/Extends.java index 38146ec9fb5..1cf830d1017 100644 --- a/checker/jtreg/nullness/inheritDeclAnnoPersist/Extends.java +++ b/checker/jtreg/nullness/inheritDeclAnnoPersist/Extends.java @@ -22,8 +22,7 @@ public String m2() { } // Issue 342 - // We do not want that behavior with related annotations. @Pure should - // override @SideEffectFree. + // We do not want that behavior with related annotations. @Pure should override @SideEffectFree. @ADescriptions({ @ADescription(annotation = "org/checkerframework/dataflow/qual/Pure"), @ADescription(annotation = "org/checkerframework/dataflow/qual/SideEffectFree") diff --git a/checker/src/main/java/org/checkerframework/checker/calledmethods/CalledMethodsAnnotatedTypeFactory.java b/checker/src/main/java/org/checkerframework/checker/calledmethods/CalledMethodsAnnotatedTypeFactory.java index ddd486af720..dfbffd2e16f 100644 --- a/checker/src/main/java/org/checkerframework/checker/calledmethods/CalledMethodsAnnotatedTypeFactory.java +++ b/checker/src/main/java/org/checkerframework/checker/calledmethods/CalledMethodsAnnotatedTypeFactory.java @@ -215,10 +215,9 @@ filterTree, collectionsSingletonList, getProcessingEnv())) { // Proceed leftward (toward the receiver) in a fluent call sequence. filterTree = TreeUtils.getReceiverTree(filterTreeAsMethodInvocation.getMethodSelect()); } - // The loop has reached the beginning of a fluent sequence of method calls. - // If the ultimate receiver at the beginning of that fluent sequence is a - // call to the Filter() constructor, then use the first argument to the Filter - // constructor, which is the name of the filter. + // The loop has reached the beginning of a fluent sequence of method calls. If the ultimate + // receiver at the beginning of that fluent sequence is a call to the Filter() constructor, then + // use the first argument to the Filter constructor, which is the name of the filter. if (filterTree == null) { return null; } diff --git a/checker/src/main/java/org/checkerframework/checker/calledmethods/builder/AutoValueSupport.java b/checker/src/main/java/org/checkerframework/checker/calledmethods/builder/AutoValueSupport.java index ccb0af66aeb..e596d2eaa18 100644 --- a/checker/src/main/java/org/checkerframework/checker/calledmethods/builder/AutoValueSupport.java +++ b/checker/src/main/java/org/checkerframework/checker/calledmethods/builder/AutoValueSupport.java @@ -246,10 +246,9 @@ private static String autoValuePropToBuilderSetterName( } } - // Could not find a corresponding setter. This is likely because an AutoValue Extension is - // in use. See https://github.com/kelloggm/object-construction-checker/issues/110 . - // For now we return null, but once that bug is fixed, this should be changed to an - // assertion failure. + // Could not find a corresponding setter. This is likely because an AutoValue Extension is in + // use. See https://github.com/kelloggm/object-construction-checker/issues/110 . For now we + // return null, but once that bug is fixed, this should be changed to an assertion failure. return null; } @@ -277,8 +276,7 @@ private List getAutoValueRequiredProperties( */ private boolean isAutoValueRequiredProperty(Element member, Set avBuilderSetterNames) { String name = member.getSimpleName().toString(); - // Ignore java.lang.Object overrides, constructors, and toBuilder methods in AutoValue - // classes. + // Ignore java.lang.Object overrides, constructors, and toBuilder methods in AutoValue classes. // Strictly speaking, this code should check return types, etc. to handle strange // overloads and other corner cases. They seem unlikely enough that we are skipping for now. if (ArraysPlume.indexOf( diff --git a/checker/src/main/java/org/checkerframework/checker/calledmethods/builder/LombokSupport.java b/checker/src/main/java/org/checkerframework/checker/calledmethods/builder/LombokSupport.java index fa46794ce99..51b8d1196f8 100644 --- a/checker/src/main/java/org/checkerframework/checker/calledmethods/builder/LombokSupport.java +++ b/checker/src/main/java/org/checkerframework/checker/calledmethods/builder/LombokSupport.java @@ -145,10 +145,9 @@ private List getLombokRequiredProperties(final Element lombokClassElemen List defaultedPropertyNames = new ArrayList<>(); for (Element member : lombokClassElement.getEnclosedElements()) { if (member.getKind() == ElementKind.FIELD) { - // Lombok never generates non-null fields with initializers in builders, unless - // the field is annotated with @Default or @Singular, which are handled elsewhere. - // So, this code doesn't need to consider whether the field has or does not have - // initializers. + // Lombok never generates non-null fields with initializers in builders, unless the field is + // annotated with @Default or @Singular, which are handled elsewhere. So, this code doesn't + // need to consider whether the field has or does not have initializers. for (AnnotationMirror anm : atypeFactory.getElementUtils().getAllAnnotationMirrors(member)) { if (NONNULL_ANNOTATIONS.contains(AnnotationUtils.annotationName(anm))) { @@ -165,13 +164,12 @@ private List getLombokRequiredProperties(final Element lombokClassElemen defaultedPropertyNames.add(propName); } } else if (member.getKind().isClass() && member.toString().endsWith("Builder")) { - // Note that the test above will fail to catch builders generated by Lombok - // that have custom names using the builderClassName attribute. TODO: find a way - // to handle such builders too. + // Note that the test above will fail to catch builders generated by Lombok that have custom + // names using the builderClassName attribute. TODO: find a way to handle such builders too. - // If a field bar has an @Singular annotation, Lombok always generates a method - // called clearBar in the builder class itself. Therefore, search the builder for - // such a method, and extract the appropriate property name to treat as defaulted. + // If a field bar has an @Singular annotation, Lombok always generates a method called + // clearBar in the builder class itself. Therefore, search the builder for such a method, + // and extract the appropriate property name to treat as defaulted. for (Element builderMember : member.getEnclosedElements()) { if (builderMember.getKind() == ElementKind.METHOD && ElementUtils.hasAnnotation(builderMember, "lombok.Generated")) { diff --git a/checker/src/main/java/org/checkerframework/checker/fenum/FenumVisitor.java b/checker/src/main/java/org/checkerframework/checker/fenum/FenumVisitor.java index 78bc03e80bf..b703bc17941 100644 --- a/checker/src/main/java/org/checkerframework/checker/fenum/FenumVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/fenum/FenumVisitor.java @@ -83,10 +83,9 @@ protected Set getExceptionParameterLowerBoundAnnotat @Override public boolean isValidUse( AnnotatedDeclaredType declarationType, AnnotatedDeclaredType useType, Tree tree) { - // The checker calls this method to compare the annotation used in a - // type to the modifier it adds to the class declaration. As our default - // modifier is FenumBottom, this results in an error when a non-subtype - // is used. Can we use FenumTop as default instead? + // The checker calls this method to compare the annotation used in a type to the modifier it + // adds to the class declaration. As our default modifier is FenumBottom, this results in an + // error when a non-subtype is used. Can we use FenumTop as default instead? return true; } } diff --git a/checker/src/main/java/org/checkerframework/checker/formatter/FormatterTreeUtil.java b/checker/src/main/java/org/checkerframework/checker/formatter/FormatterTreeUtil.java index 7f386867076..bfa9a1090b0 100644 --- a/checker/src/main/java/org/checkerframework/checker/formatter/FormatterTreeUtil.java +++ b/checker/src/main/java/org/checkerframework/checker/formatter/FormatterTreeUtil.java @@ -191,9 +191,8 @@ public boolean isFormatMethodCall(MethodInvocationTree node, AnnotatedTypeFactor ExecutableElement methodElement = TreeUtils.elementFromUse(invocationTree); int formatStringIndex = FormatterVisitor.formatStringIndex(methodElement); if (formatStringIndex == -1) { - // Reporting the error is redundant if the method was declared in source code, because - // the visitor will have reported it; but it is necessary if the method was declared in - // byte code. + // Reporting the error is redundant if the method was declared in source code, because the + // visitor will have reported it; but it is necessary if the method was declared in byte code. atypeFactory .getChecker() .reportError(invocationTree, "format.method.invalid", methodElement.getSimpleName()); diff --git a/checker/src/main/java/org/checkerframework/checker/formatter/FormatterVisitor.java b/checker/src/main/java/org/checkerframework/checker/formatter/FormatterVisitor.java index d1ff109f0c8..6c50981fc7c 100644 --- a/checker/src/main/java/org/checkerframework/checker/formatter/FormatterVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/formatter/FormatterVisitor.java @@ -80,8 +80,7 @@ public Void visitMethodInvocation(MethodInvocationTree node, Void p) { int argl = argTypes.length; int formatl = formatCats.length; if (argl < formatl) { - // For assignments, format.missing.arguments is issued - // from commonAssignmentCheck. + // For assignments, format.missing.arguments is issued from commonAssignmentCheck. // II.1 ftu.failure(invc, "format.missing.arguments", formatl, argl); } else { diff --git a/checker/src/main/java/org/checkerframework/checker/guieffect/GuiEffectTypeFactory.java b/checker/src/main/java/org/checkerframework/checker/guieffect/GuiEffectTypeFactory.java index bc516deb9f1..2d4a0f14ec2 100644 --- a/checker/src/main/java/org/checkerframework/checker/guieffect/GuiEffectTypeFactory.java +++ b/checker/src/main/java/org/checkerframework/checker/guieffect/GuiEffectTypeFactory.java @@ -134,8 +134,7 @@ public boolean isUIType(TypeElement cls) { } // Anon inner classes should not inherit the package annotation, since - // they're so often used for closures to run async on background - // threads. + // they're so often used for closures to run async on background threads. if (isAnonymousType(cls)) { // However, we need to look into Anonymous class effect inference if (uiAnonClasses.contains(cls)) { @@ -250,10 +249,9 @@ public Effect getDeclaredEffect(ExecutableElement methodElt) { return new Effect(UIEffect.class); } - // Anonymous inner types should just get the effect of the parent by - // default, rather than annotating every instance. Unless it's - // implementing a polymorphic supertype, in which case we still want the - // developer to be explicit. + // Anonymous inner types should just get the effect of the parent by default, rather than + // annotating every instance. Unless it's implementing a polymorphic supertype, in which case we + // still want the developer to be explicit. if (isAnonymousType(targetClassElt)) { boolean canInheritParentEffects = true; // Refine this for polymorphic parents DeclaredType directSuper = (DeclaredType) targetClassElt.getSuperclass(); @@ -489,9 +487,8 @@ public Effect.EffectRange findInheritedEffectRange( assert eff.isPoly(); polyOverriden = overriddenMethodElt; if (isUI) { - // Need to special case an anonymous class with @UI on - // the decl, because "new @UI Runnable {...}" parses as - // @UI on an anon class decl extending Runnable + // Need to special case an anonymous class with @UI on the decl, because "new @UI Runnable + // {...}" parses as @UI on an anon class decl extending Runnable boolean isAnonInstantiation = isAnonymousType(declaringType) && (fromElement(declaringType).hasAnnotation(UI.class) diff --git a/checker/src/main/java/org/checkerframework/checker/guieffect/GuiEffectVisitor.java b/checker/src/main/java/org/checkerframework/checker/guieffect/GuiEffectVisitor.java index 112c93ebf76..c609ca5adcf 100644 --- a/checker/src/main/java/org/checkerframework/checker/guieffect/GuiEffectVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/guieffect/GuiEffectVisitor.java @@ -114,9 +114,8 @@ protected boolean checkReceiverOverride() { overriddenType.getUnderlyingType().asElement(), PolyUIType.class) != null; // TODO: How much validation do I need here? Do I need to check that the overridden - // receiver was really @PolyUI and the method is really an @PolyUIEffect? I don't - // think so - we know it's a polymorphic parent type, so all receivers would be - // @PolyUI. + // receiver was really @PolyUI and the method is really an @PolyUIEffect? I don't think so + // - we know it's a polymorphic parent type, so all receivers would be @PolyUI. // Java would already reject before running type annotation processors if the Java // types were wrong. // The *only* extra leeway we want to permit is overriding @PolyUI receiver to @@ -359,19 +358,18 @@ public Void visitMethodInvocation(MethodInvocationTree node, Void p) { @Override public Void visitMethod(MethodTree node, Void p) { - // TODO: If the type we're in is a polymorphic (over effect qualifiers) type, the receiver - // must be @PolyUI. Otherwise a "non-polymorphic" method of a polymorphic type could be - // called on a UI instance, which then gets a Safe reference to itself (unsound!) that it - // can then pass off elsewhere (dangerous!). So all receivers in methods of a @PolyUIType - // must be @PolyUI. + // TODO: If the type we're in is a polymorphic (over effect qualifiers) type, the receiver must + // be @PolyUI. Otherwise a "non-polymorphic" method of a polymorphic type could be called on a + // UI instance, which then gets a Safe reference to itself (unsound!) that it can then pass off + // elsewhere (dangerous!). So all receivers in methods of a @PolyUIType must be @PolyUI. // TODO: What do we do then about classes that inherit from a concrete instantiation? If it - // subclasses a Safe instantiation, all is well. If it subclasses a UI instantiation, then - // the receivers should probably be @UI in both new and override methods, so calls to - // polymorphic methods of the parent class will work correctly. In which case for proving - // anything, the qualifier on sublasses of UI instantiations would always have to be - // @UI... Need to write down |- t for this system! And the judgments for method overrides - // and inheritance! Those are actually the hardest part of the system. + // subclasses a Safe instantiation, all is well. If it subclasses a UI instantiation, then the + // receivers should probably be @UI in both new and override methods, so calls to polymorphic + // methods of the parent class will work correctly. In which case for proving anything, the + // qualifier on sublasses of UI instantiations would always have to be @UI... Need to write down + // |- t for this system! And the judgments for method overrides and inheritance! Those are + // actually the hardest part of the system. ExecutableElement methElt = TreeUtils.elementFromDeclaration(node); if (debugSpew) { @@ -404,8 +402,7 @@ public Void visitMethod(MethodTree node, Void p) { atypeFactory.findInheritedEffectRange( ((TypeElement) methElt.getEnclosingElement()), methElt, true, node); // if (targetUIP == null && targetSafeP == null && targetPolyP == null) { - // implicitly annotate this method with the LUB of the effects of the methods it - // overrides + // implicitly annotate this method with the LUB of the effects of the methods it overrides // atypeFactory.fromElement(methElt).addAnnotation(range != null ? range.min.getAnnot() // : (isUIType(((TypeElement)methElt.getEnclosingElement())) ? UI.class : // AlwaysSafe.class)); @@ -574,7 +571,7 @@ private void scanUp(TreePath path) { // Push a null method and UI effect onto the stack for static field initialization // TODO: Figure out if this is safe! For static data, almost certainly, // but for statically initialized instance fields, I'm assuming those - // are implicitly moved into each constructor, which must then be @UI + // are implicitly moved into each constructor, which must then be @UI. // currentMethods.addFirst(null); // effStack.addFirst(new Effect(UIEffect.class)); // super.processClassTree(node); diff --git a/checker/src/main/java/org/checkerframework/checker/i18nformatter/I18nFormatterTransfer.java b/checker/src/main/java/org/checkerframework/checker/i18nformatter/I18nFormatterTransfer.java index 45bab106e94..a366029cd7c 100644 --- a/checker/src/main/java/org/checkerframework/checker/i18nformatter/I18nFormatterTransfer.java +++ b/checker/src/main/java/org/checkerframework/checker/i18nformatter/I18nFormatterTransfer.java @@ -69,7 +69,7 @@ public TransferResult visitMethodInvocation( // @I18nMakeFormat that will be used to annotate ResourceBundle.getString() so that when the // getString() method is called, this will check if the given key exist in the translation // file and annotate the result string with the correct format annotation according to the - // corresponding key's value + // corresponding key's value. if (tu.isMakeFormatCall(node, atypeFactory)) { Result cats = tu.makeFormatCallCategories(node, atypeFactory); if (cats.value() == null) { diff --git a/checker/src/main/java/org/checkerframework/checker/i18nformatter/I18nFormatterVisitor.java b/checker/src/main/java/org/checkerframework/checker/i18nformatter/I18nFormatterVisitor.java index 6fe65f1c35e..7dd5d81c14e 100644 --- a/checker/src/main/java/org/checkerframework/checker/i18nformatter/I18nFormatterVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/i18nformatter/I18nFormatterVisitor.java @@ -66,9 +66,8 @@ private void checkInvocationFormatFor(I18nFormatCall fc) { int paraml = paramTypes.length; int formatl = formatCats.length; - // For assignments, i18nformat.missing.arguments and - // i18nformat.excess.arguments are issued - // from commonAssignmentCheck. + // For assignments, i18nformat.missing.arguments and i18nformat.excess.arguments are + // issued from commonAssignmentCheck. if (paraml < formatl) { tu.warning(invc, "i18nformat.missing.arguments", formatl, paraml); } @@ -148,9 +147,8 @@ protected void commonAssignmentCheck( checker.reportWarning( valueTree, "i18nformat.missing.arguments", varType.toString(), valueType.toString()); } else if (rhsArgTypes.length > lhsArgTypes.length) { - // Since it is known that too many conversion categories were provided, - // issue a more specific error message to that effect than - // assignment.type.incompatible. + // Since it is known that too many conversion categories were provided, issue a more + // specific error message to that effect than assignment.type.incompatible. checker.reportError( valueTree, "i18nformat.excess.arguments", varType.toString(), valueType.toString()); } @@ -158,7 +156,7 @@ protected void commonAssignmentCheck( // By calling super.commonAssignmentCheck last, any i18nformat.excess.arguments message // issued for a given line of code will take precedence over the - // assignment.type.incompatible + // assignment.type.incompatible // issued by super.commonAssignmentCheck. super.commonAssignmentCheck(varType, valueType, valueTree, errorKey, extraArgs); } diff --git a/checker/src/main/java/org/checkerframework/checker/index/inequality/LessThanVisitor.java b/checker/src/main/java/org/checkerframework/checker/index/inequality/LessThanVisitor.java index e34b7610a0b..e64cc77fdf0 100644 --- a/checker/src/main/java/org/checkerframework/checker/index/inequality/LessThanVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/index/inequality/LessThanVisitor.java @@ -71,8 +71,7 @@ protected void commonAssignmentCheck( Object... extraArgs) { // If value is less than all expressions in the annotation in varType, // using the Value Checker, then skip the common assignment check. - // Also skip the check if the only expression is "a + 1" and the valueTree - // is "a". + // Also skip the check if the only expression is "a + 1" and the valueTree is "a". List expressions = getTypeFactory() .getLessThanExpressions( diff --git a/checker/src/main/java/org/checkerframework/checker/index/lowerbound/LowerBoundTransfer.java b/checker/src/main/java/org/checkerframework/checker/index/lowerbound/LowerBoundTransfer.java index 6b8c8943c16..574199edd5f 100644 --- a/checker/src/main/java/org/checkerframework/checker/index/lowerbound/LowerBoundTransfer.java +++ b/checker/src/main/java/org/checkerframework/checker/index/lowerbound/LowerBoundTransfer.java @@ -240,10 +240,9 @@ protected TransferResult strengthenAnnotationOfEqualTo( return result; } - // There is also special processing to look - // for literals on one side of the equals and a GTEN1 or NN on the other, so that - // those types can be promoted in the branch where their values are not equal to certain - // literals. + // There is also special processing to look for literals on one side of the equals and a GTEN1 + // or NN on the other, so that those types can be promoted in the branch where their values are + // not equal to certain literals. CFStore notEqualsStore = notEqualTo ? rfi.thenStore : rfi.elseStore; notEqualToValue(rfi.left, rfi.right, rfi.rightAnno, notEqualsStore); notEqualToValue(rfi.right, rfi.left, rfi.leftAnno, notEqualsStore); @@ -484,10 +483,9 @@ private AnnotationMirror getAnnotationForMinus( Tree leftExpr = minusNode.getLeftOperand().getTree(); Integer minLen = null; - // Check if the left side is a field access of an array's length, - // or invocation of String.length. If so, - // try to look up the MinLen of the array, and potentially keep - // this either NN or POS instead of GTEN1 or LBU. + // Check if the left side is a field access of an array's length, or invocation of + // String.length. If so, try to look up the MinLen of the array, and potentially keep this + // either NN or POS instead of GTEN1 or LBU. if (leftExpr.getKind() == Tree.Kind.MEMBER_SELECT) { MemberSelectTree mstree = (MemberSelectTree) leftExpr; minLen = aTypeFactory.getMinLenFromMemberSelectTree(mstree); diff --git a/checker/src/main/java/org/checkerframework/checker/index/samelen/SameLenTransfer.java b/checker/src/main/java/org/checkerframework/checker/index/samelen/SameLenTransfer.java index 1c7946e1e8e..a39c35ac5ab 100644 --- a/checker/src/main/java/org/checkerframework/checker/index/samelen/SameLenTransfer.java +++ b/checker/src/main/java/org/checkerframework/checker/index/samelen/SameLenTransfer.java @@ -86,9 +86,8 @@ public TransferResult visitAssignment( Node lengthNodeReceiver = getLengthReceiver(lengthNode); if (lengthNodeReceiver != null) { - // "new T[a.length]" or "new T[s.length()]" is the right hand side of the - // assignment. lengthNode is known to be "lengthNodeReceiver.length" or - // "lengthNodeReceiver.length()" + // "new T[a.length]" or "new T[s.length()]" is the right hand side of the assignment. + // lengthNode is known to be "lengthNodeReceiver.length" or "lengthNodeReceiver.length()" // targetRec is the receiver for the left hand side of the assignment. JavaExpression targetRec = JavaExpression.fromNode(node.getTarget()); @@ -272,9 +271,8 @@ protected void addInformationFromPreconditions( for (int index = 0; index < numParams; index++) { - // if the parameter has a samelen annotation, then look - // for other parameters in that annotation and propagate - // default the other annotation so that it is symmetric + // If the parameter has a samelen annotation, then look for other parameters in that + // annotation and propagate default the other annotation so that it is symmetric. AnnotatedTypeMirror atm = params.get(index); AnnotationMirror sameLenAnno = atm.getAnnotation(SameLen.class); if (sameLenAnno == null) { diff --git a/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundAnnotatedTypeFactory.java b/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundAnnotatedTypeFactory.java index ce9ab0f5405..e927bb2e92d 100644 --- a/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundAnnotatedTypeFactory.java +++ b/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundAnnotatedTypeFactory.java @@ -587,9 +587,9 @@ private void addAnnotationForRightShift( LowerBoundAnnotatedTypeFactory lowerBoundATF = getLowerBoundAnnotatedTypeFactory(); if (lowerBoundATF.isNonNegative(left)) { AnnotationMirror annotation = getAnnotatedType(left).getAnnotationInHierarchy(UNKNOWN); - // For non-negative numbers, right shift is equivalent to division by a power of two + // For non-negative numbers, right shift is equivalent to division by a power of two. // The range of the shift amount is limited to 0..30 to avoid overflows and int/long - // differences + // differences. Long shiftAmount = ValueCheckerUtils.getExactValue(right, getValueAnnotatedTypeFactory()); if (shiftAmount != null && shiftAmount >= 0 && shiftAmount < Integer.SIZE - 1) { int divisor = 1 << shiftAmount; diff --git a/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundTransfer.java b/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundTransfer.java index 4d3b122b812..00f53cd86e1 100644 --- a/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundTransfer.java +++ b/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundTransfer.java @@ -511,9 +511,8 @@ public TransferResult visitNumericalAddition( UBQualifier glb = t.glb(s); if (left.isLessThanLengthQualifier() && right.isLessThanLengthQualifier()) { - // If expression i has type @LTLengthOf(value = "f2", offset = "f1.length") int and - // expression j is less than or equal to the length of f1, then the type of i + j is - // @LTLengthOf("f2"). + // If expression i has type @LTLengthOf(value = "f2", offset = "f1.length") int and expression + // j is less than or equal to the length of f1, then the type of i + j is @LTLengthOf("f2"). UBQualifier r = removeSequenceLengths((LessThanLengthOf) left, (LessThanLengthOf) right); glb = glb.glb(r); UBQualifier l = removeSequenceLengths((LessThanLengthOf) right, (LessThanLengthOf) left); @@ -596,13 +595,11 @@ public TransferResult visitNumericalSubtraction( try { je = UpperBoundVisitor.parseJavaExpressionString(b, atypeFactory, currentPath); } catch (NullPointerException npe) { - // I have no idea why this seems to happen only on a few JDK classes. - // It appears to only happen during the preprocessing step - the NPE - // is thrown while trying to find the enclosing class of a class tree, - // which is null. I can't find a reproducible - // test case that's smaller than the size of DualPivotQuicksort. - // Since this refinement is optional, but useful elsewhere, catching this - // NPE here and returning is always safe. + // I have no idea why this seems to happen only on a few JDK classes. It appears to + // only happen during the preprocessing step - the NPE is thrown while trying to find + // the enclosing class of a class tree, which is null. I can't find a reproducible test + // case that's smaller than the size of DualPivotQuicksort. Since this refinement is + // optional, but useful elsewhere, catching this NPE here and returning is always safe. return createTransferResult(n, in, leftWithOffset); } @@ -781,8 +778,8 @@ private UBQualifier getUBQualifier(Node n, TransferInput in) { UBQualifier qualifier = getUBQualifier(hierarchy, value); if (qualifier.isUnknown()) { // The qualifier from the store or analysis might be UNKNOWN if there was some error. - // For example, - // @LTLength("a") int i = 4; // error + // For example, + // @LTLength("a") int i = 4; // error // The type of i in the store is @UpperBoundUnknown, but the type of i as computed by // the type factory is @LTLength("a"), so use that type. CFValue valueFromFactory = getValueFromFactory(n.getTree(), n); @@ -815,8 +812,8 @@ public TransferResult visitCase( CaseNode n, TransferInput in) { TransferResult result = super.visitCase(n, in); // Refines subtrahend in the switch expression - // TODO: this cannot be done in strengthenAnnotationOfEqualTo, because that does not provide - // transfer input + // TODO: This cannot be done in strengthenAnnotationOfEqualTo, because that does not provide + // transfer input. Node caseNode = n.getCaseOperand(); AssignmentNode assign = (AssignmentNode) n.getSwitchOperand(); Node switchNode = assign.getExpression(); diff --git a/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundVisitor.java b/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundVisitor.java index f00a57b53e3..ee99264cc24 100644 --- a/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/index/upperbound/UpperBoundVisitor.java @@ -404,9 +404,8 @@ private boolean relaxedCommonAssignmentCheck( // Take advantage of information available on a HasSubsequence(a, from, to) annotation // on the lhs qualifier (varLtlQual): - // this allows us to show that iff varLtlQual includes LTL(b), - // b has HSS, and expQual includes LTL(a, -from), then the LTL(b) can be removed from - // varLtlQual. + // this allows us to show that iff varLtlQual includes LTL(b), b has HSS, and expQual includes + // LTL(a, -from), then the LTL(b) can be removed from varLtlQual. UBQualifier newLHS = processSubsequenceForLHS(varLtlQual, expQual); if (newLHS.isUnknown()) { diff --git a/checker/src/main/java/org/checkerframework/checker/initialization/InitializationAnnotatedTypeFactory.java b/checker/src/main/java/org/checkerframework/checker/initialization/InitializationAnnotatedTypeFactory.java index f74bdb4982b..a37ad4fdec7 100644 --- a/checker/src/main/java/org/checkerframework/checker/initialization/InitializationAnnotatedTypeFactory.java +++ b/checker/src/main/java/org/checkerframework/checker/initialization/InitializationAnnotatedTypeFactory.java @@ -505,9 +505,9 @@ protected void setSelfTypeInInitializationCode( // If all fields are initialized-only, and they are all initialized, // then: - // - if the class is final, this is @Initialized - // - otherwise, this is @UnderInitialization(CurrentClass) as - // there might still be subclasses that need initialization. + // - if the class is final, this is @Initialized + // - otherwise, this is @UnderInitialization(CurrentClass) as + // there might still be subclasses that need initialization. if (areAllFieldsInitializedOnly(enclosingClass)) { Store store = getStoreBefore(tree); if (store != null @@ -721,14 +721,12 @@ private void computeFieldAccessType( // anything can be assigned to this field. type.replaceAnnotation(UNKNOWN_INITIALIZATION); } else if (computingAnnotatedTypeMirrorOfLHS) { - // The receiver is not initialized for this frame, but the type of a lhs is being - // computed. + // The receiver is not initialized for this frame, but the type of a lhs is being computed. // Change the type of the field to @UnknownInitialization so that // anything can be assigned to this field. type.replaceAnnotation(UNKNOWN_INITIALIZATION); } else { - // The receiver is not initialized for this frame and the type being computed is not - // a LHS. + // The receiver is not initialized for this frame and the type being computed is not a LHS. // Replace all annotations with the top annotation for that hierarchy. type.clearAnnotations(); type.addAnnotations(qualHierarchy.getTopAnnotations()); diff --git a/checker/src/main/java/org/checkerframework/checker/initialization/InitializationTransfer.java b/checker/src/main/java/org/checkerframework/checker/initialization/InitializationTransfer.java index 394ee54b356..7dd8e57c891 100644 --- a/checker/src/main/java/org/checkerframework/checker/initialization/InitializationTransfer.java +++ b/checker/src/main/java/org/checkerframework/checker/initialization/InitializationTransfer.java @@ -132,8 +132,7 @@ protected void markInvariantFieldsAsInitialized( for (VariableElement field : fields) { if (((Symbol) field).type.tsym.completer != Symbol.Completer.NULL_COMPLETER || ((Symbol) field).type.getKind() == TypeKind.ERROR) { - // If the type is not completed yet, we might run - // into trouble. Skip the field. + // If the type is not completed yet, we might run into trouble. Skip the field. // TODO: is there a nicer solution? // This was raised by Issue #244. continue; diff --git a/checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java b/checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java index 6f93938d631..f300a43c98c 100644 --- a/checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java @@ -79,8 +79,7 @@ public InitializationVisitor(BaseTypeChecker checker) { @Override public void setRoot(CompilationUnitTree root) { // Clean up the cache of initialized fields once per compilation unit. - // Alternatively, but harder to determine, this could be done once per - // top-level class. + // Alternatively, but harder to determine, this could be done once per top-level class. initializedFields.clear(); super.setRoot(root); } @@ -88,8 +87,7 @@ public void setRoot(CompilationUnitTree root) { @Override protected void checkConstructorInvocation( AnnotatedDeclaredType dt, AnnotatedExecutableType constructor, NewClassTree src) { - // receiver annotations for constructors are forbidden, therefore no - // check is necessary + // Receiver annotations for constructors are forbidden, therefore no check is necessary. // TODO: nested constructors can have receivers! } diff --git a/checker/src/main/java/org/checkerframework/checker/interning/InterningVisitor.java b/checker/src/main/java/org/checkerframework/checker/interning/InterningVisitor.java index cfd9493a101..585b4275c04 100644 --- a/checker/src/main/java/org/checkerframework/checker/interning/InterningVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/interning/InterningVisitor.java @@ -153,8 +153,7 @@ public Void visitBinary(BinaryTree node, Void p) { // in order to assume this). // Now suppose the user passes -AcheckClass=A on the command-line. - // I is not a subtype or supertype of A, so shouldCheckExpression will not return true for - // I. + // I is not a subtype or supertype of A, so shouldCheckExpression will not return true for I. // But the interning check must be performed, given the argument above. Therefore if // shouldCheckExpression returns true for either the LHS or the RHS, this method proceeds // with the interning check. @@ -681,8 +680,7 @@ public Boolean visitBinary(BinaryTree tree, Void p) { if (tree.getKind() == Tree.Kind.CONDITIONAL_OR) { if (sameTree(leftTree, node)) { // left is "a==b" - // check right, which should be a.equals(b) or b.equals(a) or - // similar + // check right, which should be a.equals(b) or b.equals(a) or similar return visit(rightTree, p); } else { return false; diff --git a/checker/src/main/java/org/checkerframework/checker/lock/LockStore.java b/checker/src/main/java/org/checkerframework/checker/lock/LockStore.java index 317c3b523c4..9f9ac013726 100644 --- a/checker/src/main/java/org/checkerframework/checker/lock/LockStore.java +++ b/checker/src/main/java/org/checkerframework/checker/lock/LockStore.java @@ -188,11 +188,10 @@ public void updateForMethodCall( // Lockannotatedtypefactory, but it affects only one of the two type hierarchies, so it // cannot use that logic. if (!isSideEffectFree(atypeFactory, method)) { - // After the call to super.updateForMethodCall, only final fields are left in - // fieldValues (if the method called is side-effecting). For the LockPossiblyHeld - // hierarchy, even a final field might be locked or unlocked by a side-effecting - // method. So, final fields must be set to @LockPossiblyHeld, but the annotation in - // the GuardedBy hierarchy should not be changed. + // After the call to super.updateForMethodCall, only final fields are left in fieldValues (if + // the method called is side-effecting). For the LockPossiblyHeld hierarchy, even a final + // field might be locked or unlocked by a side-effecting method. So, final fields must be set + // to @LockPossiblyHeld, but the annotation in the GuardedBy hierarchy should not be changed. for (FieldAccess field : new ArrayList<>(fieldValues.keySet())) { CFValue newValue = changeLockAnnoToTop(field, fieldValues.get(field)); if (newValue != null) { diff --git a/checker/src/main/java/org/checkerframework/checker/lock/LockTransfer.java b/checker/src/main/java/org/checkerframework/checker/lock/LockTransfer.java index f99bdd78ec6..7bfd556030e 100644 --- a/checker/src/main/java/org/checkerframework/checker/lock/LockTransfer.java +++ b/checker/src/main/java/org/checkerframework/checker/lock/LockTransfer.java @@ -60,9 +60,8 @@ protected void makeLockHeld(LockStore store, Node node) { protected void makeLockPossiblyHeld(LockStore store, Node node) { JavaExpression internalRepr = JavaExpression.fromNode(node); - // insertValue cannot change an annotation to a less - // specific type (e.g. LockHeld to LockPossiblyHeld), - // so insertLockPossiblyHeld is called. + // insertValue cannot change an annotation to a less specific type (e.g. LockHeld to + // LockPossiblyHeld), so insertLockPossiblyHeld is called. store.insertLockPossiblyHeld(internalRepr); } @@ -95,26 +94,20 @@ public LockStore initialStore(UnderlyingAST underlyingAST, List requiredArgs = AnnotatedTypes.expandVarArgs(atypeFactory, invokedMethod, node.getArguments()); - // Index on @GuardSatisfied at each location. -1 when no @GuardSatisfied annotation was - // present. + // Index on @GuardSatisfied at each location. -1 when no @GuardSatisfied annotation was present. // Note that @GuardSatisfied with no index is normally represented as having index -1. // We would like to ignore a @GuardSatisfied with no index for these purposes, so if it is // encountered we leave its index as -1. @@ -840,13 +835,11 @@ public Void visitSynchronized(SynchronizedTree node, Void p) { * @param lockExpressionTree the expression tree of a synchronized block */ private void ensureExpressionIsEffectivelyFinal(final ExpressionTree lockExpressionTree) { - // This functionality could be implemented using a visitor instead, - // however with this design, it is easier to be certain that an error - // will always be issued if a tree kind is not recognized. + // This functionality could be implemented using a visitor instead, however with this design, it + // is easier to be certain that an error will always be issued if a tree kind is not recognized. // Only the most common tree kinds for synchronized expressions are supported. - // Traverse the expression using 'tree', as 'lockExpressionTree' is used for error - // reporting. + // Traverse the expression using 'tree', as 'lockExpressionTree' is used for error reporting. ExpressionTree tree = lockExpressionTree; while (true) { diff --git a/checker/src/main/java/org/checkerframework/checker/nullness/KeyForPropagator.java b/checker/src/main/java/org/checkerframework/checker/nullness/KeyForPropagator.java index ad889c5bc1b..00e1f4f0ec5 100644 --- a/checker/src/main/java/org/checkerframework/checker/nullness/KeyForPropagator.java +++ b/checker/src/main/java/org/checkerframework/checker/nullness/KeyForPropagator.java @@ -105,8 +105,8 @@ public void propagate( } // else // this can happen for two reasons: - // 1) the subclass introduced NEW type arguments when the superclass had none - // 2) the supertype was RAW. + // 1) the subclass introduced NEW type arguments when the superclass had none + // 2) the supertype was RAW. // In either case, there is no reason to propagate if (supertype.getTypeArguments().isEmpty()) { return; diff --git a/checker/src/main/java/org/checkerframework/checker/nullness/NullnessAnnotatedTypeFactory.java b/checker/src/main/java/org/checkerframework/checker/nullness/NullnessAnnotatedTypeFactory.java index b7dcc8b203f..7c0e4e95c7b 100644 --- a/checker/src/main/java/org/checkerframework/checker/nullness/NullnessAnnotatedTypeFactory.java +++ b/checker/src/main/java/org/checkerframework/checker/nullness/NullnessAnnotatedTypeFactory.java @@ -478,9 +478,8 @@ public Void visitIdentifier(IdentifierTree node, AnnotatedTypeMirror type) { assert elt != null; if (elt.getKind() == ElementKind.EXCEPTION_PARAMETER) { - // TODO: It's surprising that we have to do this in - // both visitVariable and visitIdentifier. This should - // already be handled by applying the defaults anyway. + // TODO: It's surprising that we have to do this in both visitVariable and + // visitIdentifier. This should already be handled by applying the defaults anyway. // case 9. exception parameter type.replaceAnnotation(NONNULL); } diff --git a/checker/src/main/java/org/checkerframework/checker/nullness/NullnessChecker.java b/checker/src/main/java/org/checkerframework/checker/nullness/NullnessChecker.java index 5515b4ad04b..71b717f2db5 100644 --- a/checker/src/main/java/org/checkerframework/checker/nullness/NullnessChecker.java +++ b/checker/src/main/java/org/checkerframework/checker/nullness/NullnessChecker.java @@ -18,8 +18,7 @@ @SupportedLintOptions({ NullnessChecker.LINT_NOINITFORMONOTONICNONNULL, NullnessChecker.LINT_REDUNDANTNULLCOMPARISON, - // Temporary option to forbid non-null array component types, - // which is allowed by default. + // Temporary option to forbid non-null array component types, which is allowed by default. // Forbidding is sound and will eventually be the default. // Allowing is unsound, as described in Section 3.3.4, "Nullness and arrays": // https://checkerframework.org/manual/#nullness-arrays diff --git a/checker/src/main/java/org/checkerframework/checker/nullness/NullnessVisitor.java b/checker/src/main/java/org/checkerframework/checker/nullness/NullnessVisitor.java index 0795dc40163..35351f75025 100644 --- a/checker/src/main/java/org/checkerframework/checker/nullness/NullnessVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/nullness/NullnessVisitor.java @@ -171,10 +171,9 @@ protected void commonAssignmentCheck( ExpressionTree valueExp, @CompilerMessageKey String errorKey, Object... extraArgs) { - // Use the valueExp as the context because data flow will have a value for that tree. - // It might not have a value for the var tree. This is sound because - // if data flow has determined @PolyNull is @Nullable at the RHS, then - // it is also @Nullable for the LHS. + // Use the valueExp as the context because data flow will have a value for that tree. It might + // not have a value for the var tree. This is sound because if data flow has determined + // @PolyNull is @Nullable at the RHS, then it is also @Nullable for the LHS. atypeFactory.replacePolyQualifier(varType, valueExp); super.commonAssignmentCheck(varType, valueExp, errorKey, extraArgs); } @@ -332,10 +331,9 @@ public Void visitAssert(AssertTree node, Void p) { // See also // org.checkerframework.dataflow.cfg.builder.CFGBuilder.CFGTranslationPhaseOne.visitAssert - // In cases where neither assumeAssertionsAreEnabled nor assumeAssertionsAreDisabled are - // turned on and @AssumeAssertions is not used, checkForNullability is still called since - // the CFGBuilder will have generated one branch for which asserts are assumed to be - // enabled. + // In cases where neither assumeAssertionsAreEnabled nor assumeAssertionsAreDisabled are turned + // on and @AssumeAssertions is not used, checkForNullability is still called since the + // CFGBuilder will have generated one branch for which asserts are assumed to be enabled. boolean doVisitAssert = true; @@ -595,9 +593,8 @@ protected void checkMethodInvocability( AnnotatedTypeMirror treeReceiver = methodReceiver.shallowCopy(false); AnnotatedTypeMirror rcv = atypeFactory.getReceiverType(node); treeReceiver.addAnnotations(rcv.getEffectiveAnnotations()); - // If receiver is Nullable, then we don't want to issue a warning - // about method invocability (we'd rather have only the - // "dereference.of.nullable" message). + // If receiver is Nullable, then we don't want to issue a warning about method invocability + // (we'd rather have only the "dereference.of.nullable" message). if (treeReceiver.hasAnnotation(NULLABLE) || receiverAnnos.contains(MONOTONIC_NONNULL)) { return; } @@ -612,9 +609,8 @@ private final boolean isUnboxingOperation(BinaryTree tree) { // if one (or both) of them is null return isPrimitive(tree.getLeftOperand()) != isPrimitive(tree.getRightOperand()); } else { - // All BinaryTree's are of type String, a primitive type or the - // reference type equivalent of a primitive type. Furthermore, - // Strings don't have a primitive type, and therefore only + // All BinaryTree's are of type String, a primitive type or the reference type equivalent of a + // primitive type. Furthermore, Strings don't have a primitive type, and therefore only // BinaryTrees that aren't String can cause unboxing. return !isString(tree); } @@ -702,9 +698,8 @@ protected void checkExceptionParameter(CatchTree node) { } // Don't call super. - // BasetypeVisitor forces annotations on exception parameters to be top, - // but because exceptions can never be null, the Nullness Checker - // does not require this check. + // BasetypeVisitor forces annotations on exception parameters to be top, but because exceptions + // can never be null, the Nullness Checker does not require this check. } @Override diff --git a/checker/src/main/java/org/checkerframework/checker/propkey/PropertyKeyAnnotatedTypeFactory.java b/checker/src/main/java/org/checkerframework/checker/propkey/PropertyKeyAnnotatedTypeFactory.java index 3ff480ca75c..46d809e506e 100644 --- a/checker/src/main/java/org/checkerframework/checker/propkey/PropertyKeyAnnotatedTypeFactory.java +++ b/checker/src/main/java/org/checkerframework/checker/propkey/PropertyKeyAnnotatedTypeFactory.java @@ -162,9 +162,8 @@ private Set keysOfPropertyFiles(String names) { InputStream in = cl.getResourceAsStream(name); if (in == null) { - // if the classloader didn't manage to load the file, try - // whether a FileInputStream works. For absolute paths this - // might help. + // if the classloader didn't manage to load the file, try whether a FileInputStream + // works. For absolute paths this might help. try { in = new FileInputStream(name); } catch (FileNotFoundException e) { diff --git a/checker/src/main/java/org/checkerframework/checker/regex/RegexAnnotatedTypeFactory.java b/checker/src/main/java/org/checkerframework/checker/regex/RegexAnnotatedTypeFactory.java index ba5861be1bc..c11ff8a00bc 100644 --- a/checker/src/main/java/org/checkerframework/checker/regex/RegexAnnotatedTypeFactory.java +++ b/checker/src/main/java/org/checkerframework/checker/regex/RegexAnnotatedTypeFactory.java @@ -499,42 +499,42 @@ private Integer getMinimumRegexCount(final AnnotatedTypeMirror type) { return getGroupCount(primaryRegexAnno); } - // This won't work correctly until flow sensitivity is supported by the - // the Regex Checker. For example: + // This won't work correctly until flow sensitivity is supported by the + // the Regex Checker. For example: // - // char @Regex [] arr = {'r', 'e'}; - // arr[0] = '('; // type is still "char @Regex []", but this is no longer correct + // char @Regex [] arr = {'r', 'e'}; + // arr[0] = '('; // type is still "char @Regex []", but this is no longer correct // - // There are associated tests in tests/regex/Simple.java:testCharArrays - // that can be uncommented when this is uncommented. - // /** - // * Case 4: a char array that as a String is a valid regular expression. - // */ - // @Override - // public Void visitNewArray(NewArrayTree tree, AnnotatedTypeMirror type) { - // boolean isCharArray = ((ArrayType) type.getUnderlyingType()) - // .getComponentType().getKind() == TypeKind.CHAR; - // if (isCharArray && tree.getInitializers() != null) { - // List initializers = tree.getInitializers(); - // StringBuilder charArray = new StringBuilder(); - // boolean allLiterals = true; - // for (int i = 0; allLiterals && i < initializers.size(); i++) { - // ExpressionTree e = initializers.get(i); - // if (e.getKind() == Tree.Kind.CHAR_LITERAL) { - // charArray.append(((LiteralTree) e).getValue()); - // } else if (getAnnotatedType(e).hasAnnotation(Regex.class)) { - // // if there's an @Regex char in the array then substitute - // // it with a . - // charArray.append('.'); - // } else { - // allLiterals = false; - // } - // } - // if (allLiterals && RegexUtil.isRegex(charArray.toString())) { - // type.addAnnotation(Regex.class); - // } - // } - // return super.visitNewArray(tree, type); - // } + // There are associated tests in tests/regex/Simple.java:testCharArrays + // that can be uncommented when this is uncommented. + // /** + // * Case 4: a char array that as a String is a valid regular expression. + // */ + // @Override + // public Void visitNewArray(NewArrayTree tree, AnnotatedTypeMirror type) { + // boolean isCharArray = ((ArrayType) type.getUnderlyingType()) + // .getComponentType().getKind() == TypeKind.CHAR; + // if (isCharArray && tree.getInitializers() != null) { + // List initializers = tree.getInitializers(); + // StringBuilder charArray = new StringBuilder(); + // boolean allLiterals = true; + // for (int i = 0; allLiterals && i < initializers.size(); i++) { + // ExpressionTree e = initializers.get(i); + // if (e.getKind() == Tree.Kind.CHAR_LITERAL) { + // charArray.append(((LiteralTree) e).getValue()); + // } else if (getAnnotatedType(e).hasAnnotation(Regex.class)) { + // // if there's an @Regex char in the array then substitute + // // it with a . + // charArray.append('.'); + // } else { + // allLiterals = false; + // } + // } + // if (allLiterals && RegexUtil.isRegex(charArray.toString())) { + // type.addAnnotation(Regex.class); + // } + // } + // return super.visitNewArray(tree, type); + // } } } diff --git a/checker/src/main/java/org/checkerframework/checker/regex/RegexTransfer.java b/checker/src/main/java/org/checkerframework/checker/regex/RegexTransfer.java index d8ccd352d3d..8fe58b6ca40 100644 --- a/checker/src/main/java/org/checkerframework/checker/regex/RegexTransfer.java +++ b/checker/src/main/java/org/checkerframework/checker/regex/RegexTransfer.java @@ -49,9 +49,8 @@ public RegexTransfer(CFAbstractAnalysis analysis) analysis.getTypeFactory().getProcessingEnv()); } - // TODO: These are special cases for isRegex(String, int) and asRegex(String, int). - // They should be replaced by adding an @EnsuresQualifierIf annotation that supports - // specifying attributes. + // TODO: These are special cases for isRegex(String, int) and asRegex(String, int). They should + // be replaced by adding an @EnsuresQualifierIf annotation that supports specifying attributes. @Override public TransferResult visitMethodInvocation( MethodInvocationNode n, TransferInput in) { diff --git a/checker/src/main/java/org/checkerframework/checker/regex/RegexVisitor.java b/checker/src/main/java/org/checkerframework/checker/regex/RegexVisitor.java index 7d21c4a1863..dfa5f1901dd 100644 --- a/checker/src/main/java/org/checkerframework/checker/regex/RegexVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/regex/RegexVisitor.java @@ -68,11 +68,10 @@ public Void visitMethodInvocation(MethodInvocationTree node, Void p) { if (flagParam.getKind() == Kind.MEMBER_SELECT) { MemberSelectTree memSelect = (MemberSelectTree) flagParam; if (TreeUtils.isSpecificFieldAccess(memSelect, patternLiteral)) { - // This is a call to Pattern.compile with the Pattern.LITERAL - // flag so the first parameter doesn't need to be a - // @Regex String. Don't call the super method to skip checking - // if the first parameter is a @Regex String, but make sure to - // still recurse on all of the different parts of the method call. + // This is a call to Pattern.compile with the Pattern.LITERAL flag so the first parameter + // doesn't need to be a @Regex String. Don't call the super method to skip checking if the + // first parameter is a @Regex String, but make sure to still recurse on all of the + // different parts of the method call. Void r = scan(node.getTypeArguments(), p); r = reduce(scan(node.getMethodSelect(), p), r); r = reduce(scan(node.getArguments(), p), r); @@ -92,10 +91,9 @@ public Void visitMethodInvocation(MethodInvocationTree node, Void p) { int paramGroups = (Integer) literal.getValue(); ExpressionTree receiver = TreeUtils.getReceiverTree(node); if (receiver == null) { - // When checking implementations of java.util.regex.MatcherResult, calls to - // group (and other methods) don't have a receiver tree. So, just do the - // regular checking. Verifying an implemenation of a subclass of MatcherResult - // is out of the scope of this checker. + // When checking implementations of java.util.regex.MatcherResult, calls to group (and + // other methods) don't have a receiver tree. So, just do the regular checking. Verifying + // an implemenation of a subclass of MatcherResult is out of the scope of this checker. return super.visitMethodInvocation(node, p); } int annoGroups = 0; diff --git a/checker/src/main/java/org/checkerframework/checker/units/UnitsAnnotatedTypeFactory.java b/checker/src/main/java/org/checkerframework/checker/units/UnitsAnnotatedTypeFactory.java index f166925af63..abb68317788 100644 --- a/checker/src/main/java/org/checkerframework/checker/units/UnitsAnnotatedTypeFactory.java +++ b/checker/src/main/java/org/checkerframework/checker/units/UnitsAnnotatedTypeFactory.java @@ -103,9 +103,8 @@ public UnitsAnnotatedTypeFactory(BaseTypeChecker checker) { this.postInit(); } - // In Units Checker, we always want to print out the Invisible Qualifiers - // (UnknownUnits), and to format the print out of qualifiers by removing - // Prefix.one + // In Units Checker, we always want to print out the Invisible Qualifiers (UnknownUnits), and to + // format the print out of qualifiers by removing Prefix.one @Override protected AnnotatedTypeFormatter createAnnotatedTypeFormatter() { return new UnitsAnnotatedTypeFormatter(checker); @@ -145,9 +144,9 @@ public AnnotationMirror canonicalAnnotation(AnnotationMirror anno) { UnitsRelationsTools.buildAnnoMirrorWithSpecificPrefix( processingEnv, baseUnitAnnoClass, prefix); - // TODO: assert that this annotation is a prefix multiple of a Unit that's in the - // supported type qualifiers list currently this breaks for externally loaded - // annotations if the order was an alias before a base annotation. + // TODO: assert that this annotation is a prefix multiple of a Unit that's in the supported + // type qualifiers list currently this breaks for externally loaded annotations if the order + // was an alias before a base annotation. // assert isSupportedQualifier(result); built = true; diff --git a/checker/src/main/java/org/checkerframework/checker/units/UnitsAnnotationClassLoader.java b/checker/src/main/java/org/checkerframework/checker/units/UnitsAnnotationClassLoader.java index edecffc5ba2..b7c7df3e215 100644 --- a/checker/src/main/java/org/checkerframework/checker/units/UnitsAnnotationClassLoader.java +++ b/checker/src/main/java/org/checkerframework/checker/units/UnitsAnnotationClassLoader.java @@ -35,9 +35,8 @@ protected boolean isSupportedAnnotationClass(Class annoCla initialResult.getAnnotationType().asElement().getAnnotationMirrors()) { // TODO : special treatment of invisible qualifiers? - // if the annotation is a SI prefix multiple of some base unit, then return false - // classic Units checker does not need to load the annotations of SI prefix multiples of - // base units + // If the annotation is a SI prefix multiple of some base unit, then return false classic + // Units checker does not need to load the annotations of SI prefix multiples of base units. if (AnnotationUtils.areSameByName( metaAnno, "org.checkerframework.checker.units.qual.UnitsMultiple")) { return false; diff --git a/checker/src/test/java/org/checkerframework/checker/test/junit/FormatterLubGlbCheckerTest.java b/checker/src/test/java/org/checkerframework/checker/test/junit/FormatterLubGlbCheckerTest.java index d5f1287245c..b6af2eb986d 100644 --- a/checker/src/test/java/org/checkerframework/checker/test/junit/FormatterLubGlbCheckerTest.java +++ b/checker/src/test/java/org/checkerframework/checker/test/junit/FormatterLubGlbCheckerTest.java @@ -2,7 +2,7 @@ // Test case for issue 691. // https://github.com/typetools/checker-framework/issues/691 -// This exists to just run the FormatterLubGlbChecker +// This exists to just run the FormatterLubGlbChecker. import java.io.File; import java.util.List; diff --git a/checker/src/test/java/org/checkerframework/checker/test/junit/I18nFormatterLubGlbCheckerTest.java b/checker/src/test/java/org/checkerframework/checker/test/junit/I18nFormatterLubGlbCheckerTest.java index 8f138299f53..807c9b198d4 100644 --- a/checker/src/test/java/org/checkerframework/checker/test/junit/I18nFormatterLubGlbCheckerTest.java +++ b/checker/src/test/java/org/checkerframework/checker/test/junit/I18nFormatterLubGlbCheckerTest.java @@ -2,7 +2,7 @@ // Test case for issue 723. // https://github.com/typetools/checker-framework/issues/723 -// This exists to just run the I18nFormatterLubGlbChecker +// This exists to just run the I18nFormatterLubGlbChecker. import java.io.File; import java.util.List; diff --git a/checker/src/test/java/org/checkerframework/checker/test/junit/NestedAggregateCheckerTest.java b/checker/src/test/java/org/checkerframework/checker/test/junit/NestedAggregateCheckerTest.java index 3235b9f811e..0155fa3b4b0 100644 --- a/checker/src/test/java/org/checkerframework/checker/test/junit/NestedAggregateCheckerTest.java +++ b/checker/src/test/java/org/checkerframework/checker/test/junit/NestedAggregateCheckerTest.java @@ -2,7 +2,7 @@ // Test case for issue 343. // https://github.com/typetools/checker-framework/issues/343 -// This exists to just run the NestedAggregateChecker +// This exists to just run the NestedAggregateChecker. import java.io.File; import java.util.List; diff --git a/checker/src/testannotations/java/javax/annotation/concurrent/GuardedBy.java b/checker/src/testannotations/java/javax/annotation/concurrent/GuardedBy.java index bff5f1aba4b..57f9c193b38 100644 --- a/checker/src/testannotations/java/javax/annotation/concurrent/GuardedBy.java +++ b/checker/src/testannotations/java/javax/annotation/concurrent/GuardedBy.java @@ -8,10 +8,9 @@ import org.checkerframework.checker.lock.qual.LockHeld; import org.checkerframework.framework.qual.PreconditionAnnotation; -// The JCIP annotation can be used on a field (in which case it corresponds -// to the Lock Checker's @GuardedBy annotation) or on a method (in which case -// it is a declaration annotation corresponding to the Lock Checker's @Holding -// annotation). +// The JCIP annotation can be used on a field (in which case it corresponds to the Lock Checker's +// @GuardedBy annotation) or on a method (in which case it is a declaration annotation corresponding +// to the Lock Checker's @Holding annotation). // It is preferred to use these Checker Framework annotations instead: // org.checkerframework.checker.lock.qual.GuardedBy // org.checkerframework.checker.lock.qual.Holding diff --git a/checker/src/testannotations/java/net/jcip/annotations/GuardedBy.java b/checker/src/testannotations/java/net/jcip/annotations/GuardedBy.java index 6a7c0e7c110..0b3dda46071 100644 --- a/checker/src/testannotations/java/net/jcip/annotations/GuardedBy.java +++ b/checker/src/testannotations/java/net/jcip/annotations/GuardedBy.java @@ -11,10 +11,9 @@ import org.checkerframework.checker.lock.qual.LockHeld; import org.checkerframework.framework.qual.PreconditionAnnotation; -// The JCIP annotation can be used on a field (in which case it corresponds -// to the Lock Checker's @GuardedBy annotation) or on a method (in which case -// it is a declaration annotation corresponding to the Lock Checker's @Holding -// annotation). +// The JCIP annotation can be used on a field (in which case it corresponds to the Lock Checker's +// @GuardedBy annotation) or on a method (in which case it is a declaration annotation corresponding +// to the Lock Checker's @Holding annotation). // It is preferred to use these Checker Framework annotations instead: // org.checkerframework.checker.lock.qual.GuardedBy // org.checkerframework.checker.lock.qual.Holding diff --git a/checker/tests/aggregate/Placeholder.java b/checker/tests/aggregate/Placeholder.java index fa7714a7e8e..33a99cf3c5e 100644 --- a/checker/tests/aggregate/Placeholder.java +++ b/checker/tests/aggregate/Placeholder.java @@ -1,5 +1,4 @@ // We need a file to start the checker. -// We should add more files to test -// aggregate checker functionality. +// We should add more files to test aggregate checker functionality. public class Placeholder {} diff --git a/checker/tests/calledmethods-usevaluechecker/SpecialNames.java b/checker/tests/calledmethods-usevaluechecker/SpecialNames.java index fc0951f3a82..da20341ff04 100644 --- a/checker/tests/calledmethods-usevaluechecker/SpecialNames.java +++ b/checker/tests/calledmethods-usevaluechecker/SpecialNames.java @@ -1,6 +1,5 @@ -// This test ensures that special handling for method -// names in DescribeImagesRequest isn't used for other -// classes with the same names. +// This test ensures that special handling for method names in DescribeImagesRequest isn't used for +// other classes with the same names. import org.checkerframework.checker.calledmethods.qual.*; import org.checkerframework.common.returnsreceiver.qual.*; diff --git a/checker/tests/calledmethods/CmPredicate.java b/checker/tests/calledmethods/CmPredicate.java index 5c8fb62984c..80f602b649a 100644 --- a/checker/tests/calledmethods/CmPredicate.java +++ b/checker/tests/calledmethods/CmPredicate.java @@ -211,8 +211,7 @@ static void testAssignability1(@CalledMethodsPredicate("a || b") MyClass cAble) static void testAssignability2(@CalledMethodsPredicate("a && b") MyClass dAble) { // These calls would work if subtyping between predicates was by implication. They issue - // errors, because - // it is not. + // errors, because it is not. // :: error: method.invocation.invalid dAble.c(); dAble.d(); diff --git a/checker/tests/fenumswing/FlowBreak.java b/checker/tests/fenumswing/FlowBreak.java index 20c712aa2b3..4dfeff49b7b 100644 --- a/checker/tests/fenumswing/FlowBreak.java +++ b/checker/tests/fenumswing/FlowBreak.java @@ -22,10 +22,9 @@ public class FlowBreak { break; } // We can only come here from the then-branch, the else-branch is dead. - // Therefore, we only take the annotations at the end of - // the then-branch and ignore the results of the else-branch. - // Therefore, o is @SwingHorizontalOrientation and the - // following is valid: + // Therefore, we only take the annotations at the end of the then-branch and ignore the + // results of the else-branch. + // Therefore, o is @SwingHorizontalOrientation and the following is valid: @SwingHorizontalOrientation Object pla = o; } // Here we have to merge three paths: diff --git a/checker/tests/formatter/VarargsFormatter.java b/checker/tests/formatter/VarargsFormatter.java index 25f21f603cb..9aa9a33ff71 100644 --- a/checker/tests/formatter/VarargsFormatter.java +++ b/checker/tests/formatter/VarargsFormatter.java @@ -6,8 +6,7 @@ public static void main(String... p) { Formatter f = new Formatter(); // vararg as parameter - // :: warning: non-varargs call of varargs method with inexact argument type for last - // parameter; + // :: warning: non-varargs call of varargs method with inexact argument type for last parameter; f.format("Nothing", null); // equivalent to (Object[])null f.format("Nothing", (Object[]) null); f.format("%s", (Object[]) null); diff --git a/checker/tests/guieffect/TransitiveInheritance.java b/checker/tests/guieffect/TransitiveInheritance.java index 1737a0a3b98..917fb8da627 100644 --- a/checker/tests/guieffect/TransitiveInheritance.java +++ b/checker/tests/guieffect/TransitiveInheritance.java @@ -40,9 +40,9 @@ public void foo() {} // :: error: (override.effect.invalid) public void bar() {} - // Should catch when the override is for a method originating in an interface two levels up, - // but which is implemented via class inheritance (here IIndirect, which is implemented by - // MidLevel) + // Should catch when the override is for a method originating in an interface two levels up, but + // which is implemented via class inheritance (here IIndirect, which is implemented by + // MidLevel). @Override @UIEffect // :: error: (override.effect.invalid) diff --git a/checker/tests/index/GuavaPrimitives.java b/checker/tests/index/GuavaPrimitives.java index 5c4f943986d..0236b323b97 100644 --- a/checker/tests/index/GuavaPrimitives.java +++ b/checker/tests/index/GuavaPrimitives.java @@ -51,9 +51,9 @@ public class GuavaPrimitives extends AbstractList { } @SuppressWarnings( - "index") // these three fields need to be initialized in some order, and any ordering - // leads to the first two issuing errors - since each field is dependent on at - // least one of the others + "index" // these three fields need to be initialized in some order, and any ordering leads to + // the first two issuing errors - since each field is dependent on at least one of the others + ) GuavaPrimitives( short @MinLen(1) [] array, @IndexFor("#1") @LessThan("#3") int start, diff --git a/checker/tests/index/IteratorVoid.java b/checker/tests/index/IteratorVoid.java index 67a59cb96dd..db77a3f2036 100644 --- a/checker/tests/index/IteratorVoid.java +++ b/checker/tests/index/IteratorVoid.java @@ -1,8 +1,7 @@ import java.util.Iterator; -// If quals are configured incorrectly, there will be an -// incompatible assignment error; this ensures that Void -// is given the Positive type. +// If quals are configured incorrectly, there will be an incompatible assignment error; this ensures +// that Void is given the Positive type. public class IteratorVoid { T next1; diff --git a/checker/tests/index/Reassignment.java b/checker/tests/index/Reassignment.java index 5555514aba7..fbec46c6466 100644 --- a/checker/tests/index/Reassignment.java +++ b/checker/tests/index/Reassignment.java @@ -1,7 +1,6 @@ -// @skip-test until we solve the underlying issue. The code that caused this to -// pass has been removed, because an incomplete solution that masks the -// problem but still permits some unsoundness is worse than no solution and -// an obvious issue. +// @skip-test until we solve the underlying issue. The code that caused this to pass has been +// removed, because an incomplete solution that masks the problem but still permits some unsoundness +// is worse than no solution and an obvious issue. public class Reassignment { void test(int[] arr, int i) { diff --git a/checker/tests/index/RegexMatcher.java b/checker/tests/index/RegexMatcher.java index fed7549dc66..cd3911910d7 100644 --- a/checker/tests/index/RegexMatcher.java +++ b/checker/tests/index/RegexMatcher.java @@ -8,9 +8,8 @@ public class RegexMatcher { static void m(String p, String s) { Matcher matcher = Pattern.compile(p).matcher(s); - // The following line cannot be used as a test, - // because the relation of matcher to p is not tracked, - // so the upper bound is not known. + // The following line cannot be used as a test, because the relation of matcher to p is not + // tracked, so the upper bound is not known. // s.substring(matcher.start(), matcher.end()); diff --git a/checker/tests/index/UpperBoundRefinement.java b/checker/tests/index/UpperBoundRefinement.java index ce08686ae18..302a6ca4ba8 100644 --- a/checker/tests/index/UpperBoundRefinement.java +++ b/checker/tests/index/UpperBoundRefinement.java @@ -32,8 +32,7 @@ public void test3(double[] a, double[] sub) { for (int i = 0; i <= a_index_max; i++) { // i has the same type as a_index_max for (int j = 0; j < sub.length; j++) { // j is @LTL("sub") - // i + j is safe here. Because j is LTL("sub"), it should count as ("-1 + - // sub.length") + // i + j is safe here. Because j is LTL("sub"), it should count as ("-1 + sub.length") double d = a[i + j]; } } diff --git a/checker/tests/index/VarLteVar.java b/checker/tests/index/VarLteVar.java index d39512d77b8..4ea0eb10f7f 100644 --- a/checker/tests/index/VarLteVar.java +++ b/checker/tests/index/VarLteVar.java @@ -2,7 +2,7 @@ // It is easy to see that: // * i is an index for intermediate // * length <= i (or, at least length <= i+1) -// but I don't see how to verif that length is an index for intermediate. +// but I don't see how to verify that length is an index for intermediate. // @skip-test diff --git a/checker/tests/initialization/Issue556b.java b/checker/tests/initialization/Issue556b.java index f5ff2f50fb7..7e8385c69be 100644 --- a/checker/tests/initialization/Issue556b.java +++ b/checker/tests/initialization/Issue556b.java @@ -3,17 +3,16 @@ // To reproduce the problem, run: // javac -processor nullness Issue556b.java // java Issue556b -// and observe that the javac execution issues no warnings but the java -// execution suffers a null pointer exception. +// and observe that the javac execution issues no warnings but the java execution suffers a null +// pointer exception. -// Before the constructor is invoked, static initializers and static blocks -// are executed. This suggests that the Initialization Checker can assume -// that static fields are initialized in the constructor. +// Before the constructor is invoked, static initializers and static blocks are executed. This +// suggests that the Initialization Checker can assume that static fields are initialized in the +// constructor. // -// However, if any user-defined code -- including callbacks such as -// executions of equals() and hashCode() -- appears in a static initializer -// or static block, then static fields cannot be assumed to be -// initialized within the constructor. +// However, if any user-defined code -- including callbacks such as executions of equals() and +// hashCode() -- appears in a static initializer or static block, then static fields cannot be +// assumed to be initialized within the constructor. public class Issue556b { static class Parent { @@ -34,9 +33,8 @@ static class Child extends Parent { private static final Object OBJ = new Object(); private Child() { - // This call should not be legal, because at the time that the - // call occurs, the static initializers of Child have not yet - // finished executing and therefore CHILD and OBJ are not + // This call should not be legal, because at the time that the call occurs, the static + // initializers of Child have not yet finished executing and therefore CHILD and OBJ are not // necessarily initialized and are not necessarily non-null. // :: error: (method.invocation.invalid) super(OBJ); @@ -53,17 +51,15 @@ static class Child2 extends Parent { } private Child2() { - // This call should not be legal, because at the time that the - // call occurs, the static initializers of Child have not yet - // finished executing and therefore CHILD and OBJ are not + // This call should not be legal, because at the time that the call occurs, the static + // initializers of Child have not yet finished executing and therefore CHILD and OBJ are not // necessarily initialized and are not necessarily non-null. // :: error: (method.invocation.invalid) super(OBJ); } } - // Changing the order of the OBJ and CHILD fields prevents a null pointer - // exception. + // Changing the order of the OBJ and CHILD fields prevents a null pointer exception. static class ChildOk1 extends Parent { private static final Object OBJ = new Object(); public static final Child CHILD = new Child(); @@ -76,8 +72,7 @@ private ChildOk1() { } } - // Changing the order of the OBJ and CHILD field assignments prevents a - // null pointer exception. + // Changing the order of the OBJ and CHILD field assignments prevents a null pointer exception. static class ChildOk2 extends Parent { public static final ChildOk2 CHILD; private static final Object OBJ; diff --git a/checker/tests/initialization/Issue905.java b/checker/tests/initialization/Issue905.java index 25f60f1ae3b..ecd45675b48 100644 --- a/checker/tests/initialization/Issue905.java +++ b/checker/tests/initialization/Issue905.java @@ -7,8 +7,7 @@ public class Issue905 { final Object mBar; Issue905() { - // this should be @UnderInitialization(Object.class), so this call - // should be forbidden. + // this should be @UnderInitialization(Object.class), so this call should be forbidden. // :: error: (method.invocation.invalid) baz(); mBar = ""; diff --git a/checker/tests/interning/DontCrash.java b/checker/tests/interning/DontCrash.java index 9af65813a29..979fff9c61c 100644 --- a/checker/tests/interning/DontCrash.java +++ b/checker/tests/interning/DontCrash.java @@ -1,6 +1,5 @@ -// This code is illegal (javac issues an error), but nonetheless the -// org.checkerframework.checker shouldn't crash. (Maybe they shouldn't run at all if javac -// issues any errors?) +// This code is illegal (javac issues an error), but nonetheless the org.checkerframework.checker +// shouldn't crash. (Maybe they shouldn't run at all if javac issues any errors?) // @skip-test import java.util.HashMap; diff --git a/checker/tests/interning/ExpressionsInterning.java b/checker/tests/interning/ExpressionsInterning.java index e9aa71863d5..35c260f1cd6 100644 --- a/checker/tests/interning/ExpressionsInterning.java +++ b/checker/tests/interning/ExpressionsInterning.java @@ -44,10 +44,9 @@ public boolean isItTheOne(Foo f) { return THEONE.equals(f); } - // A warning when interned objects are compared via .equals helps me in - // determining whether it is a good idea to convert a given class or - // reference to @Interned -- I can see whether there are places that it - // is compared with .equals, which I might need to examine. + // A warning when interned objects are compared via .equals helps me in determining whether it is + // a good idea to convert a given class or reference to @Interned -- I can see whether there are + // places that it is compared with .equals, which I might need to examine. public boolean dontUseEqualsMethod(@Interned Foo f1, @Interned Foo f2) { // :: warning: (unnecessary.equals) return f1.equals(f2); diff --git a/checker/tests/interning/Raw3.java b/checker/tests/interning/Raw3.java index 13d26f9ec7c..1021f24824f 100644 --- a/checker/tests/interning/Raw3.java +++ b/checker/tests/interning/Raw3.java @@ -75,9 +75,8 @@ List bar3(List sl) { class DuoList extends ArrayList {} List bar4(List sl) { - // This line was previously failing because we couldn't adequately infer the - // type of DuoList as a List; it works now, though the future checking of rawtypes - // may be more strict + // This line was previously failing because we couldn't adequately infer the type of DuoList + // as a List; it works now, though the future checking of rawtypes may be more strict. // :: warning: [unchecked] unchecked conversion return (DuoList) sl; } diff --git a/checker/tests/lock/ChapterExamples.java b/checker/tests/lock/ChapterExamples.java index fe25cee9cd3..da4280f736c 100644 --- a/checker/tests/lock/ChapterExamples.java +++ b/checker/tests/lock/ChapterExamples.java @@ -1,6 +1,5 @@ -// This test contains the sample code from the Lock Checker manual chapter -// modified to fit testing instead of illustrative purposes, -// and contains other miscellaneous Lock Checker testing. +// This test contains the sample code from the Lock Checker manual chapter modified to fit testing +// instead of illustrative purposes, and contains other miscellaneous Lock Checker testing. import java.util.AbstractCollection; import java.util.ArrayList; @@ -175,10 +174,10 @@ void testDereferenceOfReceiverAndParameter( // :: error: (lock.not.held) m.field.toString(); // The following error is due to the fact that you cannot access "this.lock" without first - // having acquired "lock". The right fix in a user scenario would be to not guard "this" - // with "this.lock". The current object could instead be guarded by "" or by some - // other lock expression that is not one of its fields. We are keeping this test case here - // to make sure this scenario issues a warning. + // having acquired "lock". The right fix in a user scenario would be to not guard "this" with + // "this.lock". The current object could instead be guarded by "" or by some other lock + // expression that is not one of its fields. We are keeping this test case here to make sure + // this scenario issues a warning. // :: error: (lock.not.held) synchronized (lock) { myField = new MyClass(); @@ -368,10 +367,10 @@ void myMethod6() { } // :: error: (lock.not.held) p2.field = new Object(); - // An error is issued indicating that p2 might be dereferenced without "lock" being held. - // The method call need not be modified, since @GuardedBy({}) <: @GuardedByUnknown and - // @GuardedBy("lock") <: @GuardedByUnknown, but the lock must be acquired prior to the - // method call. + // An error is issued indicating that p2 might be dereferenced without "lock" being held. The + // method call need not be modified, since @GuardedBy({}) <: @GuardedByUnknown and + // @GuardedBy("lock") <: @GuardedByUnknown, but the lock must be acquired prior to the method + // call. // :: error: (lock.not.held) boolean b2 = compare(p1, p2); } diff --git a/checker/tests/lock/GuardSatisfiedTest.java b/checker/tests/lock/GuardSatisfiedTest.java index f06ec336145..da0215fbb49 100644 --- a/checker/tests/lock/GuardSatisfiedTest.java +++ b/checker/tests/lock/GuardSatisfiedTest.java @@ -83,21 +83,20 @@ void testMethodCall( // Test the receiver type matching a parameter - // Two @GS parameters with no index are incomparable (as is the case for 'this' and 'q') + // Two @GS parameters with no index are incomparable (as is the case for 'this' and 'q'). // :: error: (guardsatisfied.parameters.must.match) methodToCall3(q); // :: error: (guardsatisfied.parameters.must.match) :: error: (lock.not.held) methodToCall3(p); synchronized (lock1) { - // Two @GS parameters with no index are incomparable (as is the case for 'this' and 'q') + // Two @GS parameters with no index are incomparable (as is the case for 'this' and 'q'). // :: error: (guardsatisfied.parameters.must.match) methodToCall3(q); // :: error: (guardsatisfied.parameters.must.match) :: error: (lock.not.held) methodToCall3(p); synchronized (lock2) { - // Two @GS parameters with no index are incomparable (as is the case for 'this' and - // 'q') + // Two @GS parameters with no index are incomparable (as is the case for 'this' and 'q'). // :: error: (guardsatisfied.parameters.must.match) methodToCall3(q); // :: error: (guardsatisfied.parameters.must.match) @@ -205,13 +204,11 @@ void testAssignment(@GuardSatisfied Object o) { } // Test disallowed @GuardSatisfied locations. - // Whenever a disallowed location can be located within a method return type, - // receiver or parameter, test it there, because it's important to check - // that those are not mistakenly allowed, since annotations - // on method return types, receivers and parameters are allowed. - // By definition, fields and non-parameter local variables cannot be - // in one of these locations on a method declaration, but other - // locations can be. + // Whenever a disallowed location can be located within a method return type, receiver or + // parameter, test it there, because it's important to check that those are not mistakenly + // allowed, since annotations on method return types, receivers and parameters are allowed. By + // definition, fields and non-parameter local variables cannot be in one of these locations on a + // method declaration, but other locations can be. // :: error: (guardsatisfied.location.disallowed) @GuardSatisfied Object field; diff --git a/checker/tests/lock/Issue524.java b/checker/tests/lock/Issue524.java index 9daf603beab..2becec197f6 100644 --- a/checker/tests/lock/Issue524.java +++ b/checker/tests/lock/Issue524.java @@ -4,9 +4,8 @@ import java.util.concurrent.locks.ReentrantLock; import org.checkerframework.checker.lock.qual.GuardedBy; -// WARNING: this test is nondeterministic, and has already been -// minimized - if you modify it by removing what appears to be -// redundant code, it may no longer reproduce the issue or provide +// WARNING: this test is nondeterministic, and has already been minimized - if you modify it by +// removing what appears to be redundant code, it may no longer reproduce the issue or provide // coverage for the issue after a fix for the issue has been made. // About the nondeterminism: diff --git a/checker/tests/nullness-asserts/NonNullMapValue.java b/checker/tests/nullness-asserts/NonNullMapValue.java index b991dbeed50..4cd369ff297 100644 --- a/checker/tests/nullness-asserts/NonNullMapValue.java +++ b/checker/tests/nullness-asserts/NonNullMapValue.java @@ -20,26 +20,22 @@ public class NonNullMapValue { // explicitly because it is the annotation we are talking about.) // HashMap myMap; // - // However, the get method's declaration is misleading (in the context of - // the nullness type system), since it can always return null no matter - // whether the map values are non-null: + // However, the get method's declaration is misleading (in the context of the nullness type + // system), since it can always return null no matter whether the map values are non-null: // V get(Object key) { ... return null; } // // Here are potential solutions: - // * Forbid declaring values as non-null. This is the wrong approach. - // (It would also be hard to express syntactically.) - // * The checker could recognize a special new annotation on the return - // value of get, indicating that its return type isn't merely inferred - // from the generic type, but is always nullable. (This special new - // annotations could even be "@Nullable". A different annotation may - // be better, becase in general we would like to issue an error - // message when someone applies an annotation to a generic type - // parameter.) - // Additionally, to reduce the number of false positive warnings caused - // by the fact that get's return value is nullable: - // * Build a more specialized sophisticated flow analysis that checks - // that the passed key to Map.containsKey() is either checked against - // Map.containsKey() or Map.keySet(). + // * Forbid declaring values as non-null. This is the wrong approach. (It would also be hard to + // express syntactically.) + // * The checker could recognize a special new annotation on the return value of get, indicating + // that its return type isn't merely inferred from the generic type, but is always nullable. + // (This special new annotations could even be "@Nullable". A different annotation may be + // better, becase in general we would like to issue an error message when someone applies an + // annotation to a generic type parameter.) + // Additionally, to reduce the number of false positive warnings caused by the fact that get's + // return value is nullable: + // * Build a more specialized sophisticated flow analysis that checks that the passed key to + // Map.containsKey() is either checked against Map.containsKey() or Map.keySet(). Map myMap; @@ -204,11 +200,10 @@ void testAndWithIllegalMapAnnotation(MyMap2 map) { interface MyMap2 { @org.checkerframework.dataflow.qual.Pure - // This annotation is not legal on containsKey in general. - // If the Map is declared as (say) Map, - // then get returns a nullable value. We really want to say that if - // containsKey returns non-null, then get returns V rather than - // @Nullable V, but I don't know how to say that. + // This annotation is not legal on containsKey in general. If the Map is declared as (say) + // Map, then get returns a nullable value. We really want to say that + // if containsKey returns non-null, then get returns V rather than @Nullable V, but I don't know + // how to say that. @EnsuresNonNullIf(result = true, expression = "get(#1)") public abstract boolean containsKey(@Nullable Object a1); diff --git a/checker/tests/nullness/AnnotatedJdkEqualsTest.java b/checker/tests/nullness/AnnotatedJdkEqualsTest.java index 98df32d4986..fd91bd7f418 100644 --- a/checker/tests/nullness/AnnotatedJdkEqualsTest.java +++ b/checker/tests/nullness/AnnotatedJdkEqualsTest.java @@ -9,11 +9,10 @@ void foo(URL u) { // As of this writing, the annotated JDK does not contain a URL.java file // for the java.net.URL class. // Nonetheless, the following code should type-check. - // This could be handled via inheritance of annotations from - // superclasses either during JDK creation or during type-checking. - // It would be impractical to manually annotate every method in the - // entire JDK: it would be too labor-intensive and there would be - // certain to be some oversights. + // This could be handled via inheritance of annotations from superclasses either during JDK + // creation or during type-checking. It would be impractical to manually annotate every method + // in the entire JDK: it would be too labor-intensive and there would be certain to be some + // oversights. u.equals(null); } } diff --git a/checker/tests/nullness/ArrayCreationNullable.java b/checker/tests/nullness/ArrayCreationNullable.java index 6c5b1a37f7b..dc8f20c5522 100644 --- a/checker/tests/nullness/ArrayCreationNullable.java +++ b/checker/tests/nullness/ArrayCreationNullable.java @@ -93,10 +93,8 @@ void testIntegerArray(@NonNull Integer @NonNull [] p) { ints[0].toString(); } - // The component type of zero-length arrays can - // be non-null - they will always generate - // IndexOutOfBoundsExceptions, but are usually just - // used for the type, e.g. in List.toArray. + // The component type of zero-length arrays can be non-null - they will always generate + // IndexOutOfBoundsExceptions, but are usually just used for the type, e.g. in List.toArray. void testLengthZero() { @NonNull Object @NonNull [] objs; objs = new Object[0]; diff --git a/checker/tests/nullness/AssertIfClient.java b/checker/tests/nullness/AssertIfClient.java index fad755d6d40..031158b01fb 100644 --- a/checker/tests/nullness/AssertIfClient.java +++ b/checker/tests/nullness/AssertIfClient.java @@ -49,10 +49,9 @@ boolean rpcResponseReceived() { return response != null; } - // Returns non-null if the response has been received, null otherwise; - // but an @AssertNonNullIfNonNull annotation would states the converse, - // that if the result is non-null then the response hs been received. - // See rpcResponseReceived. + // Returns non-null if the response has been received, null otherwise; but an + // @AssertNonNullIfNonNull annotation would states the converse, that if the result is non-null + // then the response hs been received. See rpcResponseReceived. @Pure @Nullable Object rpcResponse() { return response; diff --git a/checker/tests/nullness/AssignmentDuringInitialization.java b/checker/tests/nullness/AssignmentDuringInitialization.java index b1484ffeebb..3f6f53f43fa 100644 --- a/checker/tests/nullness/AssignmentDuringInitialization.java +++ b/checker/tests/nullness/AssignmentDuringInitialization.java @@ -28,9 +28,9 @@ public AssignmentDuringInitialization() { } public void goodBehavior() { - // this isn't a constructor or initializer - // the receiver of this method should already be initialized - // and therefore f1 and f2 should already be initialized + // This isn't a constructor or initializer. + // The receiver of this method should already be initialized + // and therefore f1 and f2 should already be initialized. f5 = f6; f6 = f5; f6.toString(); // No exception here diff --git a/checker/tests/nullness/DaikonTests.java b/checker/tests/nullness/DaikonTests.java index a0923041239..bd910a09d62 100644 --- a/checker/tests/nullness/DaikonTests.java +++ b/checker/tests/nullness/DaikonTests.java @@ -113,8 +113,7 @@ void test(Bug5 b) { // The problem is: // In the "then" branch, we have in "nnExpr" that "clazz" is non-null. // In the "else" branch, we have in "annos" that the variable is non-null. - // However, as these are facts in two different representations, the merge keeps - // neither! + // However, as these are facts in two different representations, the merge keeps neither! // // no error message expected b.clazz.hashCode(); diff --git a/checker/tests/nullness/EmptyConstructor.java b/checker/tests/nullness/EmptyConstructor.java index 972f19621d8..e0ab8494f66 100644 --- a/checker/tests/nullness/EmptyConstructor.java +++ b/checker/tests/nullness/EmptyConstructor.java @@ -16,9 +16,8 @@ public SuperClass() { // side-effect-free method // public EmptyConstructor() {} // ^ -// because there's no obvious call. The message key should be changed to -// one whose message is "call to non-side-effect-free superclass -// constructor not allowed in side-effect-free constructor" +// because there's no obvious call. The message key should be changed to one whose message is "call +// to non-side-effect-free superclass constructor not allowed in side-effect-free constructor" public class EmptyConstructor extends SuperClass { @SideEffectFree diff --git a/checker/tests/nullness/GeneralATFStore.java b/checker/tests/nullness/GeneralATFStore.java index a1a7d4e3043..fa09f950fe9 100644 --- a/checker/tests/nullness/GeneralATFStore.java +++ b/checker/tests/nullness/GeneralATFStore.java @@ -1,6 +1,5 @@ // Test case for a mysterious compilation failure. -// The underlying reason was that the GeneralATF -// tried storing defaulted declaration annotations. +// The underlying reason was that the GeneralATF tried storing defaulted declaration annotations. import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/checker/tests/nullness/Issue2619b.java b/checker/tests/nullness/Issue2619b.java index 2ccb97aeb5b..41be17b26f8 100644 --- a/checker/tests/nullness/Issue2619b.java +++ b/checker/tests/nullness/Issue2619b.java @@ -8,8 +8,7 @@ public class Issue2619b { void m01(Aux aux1, Aux aux2) { if (aux1.hasValue(Aux.MINIMUM_VALUE) && aux2.hasValue(Aux.MINIMUM_VALUE)) { - // hasValue is not side-effect-free, so the @KeyFor("aux1.map") is cleared rather than - // glb'ed. + // hasValue is not side-effect-free, so the @KeyFor("aux1.map") is cleared rather than glb'ed. // :: error: (assignment.type.incompatible) @KeyFor({"aux1.map", "aux2.map"}) String s1 = Aux.MINIMUM_VALUE; } diff --git a/checker/tests/nullness/Issue306.java b/checker/tests/nullness/Issue306.java index fb30c57f7ad..65a1dad52ba 100644 --- a/checker/tests/nullness/Issue306.java +++ b/checker/tests/nullness/Issue306.java @@ -15,19 +15,16 @@ static T check(T var) { void fakeMethod() { // @MonotonicNonNull is not reflexive. - // However, it is the most specific type argument - // inferred for check. Therefore, an error is + // However, it is the most specific type argument inferred for check. Therefore, an error is // raised. - // We need a mechanism to not consider a - // qualifier in type inference. + // We need a mechanism to not consider a qualifier in type inference. check(x); // Ugly way around the problem: Issue306.<@Nullable Object>check(x); - // The following error has to be raised: from - // the signature it is not guaranteed that - // the parameter is returned. + // The following error has to be raised: from the signature it is not guaranteed that the + // parameter is returned. // :: error: (monotonic.type.incompatible) x = check(x); } @@ -39,8 +36,7 @@ void realError(@MonotonicNonNull Object p) { x = y; // :: error: (monotonic.type.incompatible) x = p; - // It would be nice not to raise the following - // error. + // It would be nice not to raise the following error. // :: error: (monotonic.type.incompatible) x = x; } diff --git a/checker/tests/nullness/KeyForShadowing.java b/checker/tests/nullness/KeyForShadowing.java index 3416f4ac67f..db86f4ef9a4 100644 --- a/checker/tests/nullness/KeyForShadowing.java +++ b/checker/tests/nullness/KeyForShadowing.java @@ -12,18 +12,15 @@ public static void main(String... p) { String k = "key"; m0.put(k, 1); // k is @KeyFor("m0") after this line - // We expect an error for the next one since we are not - // respecting the method contract. It expects the - // key to be for the second parameter, not the first. + // We expect an error for the next one since we are not respecting the method contract. It + // expects the key to be for the second parameter, not the first. // :: error: (argument.type.incompatible) getMap3(m0, m1, k).toString(); - // We expect an error for the next one since although - // we are respecting the method contract, since the - // key is for the first parameter, the Nullness Checker - // is misinterpreting "m1" to be the local m1 to this - // method, and not the first parameter to the method. + // We expect an error for the next one since although we are respecting the method contract, + // since the key is for the first parameter, the Nullness Checker is misinterpreting "m1" to be + // the local m1 to this method, and not the first parameter to the method. // :: error: (argument.type.incompatible) getMap2(m0, m1, k).toString(); diff --git a/checker/tests/nullness/KeyForSubtyping.java b/checker/tests/nullness/KeyForSubtyping.java index 99e08710441..85de5c9ddd5 100644 --- a/checker/tests/nullness/KeyForSubtyping.java +++ b/checker/tests/nullness/KeyForSubtyping.java @@ -11,10 +11,9 @@ public void testSubtypeAssignments( @KeyFor("this.mapA") String a, @KeyFor("this.mapB") String b, @KeyFor({"this.mapA", "this.mapB"}) String ab) { - // Try the error cases first, otherwise dataflow will change the inferred - // annotations on the variables such that a line of code can have an - // effect on a subsequent line of code. We want each of these tests to - // be independent. + // Try the error cases first, otherwise dataflow will change the inferred annotations on the + // variables such that a line of code can have an effect on a subsequent line of code. We want + // each of these tests to be independent. // :: error: (assignment.type.incompatible) ab = a; diff --git a/checker/tests/nullness/Marino.java b/checker/tests/nullness/Marino.java index 989f540ef97..69fde3ba53a 100644 --- a/checker/tests/nullness/Marino.java +++ b/checker/tests/nullness/Marino.java @@ -32,13 +32,11 @@ void testWhile() throws Exception { a = null; } // Checker doesn't catch that m_str not initialized. - // This is Caveat 2 in the manual, but note that it - // is not limited to contructors. + // This is Caveat 2 in the manual, but note that it is not limited to contructors. System.out.println("Member string has length: " + m_str.length()); // Dereference of any static field is allowed. - // I suppose this is a design decision - // for practicality in interacting with libraries...? + // I suppose this is a design decision for practicality in interacting with libraries...? // :: error: (dereference.of.nullable) System.out.println("Member string has length: " + ms_str.length()); System.out.println( diff --git a/checker/tests/nullness/RawSuper.java b/checker/tests/nullness/RawSuper.java index 8842d971188..b2a8aeb9972 100644 --- a/checker/tests/nullness/RawSuper.java +++ b/checker/tests/nullness/RawSuper.java @@ -1,8 +1,7 @@ import org.checkerframework.checker.nullness.qual.*; // @skip-test -// This test is broken as it uses multiple classes. Javac halts -// when seeing the first error +// This test is broken as it uses multiple classes. Javac halts when seeing the first error public class RawSuper { class A { diff --git a/checker/tests/nullness/TestInfer.java b/checker/tests/nullness/TestInfer.java index e7b3f1937b4..82fbd08fe31 100644 --- a/checker/tests/nullness/TestInfer.java +++ b/checker/tests/nullness/TestInfer.java @@ -15,8 +15,7 @@ void foo() { List<@UnknownKeyFor ? extends Object> ls = new ArrayList<>(); bar(getValue(ls)); // this fails, but just getValue(ls) is OK // casting is also OK, ie bar((Object)getValue(ls)) - // the constraint should be T<:Object, which should typecheck - // since ls:List unifies with List where - // T<:Object. + // The constraint should be T<:Object, which should typecheck since ls:List + // unifies with List where T<:Object. } } diff --git a/checker/tests/nullness/UnexpectedRaw.java b/checker/tests/nullness/UnexpectedRaw.java index 93ad5fda9f9..339873576e1 100644 --- a/checker/tests/nullness/UnexpectedRaw.java +++ b/checker/tests/nullness/UnexpectedRaw.java @@ -28,9 +28,8 @@ class Utils { // The primary annotations on nullConsumer and the formal parameter consumer are // identical, so it comes down to the annotations on the type arguments. - // Let X stand in for the type argument of nullConsumer. For it to be a valid - // parameter, X must be contained by the type argument of the formal parameter, - // ? super C. + // Let X stand in for the type argument of nullConsumer. For it to be a valid parameter, X must + // be contained by the type argument of the formal parameter, ? super C. // // In other words, the following constraints must hold: // diff --git a/checker/tests/nullness/UnusedNullness.java b/checker/tests/nullness/UnusedNullness.java index 4727a778570..b0f3fadd770 100644 --- a/checker/tests/nullness/UnusedNullness.java +++ b/checker/tests/nullness/UnusedNullness.java @@ -4,12 +4,10 @@ import org.checkerframework.framework.qual.SubtypeOf; import org.checkerframework.framework.qual.Unused; -// TODO: feature request: the Nullness Checker should be aware of -// the @Unused annotation. -// This is difficult to implement: one needs to determine the correct -// AnnotatedTypeFactory for the "when" type system and use it -// to determine the right annotated type. We currently don't have -// a mechanism to do this. +// TODO: feature request: the Nullness Checker should be aware of the @Unused annotation. +// This is difficult to implement: one needs to determine the correct AnnotatedTypeFactory for the +// "when" type system and use it to determine the right annotated type. We currently don't have a +// mechanism to do this. // // @skip-test public class UnusedNullness { diff --git a/checker/tests/nullness/generics/GenericsExampleMin.java b/checker/tests/nullness/generics/GenericsExampleMin.java index 5bbb1d0ff07..9097387d622 100644 --- a/checker/tests/nullness/generics/GenericsExampleMin.java +++ b/checker/tests/nullness/generics/GenericsExampleMin.java @@ -23,8 +23,7 @@ T get(int i) { // This method works. // Note that it fails to work if it is moved after m2() in the syntax tree. - // TODO: the above comment seems out-of-date, as method - // m3 below works. + // TODO: the above comment seems out-of-date, as method m3 below works. void m1() { t = this.get(0); nble = this.get(0); diff --git a/checker/tests/nullness/generics/KeyForPolyKeyFor.java b/checker/tests/nullness/generics/KeyForPolyKeyFor.java index 1c9e5ed257a..a554aa50a39 100644 --- a/checker/tests/nullness/generics/KeyForPolyKeyFor.java +++ b/checker/tests/nullness/generics/KeyForPolyKeyFor.java @@ -17,10 +17,9 @@ void m() { for (@KeyFor("dict") String noun : nounSubset(dict.keySet())) {} } - // This method's declaration uses no @KeyFor annotations - // because in addition to being used by the dictionary feature, - // it is also used by a spell checker that only stores sets of words - // and does not use the notions of dictionaries, maps or keys. + // This method's declaration uses no @KeyFor annotations because in addition to being used by the + // dictionary feature, it is also used by a spell checker that only stores sets of words and does + // not use the notions of dictionaries, maps or keys. Set<@PolyKeyFor String> nounSubset(Set<@PolyKeyFor String> words) { return words; } diff --git a/checker/tests/tainting/TypeInvalid.java b/checker/tests/tainting/TypeInvalid.java index 0fbb939bb27..b308994c127 100644 --- a/checker/tests/tainting/TypeInvalid.java +++ b/checker/tests/tainting/TypeInvalid.java @@ -1,8 +1,7 @@ // Test case for Issue 292: // https://github.com/typetools/checker-framework/issues/292 -// TODO: ensure that type validation is consistently performed for each -// possible tree. +// TODO: ensure that type validation is consistently performed for each possible tree. // We should also add a jtreg version of this test to // ensure that each error is only output once and in the right place. diff --git a/checker/tests/units/Addition.java b/checker/tests/units/Addition.java index 3efae3d2203..3937a21f7fd 100644 --- a/checker/tests/units/Addition.java +++ b/checker/tests/units/Addition.java @@ -128,9 +128,8 @@ void good() { @s int sSecond = aSecond + bSecond; } - // Addition is illegal when the operands have different units or one - // is unqualified. In these tests, we cycle between the result and - // the first or second operand having an incorrect type. + // Addition is illegal when the operands have different units or one is unqualified. In these + // tests, we cycle between the result and the first or second operand having an incorrect type. void bad() { // Dimensions // Acceleration diff --git a/checker/tests/units/SubtractionUnits.java b/checker/tests/units/SubtractionUnits.java index 4233d13d610..c020bb5da8f 100644 --- a/checker/tests/units/SubtractionUnits.java +++ b/checker/tests/units/SubtractionUnits.java @@ -128,9 +128,8 @@ void good() { @s int sSecond = aSecond - bSecond; } - // Subtraction is illegal when the operands have different units or one - // is unqualified. In these tests, we cycle between the result and - // the first or second operand having an incorrect type. + // Subtraction is illegal when the operands have different units or one is unqualified. In these + // tests, we cycle between the result and the first or second operand having an incorrect type. void bad() { // Dimensions // Acceleration diff --git a/checker/tests/units/Units.java b/checker/tests/units/Units.java index 9603ef9d309..712c3159188 100644 --- a/checker/tests/units/Units.java +++ b/checker/tests/units/Units.java @@ -7,9 +7,8 @@ public class Units { @m int m1 = 5 * UnitsTools.m; - // The advantage of using the multiplication with a unit is that - // also double, float, etc. are easily handled and we don't need - // to end a huge number of methods to UnitsTools. + // The advantage of using the multiplication with a unit is that also double, float, etc. are + // easily handled and we don't need to end a huge number of methods to UnitsTools. @m double dm = 9.34d * UnitsTools.m; // With a static import: diff --git a/checker/tests/wpi-testchecker/non-annotated/ConflictingAnnotationsTest.java b/checker/tests/wpi-testchecker/non-annotated/ConflictingAnnotationsTest.java index f0f18d7da32..1026c07e3bb 100644 --- a/checker/tests/wpi-testchecker/non-annotated/ConflictingAnnotationsTest.java +++ b/checker/tests/wpi-testchecker/non-annotated/ConflictingAnnotationsTest.java @@ -1,9 +1,7 @@ -// Tests whether inferring an @Sibling1 annotation when another -// @Sibling1 annotation in the default package is present causes -// problems. Conflicting annotations that are not in the default -// package are not a problem, because TypeMirror#toString prints -// their fully-qualified names, making namespace collisions -// impossible. +// Tests whether inferring an @Sibling1 annotation when another @Sibling1 annotation in the default +// package is present causes problems. Conflicting annotations that are not in the default package +// are not a problem, because TypeMirror#toString prints their fully-qualified names, making +// namespace collisions impossible. public class ConflictingAnnotationsTest { @@ -11,9 +9,8 @@ int getWPINamespaceSibling1() { return getSibling1(); } - // This version of Sibling1 is not typechecked - it doesn't - // belong to the checker and instead is defined in the Sibling1.java - // file in this directory. + // This version of Sibling1 is not typechecked - it doesn't belong to the checker and instead is + // defined in the Sibling1.java file in this directory. @Sibling1 Object getLocalSibling1(Object o) { return o; } diff --git a/checker/tests/wpi-testchecker/non-annotated/DefaultsTest.java b/checker/tests/wpi-testchecker/non-annotated/DefaultsTest.java index 4b7c592504c..2c4d5f2dd9d 100644 --- a/checker/tests/wpi-testchecker/non-annotated/DefaultsTest.java +++ b/checker/tests/wpi-testchecker/non-annotated/DefaultsTest.java @@ -1,10 +1,9 @@ import org.checkerframework.checker.testchecker.wholeprograminference.qual.DefaultType; import org.checkerframework.checker.testchecker.wholeprograminference.qual.WholeProgramInferenceBottom; -// The @DefaultType annotation, which is the default for every location, is forbidden -// to be written anywhere. This class attempts to infer @DefaultType in several -// locations, and the annotated version of this class (in the annotated folder) -// should have no explicit @DefaultType annotations. +// The @DefaultType annotation, which is the default for every location, is forbidden to be written +// anywhere. This class attempts to infer @DefaultType in several locations, and the annotated +// version of this class (in the annotated folder) should have no explicit @DefaultType annotations. public class DefaultsTest { String defaultField = ""; String defaultField2; diff --git a/checker/tests/wpi-testchecker/non-annotated/EnumConstants.java b/checker/tests/wpi-testchecker/non-annotated/EnumConstants.java index 6e00f4fce80..58d47e1177f 100644 --- a/checker/tests/wpi-testchecker/non-annotated/EnumConstants.java +++ b/checker/tests/wpi-testchecker/non-annotated/EnumConstants.java @@ -1,10 +1,8 @@ // @skip-test -// Check that types on enum constants can be inferred. -// This test doesn't succeed for either kind of WPI, -// because WPI doesn't learn anything about enum constants -// from how they're used. They also cannot be assigned to, -// so there's no way for WPI to learn their types. +// Check that types on enum constants can be inferred. This test doesn't succeed for either kind of +// WPI, because WPI doesn't learn anything about enum constants from how they're used. They also +// cannot be assigned to, so there's no way for WPI to learn their types. import org.checkerframework.checker.testchecker.wholeprograminference.qual.Sibling1; diff --git a/checker/tests/wpi-testchecker/non-annotated/EnumWithInnerClass.java b/checker/tests/wpi-testchecker/non-annotated/EnumWithInnerClass.java index f18bfa2be48..4dcb7844bb0 100644 --- a/checker/tests/wpi-testchecker/non-annotated/EnumWithInnerClass.java +++ b/checker/tests/wpi-testchecker/non-annotated/EnumWithInnerClass.java @@ -1,7 +1,5 @@ -// This test ensures that enums with inner classes are -// printed properly to avoid crashing the stub parser, -// which was a problem with an earlier version of stub-based -// WPI. +// This test ensures that enums with inner classes are printed properly to avoid crashing the stub +// parser, which was a problem with an earlier version of stub-based WPI. import org.checkerframework.checker.testchecker.wholeprograminference.qual.Sibling1; diff --git a/checker/tests/wpi-testchecker/non-annotated/ExpectedErrors.java b/checker/tests/wpi-testchecker/non-annotated/ExpectedErrors.java index c58055d7cf3..8c6c31bd0c1 100644 --- a/checker/tests/wpi-testchecker/non-annotated/ExpectedErrors.java +++ b/checker/tests/wpi-testchecker/non-annotated/ExpectedErrors.java @@ -180,11 +180,10 @@ public int suppressWarningsMethodReturn() { return getSibling1(); } - // It is problematic to automatically test whole-program inference for method - // params when suppressing warnings. - // Since we must use @SuppressWarnings() for the method, - // we won't be able to catch any error inside the method body. - // Verified manually that in the "annotated" folder param's type wasn't + // It is problematic to automatically test whole-program inference for method params when + // suppressing warnings. + // Since we must use @SuppressWarnings() for the method, we won't be able to catch any error + // inside the method body. Verified manually that in the "annotated" folder param's type wasn't // updated. @SuppressWarnings("all") public void suppressWarningsMethodParams(int param) {} @@ -201,9 +200,8 @@ class NullTest { private String privateField; public String publicField; - // The types of both fields are not refined to @WholeProgramInferenceBottom, - // as whole-program inference never performs refinement in the presence - // of the null literal. + // The types of both fields are not refined to @WholeProgramInferenceBottom, as whole-program + // inference never performs refinement in the presence of the null literal. @SuppressWarnings("value") void assignFieldsToBottom() { privateField = null; diff --git a/checker/tests/wpi-testchecker/non-annotated/ValueCheck.java b/checker/tests/wpi-testchecker/non-annotated/ValueCheck.java index 8d41329adb3..dfbdd1a1374 100644 --- a/checker/tests/wpi-testchecker/non-annotated/ValueCheck.java +++ b/checker/tests/wpi-testchecker/non-annotated/ValueCheck.java @@ -1,7 +1,6 @@ -// Checks that annotations from the Value Checker (which -// is a subchecker of the WPI test checker) are actually -// present in the generated files, even when there is also -// an annotation from the main checker. +// Checks that annotations from the Value Checker (which is a subchecker of the WPI test checker) +// are actually present in the generated files, even when there is also an annotation from the main +// checker. import org.checkerframework.checker.testchecker.wholeprograminference.qual.Sibling1; import org.checkerframework.common.value.qual.IntVal; diff --git a/dataflow/src/main/java/org/checkerframework/dataflow/analysis/AbstractAnalysis.java b/dataflow/src/main/java/org/checkerframework/dataflow/analysis/AbstractAnalysis.java index d94be332a27..04429ebb08f 100644 --- a/dataflow/src/main/java/org/checkerframework/dataflow/analysis/AbstractAnalysis.java +++ b/dataflow/src/main/java/org/checkerframework/dataflow/analysis/AbstractAnalysis.java @@ -326,9 +326,8 @@ protected TransferResult callTransferFunction( Node node, TransferInput transferInput) { assert transferFunction != null : "@AssumeAssertion(nullness): invariant"; if (node.isLValue()) { - // TODO: should the default behavior return a regular transfer result, a conditional - // transfer result (depending on store.containsTwoStores()), or is the following - // correct? + // TODO: should the default behavior return a regular transfer result, a conditional transfer + // result (depending on store.containsTwoStores()), or is the following correct? return new RegularTransferResult<>(null, transferInput.getRegularStore()); } transferInput.node = node; diff --git a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/CFGProcessor.java b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/CFGProcessor.java index 8e631df82b3..c3e9611ec94 100644 --- a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/CFGProcessor.java +++ b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/CFGProcessor.java @@ -100,11 +100,9 @@ public Void visitMethod(MethodTree node, Void p) { ExecutableElement el = TreeUtils.elementFromDeclaration(node); if (el.getSimpleName().contentEquals(methodName)) { methodTree = node; - // Stop execution by throwing an exception. This - // makes sure that compilation does not proceed, and - // thus the AST is not modified by further phases of - // the compilation (and we save the work to do the - // compilation). + // Stop execution by throwing an exception. This makes sure that compilation does not + // proceed, and thus the AST is not modified by further phases of the compilation (and we + // save the work to do the compilation). throw new RuntimeException(); } return null; diff --git a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseOne.java b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseOne.java index d9a2a0742cc..7f0f91f6fc7 100644 --- a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseOne.java +++ b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseOne.java @@ -439,12 +439,10 @@ public PhaseOneResult process(TreePath bodyPath, UnderlyingAST underlyingAST) { } } - // add marker to indicate that the next block will be the exit block - // Note: if there is a return statement earlier in the method (which - // is always the case for non-void methods), then this is not - // strictly necessary. However, it is also not a problem, as it will - // just generate a degenerated control graph case that will be - // removed in a later phase. + // Add marker to indicate that the next block will be the exit block. + // Note: if there is a return statement earlier in the method (which is always the case for + // non-void methods), then this is not strictly necessary. However, it is also not a problem, as + // it will just generate a degenerated control graph case that will be removed in a later phase. nodeList.add(new UnconditionalJump(regularExitLabel)); return new PhaseOneResult( @@ -1012,9 +1010,8 @@ protected Node narrowAndBox(Node node, TypeMirror destType) { * @return whether this conversion requires narrowing to succeed */ protected boolean conversionRequiresNarrowing(TypeMirror varType, Node node) { - // Narrowing is restricted to cases where the left hand side - // is byte, char, short or Byte, Char, Short and the right - // hand side is a constant. + // Narrowing is restricted to cases where the left hand side is byte, char, short or Byte, Char, + // Short and the right hand side is a constant. TypeMirror unboxedVarType = TypesUtils.isBoxedPrimitive(varType) ? types.unboxedType(varType) : varType; TypeKind unboxedVarKind = unboxedVarType.getKind(); @@ -1130,11 +1127,10 @@ protected Node methodInvocationConvert(Node node, TypeMirror formalType) { */ protected List convertCallArguments( ExecutableElement method, List actualExprs) { - // NOTE: It is important to convert one method argument before - // generating CFG nodes for the next argument, since label binding - // expects nodes to be generated in execution order. Therefore, - // this method first determines which conversions need to be applied - // and then iterates over the actual arguments. + // NOTE: It is important to convert one method argument before generating CFG nodes for the next + // argument, since label binding expects nodes to be generated in execution order. Therefore, + // this method first determines which conversions need to be applied and then iterates over the + // actual arguments. List formals = method.getParameters(); int numFormals = formals.size(); @@ -1142,9 +1138,8 @@ protected List convertCallArguments( int numActuals = actualExprs.size(); if (method.isVarArgs()) { - // Create a new array argument if the actuals outnumber - // the formals, or if the last actual is not assignable - // to the last formal. + // Create a new array argument if the actuals outnumber the formals, or if the last actual is + // not assignable to the last formal. int lastArgIndex = numFormals - 1; TypeMirror lastParamType = formals.get(lastArgIndex).asType(); if (numActuals == numFormals @@ -1162,9 +1157,8 @@ protected List convertCallArguments( } } else { assert lastParamType instanceof ArrayType : "variable argument formal must be an array"; - // Apply method invocation conversion to lastArgIndex - // arguments and use the remaining ones to initialize - // an array. + // Apply method invocation conversion to lastArgIndex arguments and use the remaining ones + // to initialize an array. for (int i = 0; i < lastArgIndex; i++) { Node actualVal = scan(actualExprs.get(i), null); convertedNodes.add(methodInvocationConvert(actualVal, formals.get(i).asType())); @@ -1298,15 +1292,12 @@ public MethodInvocationNode visitMethodInvocation(MethodInvocationTree tree, Voi // see JLS 15.12.4 - // First, compute the receiver, if any (15.12.4.1) - // Second, evaluate the actual arguments, left to right and - // possibly some arguments are stored into an array for variable - // arguments calls (15.12.4.2) - // Third, test the receiver, if any, for nullness (15.12.4.4) - // Fourth, convert the arguments to the type of the formal - // parameters (15.12.4.5) - // Fifth, if the method is synchronized, lock the receiving - // object or class (15.12.4.5) + // First, compute the receiver, if any (15.12.4.1). + // Second, evaluate the actual arguments, left to right and possibly some arguments are stored + // into an array for variable arguments calls (15.12.4.2). + // Third, test the receiver, if any, for nullness (15.12.4.4). + // Fourth, convert the arguments to the type of the formal parameters (15.12.4.5). + // Fifth, if the method is synchronized, lock the receiving object or class (15.12.4.5). ExecutableElement method = TreeUtils.elementFromUse(tree); if (method == null) { // The method wasn't found, e.g. because of a compilation error. @@ -1334,13 +1325,11 @@ public MethodInvocationNode visitMethodInvocation(MethodInvocationTree tree, Voi List arguments; if (TreeUtils.isEnumSuper(tree)) { - // Don't convert arguments for enum super calls. The AST contains - // no actual arguments, while the method element expects two arguments, - // leading to an exception in convertCallArguments. Since no actual - // arguments are present in the AST that is being checked, it shouldn't - // cause any harm to omit the conversions. - // See also BaseTypeVisitor.visitMethodInvocation and - // QualifierPolymorphism.annotate + // Don't convert arguments for enum super calls. The AST contains no actual arguments, while + // the method element expects two arguments, leading to an exception in convertCallArguments. + // Since no actual arguments are present in the AST that is being checked, it shouldn't cause + // any harm to omit the conversions. + // See also BaseTypeVisitor.visitMethodInvocation and QualifierPolymorphism.annotate. arguments = Collections.emptyList(); } else { arguments = convertCallArguments(method, actualExprs); @@ -1815,10 +1804,9 @@ public Node visitCompoundAssignment(CompoundAssignmentTree tree, Void p) { @Override public Node visitBinary(BinaryTree tree, Void p) { - // Note that for binary operations it is important to perform any required - // promotion on the left operand before generating any Nodes for the right - // operand, because labels must be inserted AFTER ALL preceding Nodes and - // BEFORE ALL following Nodes. + // Note that for binary operations it is important to perform any required promotion on the left + // operand before generating any Nodes for the right operand, because labels must be inserted + // AFTER ALL preceding Nodes and BEFORE ALL following Nodes. Node r = null; Tree leftTree = tree.getLeftOperand(); Tree rightTree = tree.getRightOperand(); @@ -2173,9 +2161,9 @@ public void build() { } } if (defaultIndex != null) { - // the checks of all cases must happen before the default case, - // therefore we build the default case last. - // fallthrough is still handled correctly with the caseBodyLabels. + // The checks of all cases must happen before the default case, therefore we build the + // default case last. + // Fallthrough is still handled correctly with the caseBodyLabels. buildCase(switchTree.getCases().get(defaultIndex), defaultIndex); } @@ -2284,9 +2272,8 @@ public Node visitDoWhileLoop(DoWhileLoopTree tree, Void p) { Label loopEntry = new Label(); Label loopExit = new Label(); - // If the loop is a labeled statement, then its continue - // target is identical for continues with no label and - // continues with the loop's label. + // If the loop is a labeled statement, then its continue target is identical for continues with + // no label and continues with the loop's label. Label conditionStart; if (parentLabel != null) { conditionStart = continueLabels.get(parentLabel); @@ -2340,9 +2327,8 @@ public Node visitEnhancedForLoop(EnhancedForLoopTree tree, Void p) { Label loopEntry = new Label(); Label loopExit = new Label(); - // If the loop is a labeled statement, then its continue - // target is identical for continues with no label and - // continues with the loop's label. + // If the loop is a labeled statement, then its continue target is identical for continues with + // no label and continues with the loop's label. Label updateStart; if (parentLabel != null) { updateStart = continueLabels.get(parentLabel); @@ -2453,9 +2439,8 @@ public Node visitEnhancedForLoop(EnhancedForLoopTree tree, Void p) { MethodInvocationNode nextCallNode = new MethodInvocationNode( nextCall, nextAccessNode, Collections.emptyList(), getCurrentPath()); - // If the type of iteratorVariable is a capture, its type tree may be missing - // annotations, so save the expression in the node so that the full type can be found - // later. + // If the type of iteratorVariable is a capture, its type tree may be missing annotations, so + // save the expression in the node so that the full type can be found later. nextCallNode.setIterableExpression(expression); nextCallNode.setInSource(false); extendWithNode(nextCallNode); @@ -2644,9 +2629,8 @@ public Node visitForLoop(ForLoopTree tree, Void p) { Label loopEntry = new Label(); Label loopExit = new Label(); - // If the loop is a labeled statement, then its continue - // target is identical for continues with no label and - // continues with the loop's label. + // If the loop is a labeled statement, then its continue target is identical for continues with + // no label and continues with the loop's label. Label updateStart; if (parentLabel != null) { updateStart = continueLabels.get(parentLabel); @@ -2787,10 +2771,9 @@ public Node visitArrayAccess(ArrayAccessTree tree, Void p) { @Override public Node visitLabeledStatement(LabeledStatementTree tree, Void p) { - // This method can set the break target after generating all Nodes - // in the contained statement, but it can't set the continue target, - // which may be in the middle of a sequence of nodes. Labeled loops - // must look up and use the continue Labels. + // This method can set the break target after generating all Nodes in the contained statement, + // but it can't set the continue target, which may be in the middle of a sequence of + // nodes. Labeled loops must look up and use the continue Labels. Name labelName = tree.getLabel(); Label breakL = new Label(labelName + "_break"); @@ -3087,10 +3070,10 @@ public Node visitTry(TryTree tree, Void p) { tryStack.pushFrame(new TryCatchFrame(types, catchLabels)); - // Must scan the resources *after* we push frame to tryStack. Otherwise we can - // lose catch blocks. - // TODO: Should we handle try-with-resources blocks by also generating code - // for automatically closing the resources? + // Must scan the resources *after* we push frame to tryStack. Otherwise we can lose catch + // blocks. + // TODO: Should we handle try-with-resources blocks by also generating code for automatically + // closing the resources? List resources = tree.getResources(); for (Tree resource : resources) { scan(resource, p); @@ -3154,11 +3137,10 @@ public Node visitTry(TryTree tree, Void p) { } if (hasExceptionalPath(exceptionalFinallyLabel)) { - // If an exceptional path exists, scan 'finallyBlock' for - // 'exceptionalFinallyLabel', and scan copied 'finallyBlock' for 'finallyLabel' - // (a successful path). If there is no successful path, it will be removed in - // later phase. TODO: Don't we need a separate finally block for each kind of - // exception? + // If an exceptional path exists, scan 'finallyBlock' for 'exceptionalFinallyLabel', and + // scan copied 'finallyBlock' for 'finallyLabel' (a successful path). If there is no + // successful path, it will be removed in later phase. + // TODO: Don't we need a separate finally block for each kind of exception? addLabelForNextNode(exceptionalFinallyLabel); extendWithNode( new MarkerNode( @@ -3574,9 +3556,8 @@ public Node visitWhileLoop(WhileLoopTree tree, Void p) { Label loopEntry = new Label(); Label loopExit = new Label(); - // If the loop is a labeled statement, then its continue - // target is identical for continues with no label and - // continues with the loop's label. + // If the loop is a labeled statement, then its continue target is identical for continues with + // no label and continues with the loop's label. Label conditionStart; if (parentLabel != null) { conditionStart = continueLabels.get(parentLabel); diff --git a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseTwo.java b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseTwo.java index a96b5b2fc76..4f4ded0b35d 100644 --- a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseTwo.java +++ b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseTwo.java @@ -80,9 +80,8 @@ public static ControlFlowGraph process(PhaseOneResult in) { case CONDITIONAL_JUMP: { ConditionalJump cj = (ConditionalJump) node; - // Exception nodes may fall through to conditional jumps, - // so we set the block which is required for the insertion - // of missing edges. + // Exception nodes may fall through to conditional jumps, so we set the block which is + // required for the insertion of missing edges. node.setBlock(block); assert block != null; final ConditionalBlockImpl cb = new ConditionalBlockImpl(); @@ -153,9 +152,9 @@ public void setSuccessor(BlockImpl successor) { block.setSuccessor(e); block = new RegularBlockImpl(); - // ensure linking between e and next block (normal edge) - // Note: do not link to the next block for throw statements - // (these throw exceptions for sure) + // Ensure linking between e and next block (normal edge). + // Note: do not link to the next block for throw statements (these throw exceptions for + // sure). if (!node.getTerminatesExecution()) { missingEdges.add(new MissingEdge(e, i + 1)); } diff --git a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/TryCatchFrame.java b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/TryCatchFrame.java index d5f9c97ae8f..fed6e3179cd 100644 --- a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/TryCatchFrame.java +++ b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/TryCatchFrame.java @@ -53,24 +53,22 @@ public String toString() { */ @Override public boolean possibleLabels(TypeMirror thrown, Set