8071367: JMX: Remove SNMP support
authorasapre
Fri, 06 Apr 2018 17:27:24 +0530
changeset 49542 da62fa14a3fe
parent 49541 4f6887eade94
child 49543 2d5d75263e77
child 49680 2e681d678ec8
child 49717 cd4da74e310b
8071367: JMX: Remove SNMP support Summary: Drop jdk.snmp module. Reviewed-by: alanb, mchung, dfuchs Contributed-by: amit.sapre@oracle.com
make/jdk/netbeans/jmx/build.properties
src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java
src/jdk.management.agent/share/conf/management.properties
test/jdk/sun/management/jmxremote/bootstrap/rmiregistry.properties
test/jdk/sun/management/jmxremote/bootstrap/rmiregistryssl.properties
test/jdk/sun/management/windows/README
test/langtools/jdk/javadoc/doclet/testModules/jdk/element-list
--- a/make/jdk/netbeans/jmx/build.properties	Thu Apr 05 14:39:04 2018 -0700
+++ b/make/jdk/netbeans/jmx/build.properties	Fri Apr 06 17:27:24 2018 +0530
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -34,8 +34,7 @@
     javax/management/ \
     org/omg/stub/javax/management/
 
-excludes=\
-    com/sun/jmx/snmp/
+excludes=
 
 jtreg.tests=\
     com/sun/jmx/ \
--- a/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java	Thu Apr 05 14:39:04 2018 -0700
+++ b/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java	Fri Apr 06 17:27:24 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,9 +58,11 @@
 import sun.management.jmxremote.ConnectorBootstrap;
 
 /**
- * This Agent is started by the VM when -Dcom.sun.management.snmp or
- * -Dcom.sun.management.jmxremote is set. This class will be loaded by the
- * system class loader. Also jmx framework could be started by jcmd
+ * This class provides the methods to start the management agent.
+ * 1. {@link #startAgent} method is invoked by the VM if {@code -Dcom.sun.management.*} is set
+ * 2. {@link #startLocalManagementAgent} or {@link #startRemoteManagementAgent}
+ *    is invoked to start the management agent after the VM starts
+ *    via jcmd ManagementAgent.start and start_local command.
  */
 public class Agent {
     /**
@@ -239,8 +241,6 @@
     private static ResourceBundle messageRB;
     private static final String CONFIG_FILE =
             "com.sun.management.config.file";
-    private static final String SNMP_PORT =
-            "com.sun.management.snmp.port";
     private static final String JMXREMOTE =
             "com.sun.management.jmxremote";
     private static final String JMXREMOTE_PORT =
@@ -251,8 +251,6 @@
             "com.sun.management.enableThreadContentionMonitoring";
     private static final String LOCAL_CONNECTOR_ADDRESS_PROP =
             "com.sun.management.jmxremote.localConnectorAddress";
-    private static final String SNMP_AGENT_NAME =
-            "SnmpAgent";
 
     private static final String JDP_DEFAULT_ADDRESS = "224.0.23.178";
     private static final int JDP_DEFAULT_PORT = 7095;
@@ -307,8 +305,11 @@
         startAgent(config_props);
     }
 
-    // jcmd ManagementAgent.start_local entry point
-    // Also called due to command-line via startAgent()
+    /*
+     * Starts the local management agent.
+     * This method is invoked by either startAgent method or
+     * by the VM directly via jcmd ManagementAgent.start_local command.
+     */
     private static synchronized void startLocalManagementAgent() {
         Properties agentProps = VMSupport.getAgentProperties();
 
@@ -330,10 +331,10 @@
         }
     }
 
-    // jcmd ManagementAgent.start entry point
-    // This method starts the remote JMX agent and starts neither
-    // the local JMX agent nor the SNMP agent
-    // @see #startLocalManagementAgent and also @see #startAgent.
+    /*
+     * This method is invoked by the VM to start the remote management agent
+     * via jcmd ManagementAgent.start command.
+     */
     private static synchronized void startRemoteManagementAgent(String args) throws Exception {
         if (jmxServer != null) {
             throw new RuntimeException(getText(INVALID_STATE, "Agent already started"));
@@ -418,7 +419,6 @@
     }
 
     private static void startAgent(Properties props) throws Exception {
-        String snmpPort = props.getProperty(SNMP_PORT);
         String jmxremote = props.getProperty(JMXREMOTE);
         String jmxremotePort = props.getProperty(JMXREMOTE_PORT);
 
@@ -431,9 +431,6 @@
         }
 
         try {
-            if (snmpPort != null) {
-                loadSnmpAgent(props);
-            }
 
             /*
              * If the jmxremote.port property is set then we start the
@@ -533,12 +530,10 @@
     public static synchronized Properties getManagementProperties() {
         if (mgmtProps == null) {
             String configFile = System.getProperty(CONFIG_FILE);
-            String snmpPort = System.getProperty(SNMP_PORT);
             String jmxremote = System.getProperty(JMXREMOTE);
             String jmxremotePort = System.getProperty(JMXREMOTE_PORT);
 
-            if (configFile == null && snmpPort == null
-                    && jmxremote == null && jmxremotePort == null) {
+            if (configFile == null && jmxremote == null && jmxremotePort == null) {
                 // return if out-of-the-management option is not specified
                 return null;
             }
@@ -547,27 +542,6 @@
         return mgmtProps;
     }
 
-    private static void loadSnmpAgent(Properties props) {
-        /*
-         * Load the jdk.snmp service
-         */
-        AgentProvider provider = AccessController.doPrivileged(
-            (PrivilegedAction<AgentProvider>) () -> {
-                for (AgentProvider aProvider : ServiceLoader.loadInstalled(AgentProvider.class)) {
-                    if (aProvider.getName().equals(SNMP_AGENT_NAME))
-                        return aProvider;
-                }
-                return null;
-            },  null
-        );
-
-        if (provider != null) {
-            provider.startAgent(props);
-         } else { // snmp runtime doesn't exist - initialization fails
-            throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT);
-        }
-    }
-
     // read config file and initialize the properties
     private static void readConfiguration(String fname, Properties p) {
         if (fname == null) {
@@ -609,6 +583,10 @@
         }
     }
 
+    /**
+     * This method is invoked by the VM to start the management agent
+     * when -Dcom.sun.management.* is set during startup.
+     */
     public static void startAgent() throws Exception {
         String prop = System.getProperty("com.sun.management.agent.class");
 
--- a/src/jdk.management.agent/share/conf/management.properties	Thu Apr 05 14:39:04 2018 -0700
+++ b/src/jdk.management.agent/share/conf/management.properties	Fri Apr 06 17:27:24 2018 +0530
@@ -5,7 +5,6 @@
 # The Management Configuration file (in java.util.Properties format)
 # will be read if one of the following system properties is set:
 #    -Dcom.sun.management.jmxremote.port=<port-number>
-# or -Dcom.sun.management.snmp.port=<port-number>
 # or -Dcom.sun.management.config.file=<this-file>
 #
 # The default Management Configuration file is:
@@ -26,8 +25,6 @@
 # For setting the JMX RMI agent port use the following line
 # com.sun.management.jmxremote.port=<port-number>
 #
-# For setting the SNMP agent port use the following line
-# com.sun.management.snmp.port=<port-number>
 
 #####################################################################
 #                   Optional Instrumentation
@@ -50,82 +47,6 @@
 # com.sun.management.enableThreadContentionMonitoring
 
 #####################################################################
-#			SNMP Management Properties
-#####################################################################
-#
-# If the system property -Dcom.sun.management.snmp.port=<port-number>
-# is set then
-#	- The SNMP agent (with the Java virtual machine MIB) is started
-#	  that listens on the specified port for incoming SNMP requests.
-#	- the following properties for read for SNMP management.
-#
-# The configuration can be specified only at startup time.
-# Later changes to the above system property (e.g. via setProperty method), this
-# config file, or the ACL file has no effect to the running SNMP agent.
-#
-
-#
-# ##################### SNMP Trap Port #########################
-#
-# com.sun.management.snmp.trap=<trap-destination-port-number>
-#      Specifies the remote port number at which managers are expected
-#      to listen for trap. For each host defined in the ACL file,
-#      the SNMP agent will send traps at <host>:<trap-destination-port-number>
-#      Default for this property is 162.
-#
-
-# To set port for sending traps to a different port use the following line
-# com.sun.management.snmp.trap=<trap-destination-port-number>
-
-#
-# ################ SNMP listen interface #########################
-#
-# com.sun.management.snmp.interface=<InetAddress>
-#      Specifies the local interface on which the SNMP agent will bind.
-#      This is useful when running on machines which have several
-#      interfaces defined. It makes it possible to listen to a specific
-#      subnet accessible through that interface.
-#      Default for this property is "localhost".
-#
-#      The format of the value for that property is any string accepted
-#      by java.net.InetAddress.getByName(String).
-#
-
-# For restricting the port on which SNMP agent listens use the following line
-# com.sun.management.snmp.interface=<InetAddress>
-
-#
-# #################### SNMP ACL file #########################
-#
-# com.sun.management.snmp.acl=true|false
-#      Default for this property is true. (Case for true/false ignored)
-#      If this property is specified as false then the ACL file
-#      is not checked:  all manager hosts are allowed all access.
-#
-
-# For SNMP without checking ACL file uncomment the following line
-# com.sun.management.snmp.acl=false
-
-#
-# com.sun.management.snmp.acl.file=filepath
-#      Specifies location for ACL file
-#      This is optional - default location is
-#      $JRE/conf/management/snmp.acl
-#
-#      If the property "com.sun.management.snmp.acl" is set to false,
-#      then this property and the ACL file are ignored.
-#      Otherwise the ACL file must exist and be in the valid format.
-#      If the ACL file is empty or non existent then no access is allowed.
-#
-#      The SNMP agent will read the ACL file at startup time.
-#      Modification to the ACL file has no effect to any running SNMP
-#      agents which read that ACL file at startup.
-#
-
-# For a non-default acl file location use the following line
-# com.sun.management.snmp.acl.file=filepath
-
-#####################################################################
 #			RMI Management Properties
 #####################################################################
 #
--- a/test/jdk/sun/management/jmxremote/bootstrap/rmiregistry.properties	Thu Apr 05 14:39:04 2018 -0700
+++ b/test/jdk/sun/management/jmxremote/bootstrap/rmiregistry.properties	Fri Apr 06 17:27:24 2018 +0530
@@ -5,7 +5,6 @@
 # The Management Configuration file (in java.util.Properties format)
 # will be read if one of the following system properties is set:
 #    -Dcom.sun.management.jmxremote.port=<port-number>
-# or -Dcom.sun.management.snmp.port=<port-number>
 # or -Dcom.sun.management.config.file=<this-file>
 #
 # The default Management Configuration file is:
@@ -26,8 +25,6 @@
 # For setting the JMX RMI agent port use the following line
 com.sun.management.jmxremote.port=${getFreePort}
 #
-# For setting the SNMP agent port use the following line
-# com.sun.management.snmp.port=<port-number>
 
 #####################################################################
 #                   Optional Instrumentation
@@ -50,82 +47,6 @@
 # com.sun.management.enableThreadContentionMonitoring
 
 #####################################################################
-#			SNMP Management Properties
-#####################################################################
-#
-# If the system property -Dcom.sun.management.snmp.port=<port-number>
-# is set then
-#	- The SNMP agent (with the Java virtual machine MIB) is started
-#	  that listens on the specified port for incoming SNMP requests.
-#	- the following properties for read for SNMP management.
-#
-# The configuration can be specified only at startup time.
-# Later changes to the above system property (e.g. via setProperty method), this
-# config file, or the ACL file has no effect to the running SNMP agent.
-#
-
-#
-# ##################### SNMP Trap Port #########################
-#
-# com.sun.management.snmp.trap=<trap-destination-port-number>
-#      Specifies the remote port number at which managers are expected
-#      to listen for trap. For each host defined in the ACL file,
-#      the SNMP agent will send traps at <host>:<trap-destination-port-number>
-#      Default for this property is 162.
-#
-
-# To set port for sending traps to a different port use following line
-# com.sun.management.snmp.trap=<trap-destination-port-number>
-
-#
-# ################ SNMP listen interface #########################
-#
-# com.sun.management.snmp.interface=<InetAddress>
-#      Specifies the local interface on which the SNMP agent will bind.
-#      This is usefull when running on machines which have several
-#      interfaces defined. It makes it possible to listen to a specific
-#      subnet accessible through that interface.
-#      Default for this property is "localhost".
-#
-#      The format of the value for that property is any string accepted
-#      by java.net.InetAddress.getByName(String).
-#
-
-# For restricting the port on which SNMP agent listens use following line
-# com.sun.management.snmp.interface=<InetAddress>
-
-#
-# #################### SNMP ACL file #########################
-#
-# com.sun.management.snmp.acl=true|false
-#      Default for this property is true. (Case for true/false ignored)
-#      If this property is specified as false then the ACL file
-#      is not checked:  all manager hosts are allowed all access.
-#
-
-# For SNMP without checking ACL file uncomment the following line
-# com.sun.management.snmp.acl=false
-
-#
-# com.sun.management.snmp.acl.file=filepath
-#      Specifies location for ACL file
-#      This is optional - default location is
-#      $JRE/conf/management/snmp.acl
-#
-#      If the property "com.sun.management.snmp.acl" is set to false,
-#      then this property and the ACL file are ignored.
-#      Otherwise the ACL file must exist and be in the valid format.
-#      If the ACL file is empty or non existent then no access is allowed.
-#
-#      The SNMP agent will read the ACL file at startup time.
-#      Modification to the ACL file has no effect to any running SNMP
-#      agents which read that ACL file at startup.
-#
-
-# For a non-default acl file location use following line
-# com.sun.management.snmp.acl.file=filepath
-
-#####################################################################
 #			RMI Management Properties
 #####################################################################
 #
--- a/test/jdk/sun/management/jmxremote/bootstrap/rmiregistryssl.properties	Thu Apr 05 14:39:04 2018 -0700
+++ b/test/jdk/sun/management/jmxremote/bootstrap/rmiregistryssl.properties	Fri Apr 06 17:27:24 2018 +0530
@@ -5,7 +5,6 @@
 # The Management Configuration file (in java.util.Properties format)
 # will be read if one of the following system properties is set:
 #    -Dcom.sun.management.jmxremote.port=<port-number>
-# or -Dcom.sun.management.snmp.port=<port-number>
 # or -Dcom.sun.management.config.file=<this-file>
 #
 # The default Management Configuration file is:
@@ -26,8 +25,6 @@
 # For setting the JMX RMI agent port use the following line
 com.sun.management.jmxremote.port=${getFreePort}
 #
-# For setting the SNMP agent port use the following line
-# com.sun.management.snmp.port=<port-number>
 
 #####################################################################
 #                   Optional Instrumentation
@@ -50,82 +47,6 @@
 # com.sun.management.enableThreadContentionMonitoring
 
 #####################################################################
-#			SNMP Management Properties
-#####################################################################
-#
-# If the system property -Dcom.sun.management.snmp.port=<port-number>
-# is set then
-#	- The SNMP agent (with the Java virtual machine MIB) is started
-#	  that listens on the specified port for incoming SNMP requests.
-#	- the following properties for read for SNMP management.
-#
-# The configuration can be specified only at startup time.
-# Later changes to the above system property (e.g. via setProperty method), this
-# config file, or the ACL file has no effect to the running SNMP agent.
-#
-
-#
-# ##################### SNMP Trap Port #########################
-#
-# com.sun.management.snmp.trap=<trap-destination-port-number>
-#      Specifies the remote port number at which managers are expected
-#      to listen for trap. For each host defined in the ACL file,
-#      the SNMP agent will send traps at <host>:<trap-destination-port-number>
-#      Default for this property is 162.
-#
-
-# To set port for sending traps to a different port use following line
-# com.sun.management.snmp.trap=<trap-destination-port-number>
-
-#
-# ################ SNMP listen interface #########################
-#
-# com.sun.management.snmp.interface=<InetAddress>
-#      Specifies the local interface on which the SNMP agent will bind.
-#      This is usefull when running on machines which have several
-#      interfaces defined. It makes it possible to listen to a specific
-#      subnet accessible through that interface.
-#      Default for this property is "localhost".
-#
-#      The format of the value for that property is any string accepted
-#      by java.net.InetAddress.getByName(String).
-#
-
-# For restricting the port on which SNMP agent listens use following line
-# com.sun.management.snmp.interface=<InetAddress>
-
-#
-# #################### SNMP ACL file #########################
-#
-# com.sun.management.snmp.acl=true|false
-#      Default for this property is true. (Case for true/false ignored)
-#      If this property is specified as false then the ACL file
-#      is not checked:  all manager hosts are allowed all access.
-#
-
-# For SNMP without checking ACL file uncomment the following line
-# com.sun.management.snmp.acl=false
-
-#
-# com.sun.management.snmp.acl.file=filepath
-#      Specifies location for ACL file
-#      This is optional - default location is
-#      $JRE/conf/management/snmp.acl
-#
-#      If the property "com.sun.management.snmp.acl" is set to false,
-#      then this property and the ACL file are ignored.
-#      Otherwise the ACL file must exist and be in the valid format.
-#      If the ACL file is empty or non existent then no access is allowed.
-#
-#      The SNMP agent will read the ACL file at startup time.
-#      Modification to the ACL file has no effect to any running SNMP
-#      agents which read that ACL file at startup.
-#
-
-# For a non-default acl file location use following line
-# com.sun.management.snmp.acl.file=filepath
-
-#####################################################################
 #			RMI Management Properties
 #####################################################################
 #
--- a/test/jdk/sun/management/windows/README	Thu Apr 05 14:39:04 2018 -0700
+++ b/test/jdk/sun/management/windows/README	Fri Apr 06 17:27:24 2018 +0530
@@ -5,7 +5,6 @@
 The tool is used by regression tests in the following directories :-
 
 test/sun/management/jmxremote/bootstrap
-test/sun/management/snmp/bootstrap
 
 The tests in these directories create password or ACL files that need to
 be "secured" (meaning that only the owner should have access to the 
--- a/test/langtools/jdk/javadoc/doclet/testModules/jdk/element-list	Thu Apr 05 14:39:04 2018 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testModules/jdk/element-list	Fri Apr 06 17:27:24 2018 +0530
@@ -332,7 +332,6 @@
 com.sun.security.auth.module
 module:jdk.security.jgss
 com.sun.security.jgss
-module:jdk.snmp
 module:jdk.xml.dom
 org.w3c.dom.css
 org.w3c.dom.html