You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/11/14 19:53:51 UTC

[tomcat] 01/02: Fix IDE warnings. Get build working with Java 8 through 14

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 49de92f384a05fc9b58857ce311e0e99705bf6e6
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Nov 14 19:26:00 2019 +0000

    Fix IDE warnings. Get build working with Java 8 through 14
    
    "-XDignore.symbol.file" is a hack but it is the only solution I found
    that worked cleanly with all Java versions.
---
 build.xml                                                    |  7 +------
 .../apache/catalina/mbeans/JmxRemoteLifecycleListener.java   | 12 +++++++++++-
 res/findbugs/filter-false-positives.xml                      |  6 ++++++
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/build.xml b/build.xml
index f548f23..2ec230b 100644
--- a/build.xml
+++ b/build.xml
@@ -87,7 +87,6 @@
   <!-- Servlet 3.1 spec requires Java 7+ -->
   <property name="compile.source" value="7"/>
   <property name="compile.target" value="7"/>
-  <property name="compile.release" value="7"/>
   <property name="min.java.version" value="7"/>
 
   <!-- Locations to create the JAR artifacts -->
@@ -638,7 +637,6 @@
            deprecation="${compile.deprecation}"
            source="${compile.source}"
            target="${compile.target}"
-           release="${compile.release}"
            encoding="ISO-8859-1"
            includeAntRuntime="true" >
       <!-- Uncomment this to show unchecked warnings:
@@ -693,12 +691,12 @@
            deprecation="${compile.deprecation}"
            source="${compile.source}"
            target="${compile.target}"
-           release="${compile.release}"
            encoding="ISO-8859-1"
            includeAntRuntime="true" >
       <!-- Uncomment this to show unchecked warnings:
       <compilerarg value="-Xlint:unchecked"/>
       -->
+      <compilerarg value="-XDignore.symbol.file"/>
       <classpath refid="compile.classpath" />
       <exclude name="org/apache/naming/factory/webservices/**" />
     </javac>
@@ -1162,7 +1160,6 @@
              debug="${compile.debug}" deprecation="${compile.deprecation}"
              source="${compile.source}"
              target="${compile.target}"
-             release="${compile.release}"
              classpath="${tomcat.classes}"
              encoding="ISO-8859-1"
              includeantruntime="false">
@@ -1174,7 +1171,6 @@
              debug="${compile.debug}" deprecation="${compile.deprecation}"
              source="${compile.source}"
              target="${compile.target}"
-             release="${compile.release}"
              classpath="${tomcat.classes}"
              encoding="ISO-8859-1"
              includeantruntime="false">
@@ -1407,7 +1403,6 @@
            deprecation="${compile.deprecation}"
            source="${compile.source}"
            target="${compile.target}"
-           release="${compile.release}"
            encoding="ISO-8859-1"
            includeantruntime="true">
       <classpath refid="tomcat.test.classpath" />
diff --git a/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java b/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
index a4095aa..9bae7fd 100644
--- a/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
+++ b/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
@@ -324,7 +324,13 @@ public class JmxRemoteLifecycleListener implements LifecycleListener {
             Remote jmxServer = server.toStub();
             // Create the RMI registry
             try {
-                new JmxRegistry(theRmiRegistryPort, registryCsf, registrySsf, "jmxrmi", jmxServer);
+                /*
+                 * JmxRegistry is registered as a side-effect of creation.
+                 * This object is here so we can tell the IDE it is OK for it
+                 * not to be used.
+                 */
+                @SuppressWarnings("unused")
+                JmxRegistry unused = new JmxRegistry(theRmiRegistryPort, registryCsf, registrySsf, "jmxrmi", jmxServer);
             } catch (RemoteException e) {
                 log.error(sm.getString(
                         "jmxRemoteLifecycleListener.createRegistryFailed",
@@ -492,6 +498,10 @@ public class JmxRemoteLifecycleListener implements LifecycleListener {
     }
 
 
+    /*
+     * Better to use the internal API than re-invent the wheel.
+     */
+    @SuppressWarnings("restriction")
     private static class JmxRegistry extends sun.rmi.registry.RegistryImpl {
         private static final long serialVersionUID = -3772054804656428217L;
         private final String jmxName;
diff --git a/res/findbugs/filter-false-positives.xml b/res/findbugs/filter-false-positives.xml
index a4596d0..dff3613 100644
--- a/res/findbugs/filter-false-positives.xml
+++ b/res/findbugs/filter-false-positives.xml
@@ -332,6 +332,12 @@
     <Bug pattern="VO_VOLATILE_REFERENCE_TO_ARRAY" />
   </Match>
   <Match>
+    <!-- Object is used via side-effect of creation. -->
+    <Class name="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" />
+    <Method name="createServer" />
+    <Bug pattern="DLS_DEAD_LOCAL_STORE" />
+  </Match>
+  <Match>
     <!-- SQL construction is safe since it is from trusted config -->
     <Or>
       <Class name="org.apache.catalina.realm.DataSourceRealm" />


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org