8049820: Fix raw and unchecked lint warnings in sun.management
authordarcy
Wed, 09 Jul 2014 21:26:11 -0700
changeset 25405 aa7f539c3569
parent 25404 c922a1b67208
child 25406 4814eec6a323
8049820: Fix raw and unchecked lint warnings in sun.management Reviewed-by: mchung
jdk/src/share/classes/sun/management/DiagnosticCommandImpl.java
jdk/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java
jdk/src/share/classes/sun/management/GcInfoBuilder.java
jdk/src/share/classes/sun/management/GcInfoCompositeData.java
jdk/src/share/classes/sun/management/MappedMXBeanType.java
--- a/jdk/src/share/classes/sun/management/DiagnosticCommandImpl.java	Thu Jul 10 03:07:48 2014 +0000
+++ b/jdk/src/share/classes/sun/management/DiagnosticCommandImpl.java	Wed Jul 09 21:26:11 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -84,10 +84,10 @@
             Exception cause = null;
             if (info.getPermissionClass() != null) {
                 try {
-                    Class c = Class.forName(info.getPermissionClass());
+                    Class<?> c = Class.forName(info.getPermissionClass());
                     if (info.getPermissionAction() == null) {
                         try {
-                            Constructor constructor = c.getConstructor(String.class);
+                            Constructor<?> constructor = c.getConstructor(String.class);
                             permission = (Permission) constructor.newInstance(info.getPermissionName());
 
                         } catch (InstantiationException | IllegalAccessException
@@ -98,7 +98,7 @@
                     }
                     if (permission == null) {
                         try {
-                            Constructor constructor = c.getConstructor(String.class, String.class);
+                            Constructor<?> constructor = c.getConstructor(String.class, String.class);
                             permission = (Permission) constructor.newInstance(
                                     info.getPermissionName(),
                                     info.getPermissionAction());
@@ -158,7 +158,7 @@
         SortedSet<MBeanOperationInfo> operations = new TreeSet<>(new OperationInfoComparator());
         Map<String, Wrapper> wrappersmap;
         if (!isSupported) {
-            wrappersmap = (Map<String, Wrapper>) Collections.EMPTY_MAP;
+            wrappersmap = Collections.emptyMap();
         } else {
             try {
                 String[] command = getDiagnosticCommands();
@@ -189,7 +189,7 @@
                     }
                 }
             } catch (IllegalArgumentException | UnsupportedOperationException e) {
-                wrappersmap = (Map<String, Wrapper>) Collections.EMPTY_MAP;
+                wrappersmap = Collections.emptyMap();
             }
         }
         wrappers =  Collections.unmodifiableMap(wrappersmap);
--- a/jdk/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java	Thu Jul 10 03:07:48 2014 +0000
+++ b/jdk/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java	Wed Jul 09 21:26:11 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -65,7 +65,7 @@
         final GcInfoBuilder builder = AccessController.doPrivileged (new PrivilegedAction<GcInfoBuilder>() {
                 public GcInfoBuilder run() {
                     try {
-                        Class cl = Class.forName("com.sun.management.GcInfo");
+                        Class<?> cl = Class.forName("com.sun.management.GcInfo");
                         Field f = cl.getDeclaredField("builder");
                         f.setAccessible(true);
                         return (GcInfoBuilder)f.get(gcNotifInfo.getGcInfo());
--- a/jdk/src/share/classes/sun/management/GcInfoBuilder.java	Thu Jul 10 03:07:48 2014 +0000
+++ b/jdk/src/share/classes/sun/management/GcInfoBuilder.java	Wed Jul 09 21:26:11 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, 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
@@ -98,7 +98,7 @@
 
         // First, fill with the attributes in the GcInfo
         String[] gcInfoItemNames = GcInfoCompositeData.getBaseGcInfoItemNames();
-        OpenType[] gcInfoItemTypes = GcInfoCompositeData.getBaseGcInfoItemTypes();
+        OpenType<?>[] gcInfoItemTypes = GcInfoCompositeData.getBaseGcInfoItemTypes();
         int numGcInfoItems = gcInfoItemNames.length;
 
         int itemCount = numGcInfoItems + gcExtItemCount;
--- a/jdk/src/share/classes/sun/management/GcInfoCompositeData.java	Thu Jul 10 03:07:48 2014 +0000
+++ b/jdk/src/share/classes/sun/management/GcInfoCompositeData.java	Wed Jul 09 21:26:11 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2014, 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
@@ -72,7 +72,7 @@
         final GcInfoBuilder builder = AccessController.doPrivileged (new PrivilegedAction<GcInfoBuilder>() {
                         public GcInfoBuilder run() {
                             try {
-                                Class cl = Class.forName("com.sun.management.GcInfo");
+                                Class<?> cl = Class.forName("com.sun.management.GcInfo");
                                 Field f = cl.getDeclaredField("builder");
                                 f.setAccessible(true);
                                 return (GcInfoBuilder)f.get(info);
@@ -84,7 +84,7 @@
         final Object[] extAttr = AccessController.doPrivileged (new PrivilegedAction<Object[]>() {
                         public Object[] run() {
                             try {
-                                Class cl = Class.forName("com.sun.management.GcInfo");
+                                Class<?> cl = Class.forName("com.sun.management.GcInfo");
                                 Field f = cl.getDeclaredField("extAttributes");
                                 f.setAccessible(true);
                                 return (Object[])f.get(info);
@@ -182,8 +182,8 @@
         return baseGcInfoItemNames;
     }
 
-    private static OpenType[] baseGcInfoItemTypes = null;
-    static synchronized OpenType[] getBaseGcInfoItemTypes() {
+    private static OpenType<?>[] baseGcInfoItemTypes = null;
+    static synchronized OpenType<?>[] getBaseGcInfoItemTypes() {
         if (baseGcInfoItemTypes == null) {
             OpenType<?> memoryUsageOpenType = memoryUsageMapType.getOpenType();
             baseGcInfoItemTypes = new OpenType<?>[] {
--- a/jdk/src/share/classes/sun/management/MappedMXBeanType.java	Thu Jul 10 03:07:48 2014 +0000
+++ b/jdk/src/share/classes/sun/management/MappedMXBeanType.java	Wed Jul 09 21:26:11 2014 -0700
@@ -227,6 +227,7 @@
     //   Enum <-> enum's name
     //
     static class EnumMXBeanType extends MappedMXBeanType {
+        @SuppressWarnings("rawtypes")
         final Class enumClass;
         EnumMXBeanType(Class<?> c) {
             this.enumClass = c;
@@ -754,7 +755,7 @@
         }
     }
 
-    private static class InProgress extends OpenType {
+    private static class InProgress<T> extends OpenType<T> {
         private static final String description =
                   "Marker to detect recursive type use -- internal use only!";
 
@@ -783,7 +784,7 @@
     static {
         OpenType<?> t;
         try {
-            t = new InProgress();
+            t = new InProgress<>();
         } catch (OpenDataException e) {
             // Should not reach here
             throw new AssertionError(e);
@@ -791,7 +792,7 @@
         inProgress = t;
     }
 
-    private static final OpenType[] simpleTypes = {
+    private static final OpenType<?>[] simpleTypes = {
         BIGDECIMAL, BIGINTEGER, BOOLEAN, BYTE, CHARACTER, DATE,
         DOUBLE, FLOAT, INTEGER, LONG, OBJECTNAME, SHORT, STRING,
         VOID,