diff --git a/build.gradle b/build.gradle index 8e293b06c23..19bf3cdc7ac 100644 --- a/build.gradle +++ b/build.gradle @@ -927,9 +927,10 @@ subprojects { } } catch (Exception ex) { if (ex.getCause() != null && ex.getCause().getCause()!= null) { - String msg = ex.getCause().getLocalizedMessage() + ':\n' - msg += ex.getCause().getCause().getLocalizedMessage() + '\n' - msg += 'Have you installed jtreg?' + String msg = String.join(System.lineSeparator(), + ex.getCause().getLocalizedMessage() + ':', + ex.getCause().getCause().getLocalizedMessage(), + 'Have you installed jtreg?') println msg } throw ex diff --git a/checker-qual-android/build.gradle b/checker-qual-android/build.gradle index 38ce591d55d..816f06e18b1 100644 --- a/checker-qual-android/build.gradle +++ b/checker-qual-android/build.gradle @@ -38,14 +38,16 @@ final checkerQualAndroidPom(publication) { publication.from components.java publication.pom { name = 'Checker Qual Android' - description = 'checker-qual-android contains annotations (type qualifiers) that a programmer\n' + - 'writes to specify Java code for type-checking by the Checker Framework.\n' + - '\n' + - 'The checker-qual-android artifact is identical to the checker-qual\n' + - 'artifact, except that in checker-qual-android annotations have classfile\n' + - 'retention. The default Android Gradle plugin retains types annotated with\n' + - 'runtime annotations in the main dex, but strips out class-retention\n' + - 'annotations.\n' + description = + String.join(System.lineSeparator(), + 'checker-qual-android contains annotations (type qualifiers) that a programmer', + 'writes to specify Java code for type-checking by the Checker Framework.', + '', + 'The checker-qual-android artifact is identical to the checker-qual', + 'artifact, except that in checker-qual-android annotations have classfile', + 'retention. The default Android Gradle plugin retains types annotated with', + 'runtime annotations in the main dex, but strips out class-retention', + 'annotations.') licenses { license { name = 'The MIT License' diff --git a/checker-qual/build.gradle b/checker-qual/build.gradle index a74a851b4e0..7a575e377f9 100644 --- a/checker-qual/build.gradle +++ b/checker-qual/build.gradle @@ -45,8 +45,9 @@ final checkerQualPom(publication) { publication.from components.java publication.pom { name = 'Checker Qual' - description = 'checker-qual contains annotations (type qualifiers) that a programmer\n' + - 'writes to specify Java code for type-checking by the Checker Framework.\n' + description = String.join(System.lineSeparator(), + 'checker-qual contains annotations (type qualifiers) that a programmer' + + 'writes to specify Java code for type-checking by the Checker Framework.') licenses { license { name = 'The MIT License' diff --git a/checker/build.gradle b/checker/build.gradle index 123c8f27b8d..c4159718fa6 100644 --- a/checker/build.gradle +++ b/checker/build.gradle @@ -1042,12 +1042,14 @@ final checkerPom(publication) { // Don't use publication.from components.java which would publish the skinny jar as checker.jar. publication.pom { name = 'Checker Framework' - description = 'The Checker Framework enhances Java\'s type system to\n' + - 'make it more powerful and useful. This lets software developers\n' + - 'detect and prevent errors in their Java programs.\n' + - 'The Checker Framework includes compiler plug-ins ("checkers")\n' + - 'that find bugs or verify their absence. It also permits you to\n' + - 'write your own compiler plug-ins.' + description = + String.join(System.lineSeparator(), + 'The Checker Framework enhances Java\'s type system to', + 'make it more powerful and useful. This lets software developers', + 'detect and prevent errors in their Java programs.', + 'The Checker Framework includes compiler plug-ins ("checkers")', + 'that find bugs or verify their absence. It also permits you to', + 'write your own compiler plug-ins.') licenses { license { name = 'GNU General Public License, version 2 (GPL2), with the classpath exception' diff --git a/checker/src/main/java/org/checkerframework/checker/resourceleak/messages.properties b/checker/src/main/java/org/checkerframework/checker/resourceleak/messages.properties index c5776fbf9a5..a9df3c24711 100644 --- a/checker/src/main/java/org/checkerframework/checker/resourceleak/messages.properties +++ b/checker/src/main/java/org/checkerframework/checker/resourceleak/messages.properties @@ -1,12 +1,12 @@ -required.method.not.called=@MustCall %s may not have been invoked on %s or any of its aliases.\nThe type of object is: %s.\nReason for going out of scope: %s +required.method.not.called=@MustCall %s may not have been invoked on %s or any of its aliases.%nThe type of object is: %s.%nReason for going out of scope: %s missing.creates.mustcall.for=Method %s re-assigns the non-final, owning field %s.%s, but does not have a corresponding @CreatesMustCallFor annotation. incompatible.creates.mustcall.for=Method %s re-assigns the non-final, owning field %s.%s, but its @CreatesMustCallFor annotation targets %s. reset.not.owning=Calling method %s resets the must-call obligations of the expression %s, which is non-owning. Either annotate its declaration with an @Owning annotation, extract it into a local variable, or write a corresponding @CreatesMustCallFor annotation on the method that encloses this statement. -creates.mustcall.for.override.invalid=Method %s cannot override method %s, which defines fewer @CreatesMustCallFor targets.\nfound: %s\nrequired: %s +creates.mustcall.for.override.invalid=Method %s cannot override method %s, which defines fewer @CreatesMustCallFor targets.%nfound: %s%nrequired: %s creates.mustcall.for.invalid.target=Cannot create a must-call obligation for "%s" since its type %s has no must-call methods. -destructor.exceptional.postcondition=Method %s must resolve the must-call obligations of the owning field %s along all paths, including exceptional paths. On an exceptional path, the @EnsuresCalledMethods annotation was not satisfied.\nFound: %s\nRequired: %s -mustcallalias.out.of.scope=This @MustCallAlias parameter might go out of scope without being assigned into an owning field of this object (if this is a constructor) or returned.\nReason for going out of scope: %s -mustcallalias.method.return.and.param=@MustCallAlias annotations must appear in pairs (one on a return type and one on a parameter type).\nBut %s -owning.override.param=Incompatible ownership for parameter %s.\nfound : no ownership annotation or @NotOwning\nrequired: @Owning\nConsequence: method %s in %s cannot override method %s in %s -owning.override.return=Incompatible ownership for return.\nfound : no ownership annotation or @Owning\nrequired: @NotOwning\nConsequence: method %s in %s cannot override method %s in %s -required.method.not.known=The checker cannot determine the must call methods of %s or any of its aliases, so it could not determine if they were called. Typically, this error indicates that you need to write an @MustCall annotation (often on an unconstrained generic type).\nThe type of object is: %s.\nReason for going out of scope: %s +destructor.exceptional.postcondition=Method %s must resolve the must-call obligations of the owning field %s along all paths, including exceptional paths. On an exceptional path, the @EnsuresCalledMethods annotation was not satisfied.%nFound: %s%nRequired: %s +mustcallalias.out.of.scope=This @MustCallAlias parameter might go out of scope without being assigned into an owning field of this object (if this is a constructor) or returned.%nReason for going out of scope: %s +mustcallalias.method.return.and.param=@MustCallAlias annotations must appear in pairs (one on a return type and one on a parameter type).%nBut %s +owning.override.param=Incompatible ownership for parameter %s.%nfound : no ownership annotation or @NotOwning%nrequired: @Owning%nConsequence: method %s in %s cannot override method %s in %s +owning.override.return=Incompatible ownership for return.%nfound : no ownership annotation or @Owning%nrequired: @NotOwning%nConsequence: method %s in %s cannot override method %s in %s +required.method.not.known=The checker cannot determine the must call methods of %s or any of its aliases, so it could not determine if they were called. Typically, this error indicates that you need to write an @MustCall annotation (often on an unconstrained generic type).%nThe type of object is: %s.%nReason for going out of scope: %s diff --git a/dataflow/build.gradle b/dataflow/build.gradle index 8127ddfaa41..b23e410b157 100644 --- a/dataflow/build.gradle +++ b/dataflow/build.gradle @@ -187,11 +187,13 @@ final dataflowShadedPom(MavenPublication publication, String shadedPkgName) { publication.artifactId = "dataflow-${shadedPkgName}" publication.pom { name = "Dataflow (${shadedPkgName})" - description = "dataflow-${shadedPkgName} is a dataflow framework based on the javac compiler.\n" + - '\n' + - 'It differs from the org.checkerframework:dataflow artifact in two ways.\n' + - "First, the packages in this artifact have been renamed to org.checkerframework.${shadedPkgName}.*.\n" + - 'Second, unlike the dataflow artifact, this artifact contains the dependencies it requires.' + description = + String.join(System.lineSeparator(), + "dataflow-${shadedPkgName} is a dataflow framework based on the javac compiler.", + '', + 'It differs from the org.checkerframework:dataflow artifact in two ways.', + "First, the packages in this artifact have been renamed to org.checkerframework.${shadedPkgName}.*.", + 'Second, unlike the dataflow artifact, this artifact contains the dependencies it requires.') licenses { license { name = 'GNU General Public License, version 2 (GPL2), with the classpath exception' diff --git a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/AbstractCFGVisualizer.java b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/AbstractCFGVisualizer.java index b5a8254ad73..cfdb28afe1f 100644 --- a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/AbstractCFGVisualizer.java +++ b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/AbstractCFGVisualizer.java @@ -192,8 +192,8 @@ protected void addBlock(Block b, Set visited, Queue workList) { * @param bb the block * @param analysis the current analysis * @param separator the line separator. Examples: "\\l" for left justification in {@link - * DOTCFGVisualizer} (this is really a terminator, not a separator), "\n" to add a new line in - * {@link StringCFGVisualizer} + * DOTCFGVisualizer} (this is really a terminator, not a separator), "\n" or {@code + * System.lineSeparator()} to add a new line in {@link StringCFGVisualizer} * @return the String representation of the block */ protected String visualizeBlockWithSeparator( @@ -296,8 +296,8 @@ protected enum VisualizeWhere { * @param bb a block * @param analysis the current analysis * @param separator the line separator. Examples: "\\l" for left justification in {@link - * DOTCFGVisualizer} (which is actually a line TERMINATOR, not a separator!), "\n" to add a - * new line in {@link StringCFGVisualizer} + * DOTCFGVisualizer} (which is actually a line TERMINATOR, not a separator!), "\n" or {@code + * System.lineSeparator()} to add a new line in {@link StringCFGVisualizer} * @return the visualization of the transfer input before or after the given block */ protected String visualizeBlockTransferInputHelper( diff --git a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java index e7f149b99a4..beedf9ccb27 100644 --- a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java +++ b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizeLauncher.java @@ -286,7 +286,7 @@ public static void writeStringOfCFG( if (res != null && res.get("stringGraph") != null) { out.write(res.get("stringGraph").toString()); } - out.write("\n"); + out.write(System.lineSeparator()); } catch (IOException e) { e.printStackTrace(); } diff --git a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/StringCFGVisualizer.java b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/StringCFGVisualizer.java index 9ee7882bcbe..0f47ce3257c 100644 --- a/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/StringCFGVisualizer.java +++ b/dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/StringCFGVisualizer.java @@ -48,7 +48,7 @@ public void init(Map args) { @Override public String getSeparator() { - return "\n"; + return System.lineSeparator(); } @Override diff --git a/framework-test/build.gradle b/framework-test/build.gradle index f1b6fdc87c9..9d09a7b280c 100644 --- a/framework-test/build.gradle +++ b/framework-test/build.gradle @@ -23,8 +23,9 @@ final frameworkTest(publication) { publication.from components.java publication.pom { name = 'Checker Framework Testing Library' - description = 'framework-test contains utility classes for testing type-checkers\n' + - 'that are built on the Checker Framework.' + description = String.join(System.lineSeparator(), + 'framework-test contains utility classes for testing type-checkers' + + 'that are built on the Checker Framework.') licenses { license { name = 'GNU General Public License, version 2 (GPL2), with the classpath exception' diff --git a/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java b/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java index 342d8366227..6ab1a194f65 100644 --- a/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java +++ b/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java @@ -487,12 +487,9 @@ protected void testAnnotationInsertion() { String withAnnotations; try (InputStream annotationInputStream = root.getSourceFile().openInputStream()) { - // This check only runs on files from the Checker Framework test suite, which should all - // use UNIX line separators. Using System.lineSeparator instead of "\n" could cause the - // test to fail on Mac or Windows. withAnnotations = new InsertAjavaAnnotations(elements) - .insertAnnotations(annotationInputStream, withoutAnnotations, "\n"); + .insertAnnotations(annotationInputStream, withoutAnnotations, System.lineSeparator()); } catch (IOException e) { throw new BugInCF("Error while reading Java file: " + root.getSourceFile().toUri(), e); } @@ -501,7 +498,7 @@ protected void testAnnotationInsertion() { try { modifiedAst = JavaParserUtil.parseCompilationUnit(withAnnotations); } catch (ParseProblemException e) { - throw new BugInCF("Failed to parse code after annotation insertion:\n" + withAnnotations, e); + throw new BugInCF("Failed to parse code after annotation insertion: " + withAnnotations, e); } AnnotationEqualityVisitor visitor = new AnnotationEqualityVisitor(); diff --git a/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceImplementation.java b/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceImplementation.java index cb219896892..e19422d3bff 100644 --- a/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceImplementation.java +++ b/framework/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceImplementation.java @@ -327,7 +327,7 @@ private void updateInferredExecutableParameterTypes( if (showWpiFailedInferences) { printFailedInferenceDebugMessage( "Annotations cannot be placed on varargs parameters in -Ainfer=jaifs mode, because" - + " the JAIF format does not correctly support it.\n" + + " the JAIF format does not correctly support it. " + "The signature of the method whose varargs parameter was not annotated is: " + JVMNames.getJVMMethodSignature(methodElt)); } @@ -363,7 +363,7 @@ private void updateInferredExecutableParameterTypes( printFailedInferenceDebugMessage( "Javac cannot create an array type " + "from a wildcard, so WPI did not attempt to infer a type for an array " - + "parameter.\n" + + "parameter. " + "The signature of the method whose parameter had inference skipped is: " + JVMNames.getJVMMethodSignature(methodElt)); } @@ -594,7 +594,7 @@ public void updateFromFormalParameterAssignment( printFailedInferenceDebugMessage( "Could not update from formal parameter " + "assignment, because an ArrayCreationNode with a null tree is created when " - + "the parameter is a variable-length list.\nParameter: " + + "the parameter is a variable-length list. Parameter: " + paramElt); } return; @@ -613,7 +613,7 @@ public void updateFromFormalParameterAssignment( printFailedInferenceDebugMessage( "Could not update from formal " + "parameter assignment inside a lambda expression, because lambda parameters " - + "cannot be annotated.\nParameter: " + + "cannot be annotated. Parameter: " + paramElt); } return; @@ -1101,12 +1101,12 @@ public void updateAtmWithLub(AnnotatedTypeMirror sourceCodeATM, AnnotatedTypeMir } else { if (showWpiFailedInferences) { printFailedInferenceDebugMessage( - "attempted to update the component type of an array type, but found an unexpected" - + " difference in type structure.\n" - + "LHS kind: " - + sourceCodeComponent.getKind() - + "\nRHS kind: " - + ajavaComponent.getKind()); + String.join( + System.lineSeparator(), + "attempted to update the component type of an array type, but found an" + + " unexpected difference in type structure.", + "LHS kind: " + sourceCodeComponent.getKind(), + "RHS kind: " + ajavaComponent.getKind())); break; } } diff --git a/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java b/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java index a87d3694192..23622dd1ab4 100644 --- a/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java +++ b/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java @@ -1316,9 +1316,9 @@ protected void printOrStoreMessage( */ private void printStackTrace(StackTraceElement[] trace) { if (hasOption("dumpOnErrors")) { - StringBuilder msg = new StringBuilder(); + StringJoiner msg = new StringJoiner(System.lineSeparator()); for (StackTraceElement elem : trace) { - msg.append("\tat " + elem + "\n"); + msg.add("\tat " + elem); } message(Diagnostic.Kind.NOTE, msg.toString()); } diff --git a/framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/InferenceFactory.java b/framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/InferenceFactory.java index 982a019726e..f21b0c89511 100644 --- a/framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/InferenceFactory.java +++ b/framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/InferenceFactory.java @@ -183,7 +183,7 @@ public InferenceFactory(Java8InferenceContext context) { return new ProperType(res, TreeUtils.typeOf(var), this.context); } else { throw new BugInCF( - "Unexpected assignment context.\nKind: %s\nTree: %s", context.getKind(), context); + "Unexpected assignment context.%nKind: %s%nTree: %s", context.getKind(), context); } } }