提交 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 {
}
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) {
......
......@@ -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;
......
......@@ -428,7 +428,7 @@ public enum LauncherHelper {
if (t != null) {
t.printStackTrace();
} else {
Thread.currentThread().dumpStack();
Thread.dumpStack();
}
}
System.exit(1);
......
......@@ -169,17 +169,15 @@ public class PerfInstrumentation {
Matcher matcher = pattern.matcher("");
List<Counter> matches = new ArrayList<Counter>();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry me = (Map.Entry) iter.next();
String name = (String) me.getKey();
for (Map.Entry<String,Counter> 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;
......
......@@ -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<Principal> principals = subject.getPrincipals();
for (Principal p: principals) {
if (properties.containsKey(p.getName())) {
return;
}
}
final Set<String> principalsStr = new HashSet<String>();
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);
......
......@@ -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",
"lib", "k12", "cc", "tec", "gen", "cog", "mus", "dst"));
private static Map<String,Set> topMap = new HashMap<String,Set>();
private static Map<String,Set> top3Map = new HashMap<String,Set>();
private static Map<String,Set<String>> topMap = new HashMap<>();
private static Map<String,Set<String>> top3Map = new HashMap<>();
static {
/*
......@@ -764,7 +764,7 @@ static {
*/
String str = cname.substring(third + 1);
if (third != -1) {
Set set = top3Map.get(s);
Set<String> 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<String> topSet = topMap.get(s);
if (topSet != null) {
if (topSet.contains(s2)) {
return cname.substring(third + 1);
......
......@@ -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;
......
......@@ -75,7 +75,7 @@ public abstract class HotSpotAttachProvider extends AttachProvider {
new ArrayList<VirtualMachineDescriptor>();
MonitoredHost host;
Set vms;
Set<Integer> 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();
}
}
}
......
......@@ -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:");
......
......@@ -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);
}
......
......@@ -59,13 +59,13 @@ public class Jps {
MonitoredHost.getMonitoredHost(hostId);
// 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();
Throwable lastError = null;
int lvmid = ((Integer)j.next()).intValue();
int lvmid = jvm;
output.append(String.valueOf(lvmid));
......
......@@ -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
......
......@@ -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.");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册