Repository navigation
BUILD: Treat every javac and javadoc warning as an error - #240
Draft
jwrosewell wants to merge 2 commits into
Draft
jwrosewell wants to merge 2 commits into
jwrosewell wants to merge 2 commits into
Conversation
Every package tree and both examples trees compile with -Xlint:all and -Werror. The options and try lints were off in the package trees, Location had -Werror commented out, and the examples trees had no lint. The packages keep Java 8, with --release 8 on JDK 9 and later. javac 21 warns that Java 8 is obsolete and javac 17 does not, so CI compiles with JDK 17 and still runs the tests on the JDK each entry names, 8, 11, 17 or 21. Most try lint warnings came from close() throws Exception on Pipeline, FlowData and FlowElement. close() on those interfaces, FlowElementBase, CloseableIterable and the on-premise engines' iterables now declares no checked exception. A close failure is thrown as the new unchecked CloseException in fiftyone.pipeline.core.exceptions, an interrupt is kept, and a Pipeline closes every service even when one throws IOException. javadoc runs every doclint check and fails the build on any warning, and every public and protected member of the hand-written classes is documented. The SWIG classes, the generated property accessors' missing comments, and the owid-java package are left out, each with its reason in the module's pom. The Doxygen @example and @include commands become \example and \include, and code blocks javadoc read as HTML become <pre>{@code ...}</pre>. 86 classes declare the constructor they had by default, with the same access.
The examples build by default against the 4.5.130 packages on Maven Central, where close() still declares Exception. javac's try lint then warned at every try-with-resources of a Pipeline, a FlowData or a CloseableIterable, and -Werror stopped the build. In 66 places in both examples trees each one is now a local variable closed in a finally block, and the PMD resource rule accepts that form. The examples READMEs say to build them with JDK 17, as javac 21 refuses the Java 8 source level. The IP Intelligence engine closes its native weighted value lists through a new useAndClose helper, as try-with-resources would, and no longer wraps their exceptions in RuntimeException. The pool test closes its first FlowData in a finally block, BinaryWriter's javadoc says which stream it writes to, and javadoc now builds on JDK 11.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
javac and javadoc warnings did not fail every build. The package trees turned off the
optionsandtrylints, Location had-Werrorcommented out, and the examples trees had no lint. javadoc ran with<doclint>none</doclint>and<quiet>true</quiet>, so its warnings were neither shown nor fatal. And javac 21 warns that Java 8 is obsolete, so the JDK 21 entries could not build with-Werror.What changes
-Xlint:alland-Werrorinpipeline/pom.xml,device-detection/pom.xml,ip-intelligence/pom.xml,location/pom.xmland bothexamples/*/pom.xml. Arelease-8profile compiles against the Java 8 API with--release 8on JDK 9 and later.ci/packages.ps1, tested in the newci/java-home.Tests.ps1. The Cloud 51Did and fresh clone workflows compile with JDK 17 too, and the README and contributor guide say to build from source with JDK 17.close()declares no checked exception onPipeline,FlowData,FlowElement,FlowElementBase,CloseableIterable,CloseableIterableDefaultand the iterables of both on-premise engines. A close failure is thrown as the new uncheckedCloseExceptioninfiftyone.pipeline.core.exceptions, anInterruptedExceptionsets the interrupt status again, and a Pipeline closes every service even when one throwsIOException.<doclint>all</doclint>and<failOnWarnings>true</failOnWarnings>in the four parent poms, and every public and protected member of the hand-written classes is documented. Three things are left out, each with its reason in the module's pom: the SWIG generated classes of the two on-premise engines, the missing comment check indevice-detection.sharedandip-intelligence.shared(whose property accessors are generated), and the owid-java package inpipeline.did.@exampleand@includebecome\exampleand\include, and code blocks javadoc read as HTML become<pre>{@code ...}</pre>, checked with Doxygen 1.17.0 and javadoc 17 and 21.tryandserialwarnings are fixed where they were.-endorseddirsleaves the Location servlet example, as javac refuses it with--release.Before you upgrade
close()methods above and declaresthrows Exceptionno longer compiles, and has to handle the exception itself. Callers that caughtExceptionfromclose()now get the uncheckedCloseException.Second commit
useAndClose, as try-with-resources would, and no longer wraps their exceptions inRuntimeException.BinaryWriter's javadoc says it writes to the byte array stream it is given, with a test, and javadoc builds on JDK 11.At the second commit, on Linux: both examples trees, which failed against the published packages with the
trywarnings, build with no warning on JDK 17. The whole repository with-Pdev(66 modules, both examples trees, 39 javadoc jars and PMD) builds with no warning on JDK 17 and JDK 11. Thepipeline.commonandpipeline.coreunit tests pass (228), and so do the 4 newuseAndClosetests. Not run: JDK 8 and 21 tests, the native, cloud and data file tests, and the workflows on GitHub.Tests
On Linux x64 with Maven 3.9.16, the native libraries built with gcc and CMake, the free Lite data files, and no keys:
mvn clean install -DskipTests -Pdevon JDK 17 builds everything, examples included, with no javac or javadoc warning.ValueCloudTestsin IP Intelligence cloud, which needs a resource key.Before this leaves draft
Not ready to merge until these are done.
@returnon the generated accessors, so theall,-missingsettings can go. owid-java fixes its javadoc, sopipeline.didcan include that package again.pipeline/pipeline.aggregate, which has no sources.close()still declaresException. The documentation teaches try-with-resources, and with a finally block an exception fromclose()replaces one from the body, so a decision is needed before this merges: keep these finally blocks, or keep try-with-resources and build the examples against this tree's packages until a release with the newclose()is published, then move them back.