diff --git a/src/share/classes/sun/instrument/InstrumentationImpl.java b/src/share/classes/sun/instrument/InstrumentationImpl.java index 359cdbdff3e621d5ea62ca46b4ba9d069b5c0dbb..9957e1c64d4b5963ade71900790a429514e639df 100644 --- a/src/share/classes/sun/instrument/InstrumentationImpl.java +++ b/src/share/classes/sun/instrument/InstrumentationImpl.java @@ -136,7 +136,7 @@ public class InstrumentationImpl implements Instrumentation { } public void - retransformClasses(Class[] classes) { + retransformClasses(Class... classes) { if (!isRetransformClassesSupported()) { throw new UnsupportedOperationException( "retransformClasses is not supported in this environment"); @@ -150,7 +150,7 @@ public class InstrumentationImpl implements Instrumentation { } public void - redefineClasses(ClassDefinition[] definitions) + redefineClasses(ClassDefinition... definitions) throws ClassNotFoundException { if (!isRedefineClassesSupported()) { throw new UnsupportedOperationException("redefineClasses is not supported in this environment"); @@ -321,7 +321,7 @@ public class InstrumentationImpl implements Instrumentation { try { m = javaAgentClass.getDeclaredMethod( methodname, - new Class[] { + new Class[] { String.class, java.lang.instrument.Instrumentation.class } @@ -336,7 +336,7 @@ public class InstrumentationImpl implements Instrumentation { // now try the declared 1-arg method try { m = javaAgentClass.getDeclaredMethod(methodname, - new Class[] { String.class }); + new Class[] { String.class }); } catch (NoSuchMethodException x) { // ignore this exception because we'll try // two arg inheritance next @@ -347,7 +347,7 @@ public class InstrumentationImpl implements Instrumentation { // now try the inherited 2-arg method try { m = javaAgentClass.getMethod( methodname, - new Class[] { + new Class[] { String.class, java.lang.instrument.Instrumentation.class } @@ -363,7 +363,7 @@ public class InstrumentationImpl implements Instrumentation { // finally try the inherited 1-arg method try { m = javaAgentClass.getMethod(methodname, - new Class[] { String.class }); + new Class[] { String.class }); } catch (NoSuchMethodException x) { // none of the methods exists so we throw the // first NoSuchMethodException as per 5.0 @@ -411,7 +411,7 @@ public class InstrumentationImpl implements Instrumentation { private byte[] transform( ClassLoader loader, String classname, - Class classBeingRedefined, + Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer, boolean isRetransformer) { diff --git a/src/share/classes/sun/instrument/TransformerManager.java b/src/share/classes/sun/instrument/TransformerManager.java index 2f8cfa1ae0f9fa7bb35cc0f6c432ebf6fcd23c9c..b0a020570efde66b4088c9bb83cb1cff29fd3fb1 100644 --- a/src/share/classes/sun/instrument/TransformerManager.java +++ b/src/share/classes/sun/instrument/TransformerManager.java @@ -169,7 +169,7 @@ public class TransformerManager public byte[] transform( ClassLoader loader, String classname, - Class classBeingRedefined, + Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) { boolean someoneTouchedTheBytecode = false; diff --git a/src/share/classes/sun/launcher/LauncherHelper.java b/src/share/classes/sun/launcher/LauncherHelper.java index 24eeaca2cc1efe6d952f3dec30b39978ff5b6e49..2f3710bce1020c943c1b304f160d2e5702d9744f 100644 --- a/src/share/classes/sun/launcher/LauncherHelper.java +++ b/src/share/classes/sun/launcher/LauncherHelper.java @@ -428,7 +428,7 @@ public enum LauncherHelper { if (t != null) { t.printStackTrace(); } else { - Thread.currentThread().dumpStack(); + Thread.dumpStack(); } } System.exit(1); diff --git a/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java b/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java index 154174407ba2fe7a89cf1e8daadc78ff7b019a41..eb7ae7ac332f1618dda428b89461709e57729299 100644 --- a/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java +++ b/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java @@ -169,17 +169,15 @@ public class PerfInstrumentation { Matcher matcher = pattern.matcher(""); List matches = new ArrayList(); - Iterator iter = map.entrySet().iterator(); - while (iter.hasNext()) { - Map.Entry me = (Map.Entry) iter.next(); - String name = (String) me.getKey(); + for (Map.Entry me: map.entrySet()) { + String name = me.getKey(); // apply pattern to counter name matcher.reset(name); // if the pattern matches, then add Counter to list if (matcher.lookingAt()) { - matches.add((Counter)me.getValue()); + matches.add(me.getValue()); } } return matches; diff --git a/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java b/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java index 3e480891772e819b3b48225ce3863b69575625ee..a3b318a8cecb5ef88b8196d59ef49f8c7e2e0047 100644 --- a/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java +++ b/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java @@ -233,16 +233,14 @@ public final class ConnectorBootstrap { "the access file [" + accessFile + "] as the " + "authenticated Subject is null"); } - final Set principals = subject.getPrincipals(); - for (Iterator i = principals.iterator(); i.hasNext();) { - final Principal p = (Principal) i.next(); + final Set principals = subject.getPrincipals(); + for (Principal p: principals) { if (properties.containsKey(p.getName())) { return; } } final Set principalsStr = new HashSet(); - for (Iterator i = principals.iterator(); i.hasNext();) { - final Principal p = (Principal) i.next(); + for (Principal p: principals) { principalsStr.add(p.getName()); } throw new SecurityException( @@ -653,7 +651,7 @@ public final class ConnectorBootstrap { } TrustManagerFactory tmf = TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm()); - tmf.init((KeyStore) ts); + tmf.init(ts); SSLContext ctx = SSLContext.getInstance("SSL"); ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); diff --git a/src/share/classes/sun/net/RegisteredDomain.java b/src/share/classes/sun/net/RegisteredDomain.java index 49c67c2b24b7964b4167eb1872d5b1807564dab2..7e75b321eb604aab69297bc7422f13c6b73628b0 100644 --- a/src/share/classes/sun/net/RegisteredDomain.java +++ b/src/share/classes/sun/net/RegisteredDomain.java @@ -118,8 +118,8 @@ private static Set usStateSet = new HashSet(Arrays.asList("ak", private static Set usSubStateSet = new HashSet(Arrays.asList("state", "lib", "k12", "cc", "tec", "gen", "cog", "mus", "dst")); -private static Map topMap = new HashMap(); -private static Map top3Map = new HashMap(); +private static Map> topMap = new HashMap<>(); +private static Map> top3Map = new HashMap<>(); static { /* @@ -764,7 +764,7 @@ static { */ String str = cname.substring(third + 1); if (third != -1) { - Set set = top3Map.get(s); + Set set = top3Map.get(s); if (set != null) { if (set.contains(str)) { return cname.substring(fourth + 1); @@ -801,7 +801,7 @@ static { /* * XX.MA.US. */ - Set topSet = topMap.get(s); + Set topSet = topMap.get(s); if (topSet != null) { if (topSet.contains(s2)) { return cname.substring(third + 1); diff --git a/src/share/classes/sun/net/www/protocol/jar/Handler.java b/src/share/classes/sun/net/www/protocol/jar/Handler.java index 62686c6b99ebc42875c71ce501f098873e16047a..8e9f8e3a35f2c9403295ad0aafd4fe151d41f5fb 100644 --- a/src/share/classes/sun/net/www/protocol/jar/Handler.java +++ b/src/share/classes/sun/net/www/protocol/jar/Handler.java @@ -123,6 +123,7 @@ public class Handler extends java.net.URLStreamHandler { @Override + @SuppressWarnings("deprecation") protected void parseURL(URL url, String spec, int start, int limit) { String file = null; diff --git a/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java b/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java index 08535a1fff62b01b24944203fff6e367ace581f7..c28dddad9d7058d2c5e6e5c2fe65df7c7fbd3ef4 100644 --- a/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java +++ b/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java @@ -75,7 +75,7 @@ public abstract class HotSpotAttachProvider extends AttachProvider { new ArrayList(); MonitoredHost host; - Set vms; + Set vms; try { host = MonitoredHost.getMonitoredHost(new HostIdentifier((String)null)); vms = host.activeVms(); @@ -92,31 +92,29 @@ public abstract class HotSpotAttachProvider extends AttachProvider { throw new InternalError(t); // shouldn't happen } - for (Object vmid: vms) { - if (vmid instanceof Integer) { - String pid = vmid.toString(); - String name = pid; // default to pid if name not available - boolean isAttachable = false; - MonitoredVm mvm = null; + for (Integer vmid: vms) { + String pid = vmid.toString(); + String name = pid; // default to pid if name not available + boolean isAttachable = false; + MonitoredVm mvm = null; + try { + mvm = host.getMonitoredVm(new VmIdentifier(pid)); try { - mvm = host.getMonitoredVm(new VmIdentifier(pid)); - try { - isAttachable = MonitoredVmUtil.isAttachable(mvm); - // use the command line as the display name - name = MonitoredVmUtil.commandLine(mvm); - } catch (Exception e) { - } - if (isAttachable) { - result.add(new HotSpotVirtualMachineDescriptor(this, pid, name)); - } - } catch (Throwable t) { - if (t instanceof ThreadDeath) { - throw (ThreadDeath)t; - } - } finally { - if (mvm != null) { - mvm.detach(); - } + isAttachable = MonitoredVmUtil.isAttachable(mvm); + // use the command line as the display name + name = MonitoredVmUtil.commandLine(mvm); + } catch (Exception e) { + } + if (isAttachable) { + result.add(new HotSpotVirtualMachineDescriptor(this, pid, name)); + } + } catch (Throwable t) { + if (t instanceof ThreadDeath) { + throw (ThreadDeath)t; + } + } finally { + if (mvm != null) { + mvm.detach(); } } } diff --git a/src/share/classes/sun/tools/jinfo/JInfo.java b/src/share/classes/sun/tools/jinfo/JInfo.java index 9812a1ef5656595bcaf4ee8831d34728ca830160..5a4053416856c330b74cd7ecdb130d8d93fd3253 100644 --- a/src/share/classes/sun/tools/jinfo/JInfo.java +++ b/src/share/classes/sun/tools/jinfo/JInfo.java @@ -98,7 +98,7 @@ public class JInfo { } // loads the given class using the system class loader - private static Class loadClass(String name) { + private static Class loadClass(String name) { // // We specify the system clas loader so as to cater for development // environments where this class is on the boot class path but sa-jdi.jar @@ -178,7 +178,7 @@ public class JInfo { // print usage message private static void usage() { - Class c = loadClass("sun.jvm.hotspot.tools.JInfo"); + Class c = loadClass("sun.jvm.hotspot.tools.JInfo"); boolean usageSA = (c != null); System.out.println("Usage:"); diff --git a/src/share/classes/sun/tools/jmap/JMap.java b/src/share/classes/sun/tools/jmap/JMap.java index 0fb7b79a7e3f066aadb7f5111fbfc3e321219fc0..1d68b668fbf6b7986e17de0e97e0b97560738c87 100644 --- a/src/share/classes/sun/tools/jmap/JMap.java +++ b/src/share/classes/sun/tools/jmap/JMap.java @@ -198,7 +198,7 @@ public class JMap { } // loads the given class using the system class loader - private static Class loadClass(String name) { + private static Class loadClass(String name) { // // We specify the system clas loader so as to cater for development // environments where this class is on the boot class path but sa-jdi.jar @@ -336,7 +336,7 @@ public class JMap { // returns true if SA is available private static boolean haveSA() { - Class c = loadClass("sun.jvm.hotspot.tools.HeapSummary"); + Class c = loadClass("sun.jvm.hotspot.tools.HeapSummary"); return (c != null); } diff --git a/src/share/classes/sun/tools/jps/Jps.java b/src/share/classes/sun/tools/jps/Jps.java index 9611dd3a007fafae7182eb717e1a07ce85592032..9c653816b30f187a996f215733bffccc7d0b4fc9 100644 --- a/src/share/classes/sun/tools/jps/Jps.java +++ b/src/share/classes/sun/tools/jps/Jps.java @@ -59,13 +59,13 @@ public class Jps { MonitoredHost.getMonitoredHost(hostId); // get the set active JVMs on the specified host. - Set jvms = monitoredHost.activeVms(); + Set jvms = monitoredHost.activeVms(); - for (Iterator j = jvms.iterator(); j.hasNext(); /* empty */ ) { + for (Integer jvm: jvms) { StringBuilder output = new StringBuilder(); Throwable lastError = null; - int lvmid = ((Integer)j.next()).intValue(); + int lvmid = jvm; output.append(String.valueOf(lvmid)); diff --git a/src/share/classes/sun/tools/jstack/JStack.java b/src/share/classes/sun/tools/jstack/JStack.java index 004c2abdfb7b5954667cee98abbd42b1d0309fc0..66fc672652c2acc334dcfa87e126deee5c1b7a82 100644 --- a/src/share/classes/sun/tools/jstack/JStack.java +++ b/src/share/classes/sun/tools/jstack/JStack.java @@ -137,7 +137,7 @@ public class JStack { } // Returns sun.jvm.hotspot.tools.JStack if available, otherwise null. - private static Class loadSAClass() { + private static Class loadSAClass() { // // Attempt to load JStack class - we specify the system class // loader so as to cater for development environments where diff --git a/src/share/classes/sun/tools/serialver/SerialVer.java b/src/share/classes/sun/tools/serialver/SerialVer.java index 13ff3599609e1a4ace5dc8d43f597e46a89b54b3..4b310a81ad7774cbc3945bd703ed13d01434b32d 100644 --- a/src/share/classes/sun/tools/serialver/SerialVer.java +++ b/src/share/classes/sun/tools/serialver/SerialVer.java @@ -98,6 +98,7 @@ public class SerialVer extends Applet { classname_t.requestFocus(); } + @SuppressWarnings("deprecation") public boolean action(Event ev, Object obj) { if (ev.target == classname_t) { show((String)ev.arg); @@ -110,6 +111,7 @@ public class SerialVer extends Applet { } + @SuppressWarnings("deprecation") public boolean handleEvent(Event ev) { boolean rc = super.handleEvent(ev); return rc; @@ -206,7 +208,7 @@ public class SerialVer extends Applet { } static String resolveClass(String classname) throws ClassNotFoundException { - Class cl = Class.forName(classname, false, loader); + Class cl = Class.forName(classname, false, loader); ObjectStreamClass desc = ObjectStreamClass.lookup(cl); if (desc != null) { return " static final long serialVersionUID = " + @@ -216,6 +218,10 @@ public class SerialVer extends Applet { } } + @SuppressWarnings("deprecation") + private static void showWindow(Window w) { + w.show(); + } public static void main(String[] args) { boolean show = false; @@ -316,7 +322,7 @@ public class SerialVer extends Applet { f.add("Center", sv); f.pack(); - f.show(); + showWindow(f); } } @@ -362,6 +368,7 @@ class SerialVerFrame extends Frame { /* * Handle a window destroy event by exiting. */ + @SuppressWarnings("deprecation") public boolean handleEvent(Event e) { if (e.id == Event.WINDOW_DESTROY) { exit(0); @@ -371,6 +378,7 @@ class SerialVerFrame extends Frame { /* * Handle an Exit event by exiting. */ + @SuppressWarnings("deprecation") public boolean action(Event ev, Object obj) { if (ev.target == exit_i) { exit(0); @@ -455,11 +463,7 @@ class Res { } try { String message = messageRB.getString(key); - String[] args = new String[3]; - args[0] = a1; - args[1] = a2; - args[2] = a3; - return MessageFormat.format(message, args); + return MessageFormat.format(message, a1, a2, a3); } catch (MissingResourceException e) { throw new Error("Fatal: Resource for serialver is broken. There is no " + key + " key in resource."); }