< prev index next >

src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()


 248     private static final String RMI_PORT =
 249             "com.sun.management.jmxremote.rmi.port";
 250     private static final String ENABLE_THREAD_CONTENTION_MONITORING =
 251             "com.sun.management.enableThreadContentionMonitoring";
 252     private static final String LOCAL_CONNECTOR_ADDRESS_PROP =
 253             "com.sun.management.jmxremote.localConnectorAddress";
 254 
 255     private static final String JDP_DEFAULT_ADDRESS = "224.0.23.178";
 256     private static final int JDP_DEFAULT_PORT = 7095;
 257 
 258     // The only active agent allowed
 259     private static JMXConnectorServer jmxServer = null;
 260     // The properties used to configure the server
 261     private static Properties configProps = null;
 262 
 263     // Parse string com.sun.management.prop=xxx,com.sun.management.prop=yyyy
 264     // and return property set if args is null or empty
 265     // return empty property set
 266     private static Properties parseString(String args) {
 267         Properties argProps = new Properties();
 268         if (args != null && !args.trim().equals("")) {
 269             for (String option : args.split(",")) {
 270                 String s[] = option.split("=", 2);
 271                 String name = s[0].trim();
 272                 String value = (s.length > 1) ? s[1].trim() : "";
 273 
 274                 if (!name.startsWith("com.sun.management.")) {
 275                     error(INVALID_OPTION, name);
 276                 }
 277 
 278                 argProps.setProperty(name, value);
 279             }
 280         }
 281 
 282         return argProps;
 283     }
 284 
 285     // invoked by -javaagent or -Dcom.sun.management.agent.class
 286     public static void premain(String args) throws Exception {
 287         agentmain(args);
 288     }




 248     private static final String RMI_PORT =
 249             "com.sun.management.jmxremote.rmi.port";
 250     private static final String ENABLE_THREAD_CONTENTION_MONITORING =
 251             "com.sun.management.enableThreadContentionMonitoring";
 252     private static final String LOCAL_CONNECTOR_ADDRESS_PROP =
 253             "com.sun.management.jmxremote.localConnectorAddress";
 254 
 255     private static final String JDP_DEFAULT_ADDRESS = "224.0.23.178";
 256     private static final int JDP_DEFAULT_PORT = 7095;
 257 
 258     // The only active agent allowed
 259     private static JMXConnectorServer jmxServer = null;
 260     // The properties used to configure the server
 261     private static Properties configProps = null;
 262 
 263     // Parse string com.sun.management.prop=xxx,com.sun.management.prop=yyyy
 264     // and return property set if args is null or empty
 265     // return empty property set
 266     private static Properties parseString(String args) {
 267         Properties argProps = new Properties();
 268         if (args != null && !args.trim().isEmpty()) {
 269             for (String option : args.split(",")) {
 270                 String s[] = option.split("=", 2);
 271                 String name = s[0].trim();
 272                 String value = (s.length > 1) ? s[1].trim() : "";
 273 
 274                 if (!name.startsWith("com.sun.management.")) {
 275                     error(INVALID_OPTION, name);
 276                 }
 277 
 278                 argProps.setProperty(name, value);
 279             }
 280         }
 281 
 282         return argProps;
 283     }
 284 
 285     // invoked by -javaagent or -Dcom.sun.management.agent.class
 286     public static void premain(String args) throws Exception {
 287         agentmain(args);
 288     }


< prev index next >