test/java/util/logging/LoggingMXBeanTest2.java
Print this page
rev 6099 : 8003380: Compiler warnings in logging test code
Summary: Use generics, suppress warnings where appropriate, remove unused imports, etc.
Reviewed-by: lancea, chegar
@@ -35,11 +35,10 @@
import java.util.List;
import java.util.ListIterator;
public class LoggingMXBeanTest2
{
-
static LoggingMXBean mbean = LogManager.getLoggingMXBean();
static String LOGGER_NAME_1 = "com.sun.management.Logger";
static String LOGGER_NAME_2 = "com.sun.management.Logger.Logger2";
static String UNKNOWN_LOGGER_NAME = "com.sun.management.Unknown";
static Logger logger1;
@@ -55,18 +54,18 @@
/*
* Check for the existence of our new Loggers
*/
System.out.println("Test Logger Name retrieval (getLoggerNames)");
boolean log1 = false, log2 = false;
- List loggers = mbean.getLoggerNames();
+ List<String> loggers = mbean.getLoggerNames();
if (loggers == null || loggers.size() < 2) {
throw new RuntimeException(
"Could not Detect the presense of the new Loggers");
}
- for (ListIterator iter = loggers.listIterator(); iter.hasNext(); ) {
- String logger = (String) iter.next();
+ for (ListIterator<String> iter = loggers.listIterator(); iter.hasNext(); ) {
+ String logger = iter.next();
if (logger.equals(LOGGER_NAME_1)) {
log1 = true;
System.out.println(" : Found new Logger : " + logger);
}
if (logger.equals(LOGGER_NAME_2)) {
@@ -185,8 +184,8 @@
" but got " + p3);
}
}
public static void main(String[] argv) throws Exception {
- LoggingMXBeanTest2 p = new LoggingMXBeanTest2();
+ new LoggingMXBeanTest2();
}
}