提交 b79c3ab0 编写于 作者: A alanb

7117357: Warnings in sun.instrument, tools and other sun.* classes

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