#12472 closed enhancement (fixed)
Java 8: Use error-prone in build
Reported by: | simon04 | Owned by: | Don-vip |
---|---|---|---|
Priority: | normal | Milestone: | 16.07 |
Component: | Core | Version: | |
Keywords: | build error prone ant java8 | Cc: | Don-vip, bastiK |
Description
Error-prone aims at identifying issues at compile time. Running it on the current code base reveals:
compile: [javac] Compiling 434 source files to /home/simon/src/josm.svngit/build [javac] Note: /home/simon/src/josm.svngit/src/oauth/signpost/AbstractOAuthProvider.java uses or overrides a deprecated API. [javac] Note: Recompile with -Xlint:deprecation for details. [javac] Note: Some input files use unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [javac] Compiling 60 source files to /home/simon/src/josm.svngit/build [javac] /home/simon/src/josm.svngit/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java:305: warning: [SynchronizeOnNonFinalField] Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects. [javac] synchronized (mapMarkerList) { [javac] ^ [javac] (see http://errorprone.info/bugpattern/SynchronizeOnNonFinalField) [javac] /home/simon/src/josm.svngit/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java:319: warning: [SynchronizeOnNonFinalField] Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects. [javac] synchronized (mapRectangleList) { [javac] ^ [javac] (see http://errorprone.info/bugpattern/SynchronizeOnNonFinalField) [javac] /home/simon/src/josm.svngit/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java:334: warning: [SynchronizeOnNonFinalField] Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects. [javac] synchronized (mapPolygonList) { [javac] ^ [javac] (see http://errorprone.info/bugpattern/SynchronizeOnNonFinalField) [javac] /home/simon/src/josm.svngit/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java:653: warning: [SynchronizeOnNonFinalField] Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects. [javac] synchronized (mapPolygonList) { [javac] ^ [javac] (see http://errorprone.info/bugpattern/SynchronizeOnNonFinalField) [javac] /home/simon/src/josm.svngit/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java:662: warning: [SynchronizeOnNonFinalField] Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects. [javac] synchronized (mapRectangleList) { [javac] ^ [javac] (see http://errorprone.info/bugpattern/SynchronizeOnNonFinalField) [javac] /home/simon/src/josm.svngit/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java:671: warning: [SynchronizeOnNonFinalField] Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects. [javac] synchronized (mapMarkerList) { [javac] ^ [javac] (see http://errorprone.info/bugpattern/SynchronizeOnNonFinalField) [javac] 6 warnings [javac] Compiling 1290 source files to /home/simon/src/josm.svngit/build [javac] /home/simon/src/josm.svngit/src/org/openstreetmap/josm/data/osm/Storage.java:414: warning: [NonAtomicVolatileUpdate] This update of a volatile variable is non-atomic [javac] modCount++; [javac] ^ [javac] (see http://errorprone.info/bugpattern/NonAtomicVolatileUpdate) [javac] /home/simon/src/josm.svngit/src/org/openstreetmap/josm/gui/SideButton.java:59: warning: [StringEquality] String comparison using reference equality instead of value equality [javac] if (evt.getPropertyName() == javax.swing.Action.SMALL_ICON) { [javac] ^ [javac] (see http://errorprone.info/bugpattern/StringEquality) [javac] Did you mean 'if (javax.swing.Action.SMALL_ICON.equals(evt.getPropertyName())) {'? [javac] /home/simon/src/josm.svngit/src/org/openstreetmap/josm/io/NmeaReader.java:54: warning: [NonOverridingEquals] equals method doesn't override Object.equals; enum instances can safely be compared by reference equality, so please delete this [javac] public boolean equals(String type) { [javac] ^ [javac] (see http://errorprone.info/bugpattern/NonOverridingEquals) [javac] Did you mean to remove this line? [javac] 3 warnings [copy] Copying 1 file to /home/simon/src/josm.svngit/build
To integrate it, the following modifications on build.xml
are required:
-
build.xml
diff --git a/build.xml b/build.xml index bd7e95c..019fd16 100644
a b Build-Date: ${build.tstamp} 225 225 <exclude name="org/apache/commons/logging/impl/ServletContextCleaner.java"/> 226 226 </javac> 227 227 <!-- JMapViewer --> 228 <javac sourcepath="" srcdir="${src.dir}" excludes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java,org/openstreetmap/josm/**,JOSM.java,gnu/**" 228 <javac compiler="com.google.errorprone.ErrorProneAntCompilerAdapter" 229 sourcepath="" srcdir="${src.dir}" excludes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java,org/openstreetmap/josm/**,JOSM.java,gnu/**" 229 230 destdir="build" target="1.7" source="1.7" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8"> 231 <compilerclasspath> 232 <pathelement location="./error_prone_ant-2.0.8.jar"/> 233 </compilerclasspath> 230 234 <compilerarg value="-Xlint:cast"/> 231 235 <compilerarg value="-Xlint:deprecation"/> 232 236 <compilerarg value="-Xlint:dep-ann"/> … … Build-Date: ${build.tstamp} 242 246 <compilerarg value="-XDignore.symbol.file"/> 243 247 </javac> 244 248 <!-- JOSM --> 245 <javac sourcepath="" srcdir="${src.dir}" excludes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java" 249 <javac compiler="com.google.errorprone.ErrorProneAntCompilerAdapter" 250 sourcepath="" srcdir="${src.dir}" excludes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java" 246 251 destdir="build" target="1.7" source="1.7" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8"> 252 <compilerclasspath> 253 <pathelement location="./error_prone_ant-2.0.8.jar"/> 254 </compilerclasspath> 247 255 <compilerarg value="-Xlint:cast"/> 248 256 <compilerarg value="-Xlint:deprecation"/> 249 257 <compilerarg value="-Xlint:dep-ann"/>
Shall we add this to our build process?
Attachments (0)
Change History (25)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Keywords: | error prone ant added |
---|---|
Milestone: | → 16.02 |
I'd say yes if you put jar file in tools
.
comment:3 by , 9 years ago
Keywords: | java8 added |
---|---|
Milestone: | 16.02 → 16.04 |
Nowhere documented, but it requires JDK 8.
follow-up: 5 comment:4 by , 9 years ago
I think these are also in Coverity. Do we need another test for the same?
comment:5 by , 9 years ago
Replying to stoecker:
I think these are also in Coverity. Do we need another test for the same?
No. It seems I mixed something up. These are not in Coverity.
comment:6 by , 9 years ago
Even if it were, it's always better to have an autonomous offline system. We have quotas with Coverity and sometimes the website can be slow, or even unavailable.
comment:7 by , 9 years ago
Milestone: | 16.04 → 16.05 |
---|
comment:8 by , 9 years ago
Milestone: | 16.05 → 16.06 |
---|
comment:9 by , 9 years ago
Milestone: | 16.06 → 16.07 |
---|
comment:10 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Summary: | Use error-prone in build → [PATCH] Java 8: Use error-prone in build |
comment:15 by , 9 years ago
Summary: | [PATCH] Java 8: Use error-prone in build → Java 8: Use error-prone in build |
---|
In 9703/josm: