8054050: Fix stay raw and unchecked lint warnings in core libs

Reviewed-by: lancea, alanb
This commit is contained in:
Joe Darcy 2014-07-31 11:48:39 -07:00
parent 5be9b5e8ec
commit e03cc0d3c2
20 changed files with 72 additions and 69 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, 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
@ -267,7 +267,7 @@ public class GcInfo implements CompositeData, CompositeDataView {
return cdata.toString();
}
public Collection values() {
public Collection<?> values() {
return cdata.values();
}

View File

@ -33,18 +33,18 @@ import java.util.ArrayList;
public class ExpressionParser implements ExpressionParserConstants {
Stack stack = new Stack();
Stack<LValue> stack = new Stack<>();
VirtualMachine vm = null;
GetFrame frameGetter = null;
private static GetFrame lastFrameGetter;
private static LValue lastLValue;
LValue peek() {
return (LValue)stack.peek();
return stack.peek();
}
LValue pop() {
return (LValue)stack.pop();
return stack.pop();
}
void push(LValue lval) {
@ -915,7 +915,7 @@ public class ExpressionParser implements ExpressionParserConstants {
}
final public void PrimarySuffix() throws ParseException {
List argList;
List<Value> argList;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case LBRACKET:
jj_consume_token(LBRACKET);
@ -993,8 +993,8 @@ public class ExpressionParser implements ExpressionParserConstants {
jj_consume_token(NULL);
}
final public List Arguments() throws ParseException {
List argList = new ArrayList();
final public List<Value> Arguments() throws ParseException {
List<Value> argList = new ArrayList<>();
jj_consume_token(LPAREN);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case FALSE:
@ -1026,7 +1026,7 @@ public class ExpressionParser implements ExpressionParserConstants {
throw new Error("Missing return statement in function");
}
final public void ArgumentList(List argList) throws ParseException {
final public void ArgumentList(List<Value> argList) throws ParseException {
Expression();
argList.add(pop().interiorGetValue());
label_17:
@ -1046,7 +1046,7 @@ public class ExpressionParser implements ExpressionParserConstants {
}
final public void AllocationExpression() throws ParseException {
List argList; String className;
List<Value> argList; String className;
if (jj_2_7(2)) {
jj_consume_token(NEW);
PrimitiveType();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -229,9 +229,9 @@ public class JavaClass extends JavaHeapObject {
return name.indexOf('[') != -1;
}
public Enumeration getInstances(boolean includeSubclasses) {
public Enumeration<JavaHeapObject> getInstances(boolean includeSubclasses) {
if (includeSubclasses) {
Enumeration res = instances.elements();
Enumeration<JavaHeapObject> res = instances.elements();
for (int i = 0; i < subclasses.length; i++) {
res = new CompositeEnumeration(res,
subclasses[i].getInstances(true));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -166,11 +166,11 @@ public abstract class JavaHeapObject extends JavaThing {
*
* @return an Enumeration of JavaHeapObject instances
*/
public Enumeration getReferers() {
public Enumeration<JavaThing> getReferers() {
if (referersLen != -1) {
throw new RuntimeException("not resolved: " + getIdString());
}
return new Enumeration() {
return new Enumeration<JavaThing>() {
private int num = 0;
@ -178,7 +178,7 @@ public abstract class JavaHeapObject extends JavaThing {
return referers != null && num < referers.length;
}
public Object nextElement() {
public JavaThing nextElement() {
return referers[num++];
}
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -54,7 +54,7 @@ public class ReachableExcludesImpl implements ReachableExcludes {
private File excludesFile;
private long lastModified;
private Hashtable methods; // Hashtable<String, String>, used as a bag
private Hashtable<String, String> methods; // Used as a bag
/**
* Create a new ReachableExcludesImpl over the given file. The file will be

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -86,7 +86,7 @@ public class ReachableObjects {
// Now grab the elements into a vector, and sort it in decreasing size
JavaThing[] things = new JavaThing[bag.size()];
int i = 0;
for (Enumeration e = bag.elements(); e.hasMoreElements(); ) {
for (Enumeration<JavaHeapObject> e = bag.elements(); e.hasMoreElements(); ) {
things[i++] = (JavaThing) e.nextElement();
}
ArraySorter.sort(things, new Comparer() {
@ -131,7 +131,7 @@ public class ReachableObjects {
return usedFields;
}
private String[] getElements(Hashtable ht) {
private String[] getElements(Hashtable<?, ?> ht) {
Object[] keys = ht.keySet().toArray();
int len = keys.length;
String[] res = new String[len];

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -81,7 +81,7 @@ public class Snapshot {
new HashMap<JavaHeapObject, Root>();
// soft cache of finalizeable objects - lazily initialized
private SoftReference<Vector> finalizablesCache;
private SoftReference<Vector<?>> finalizablesCache;
// represents null reference
private JavaThing nullThing;
@ -383,7 +383,7 @@ public class Snapshot {
/**
* Return an Iterator of all of the classes in this snapshot.
**/
public Iterator getClasses() {
public Iterator<JavaClass> getClasses() {
// note that because classes is a TreeMap
// classes are already sorted by name
return classes.values().iterator();
@ -395,8 +395,8 @@ public class Snapshot {
return res;
}
public synchronized Enumeration getFinalizerObjects() {
Vector obj;
public synchronized Enumeration<?> getFinalizerObjects() {
Vector<?> obj;
if (finalizablesCache != null &&
(obj = finalizablesCache.get()) != null) {
return obj.elements();
@ -418,7 +418,7 @@ public class Snapshot {
finalizables.add(referent);
}
}
finalizablesCache = new SoftReference<Vector>(finalizables);
finalizablesCache = new SoftReference<Vector<?>>(finalizables);
return finalizables.elements();
}
@ -455,7 +455,7 @@ public class Snapshot {
// Even though curr is in the rootset, we want to explore its
// referers, because they might be more interesting.
}
Enumeration referers = curr.getReferers();
Enumeration<JavaThing> referers = curr.getReferers();
while (referers.hasMoreElements()) {
JavaHeapObject t = (JavaHeapObject) referers.nextElement();
if (t != null && !visited.containsKey(t)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -51,7 +51,7 @@ public class OQLEngine {
// create JavaScript engine
Method getEngineMethod = managerClass.getMethod("getEngineByName",
new Class[] { String.class });
new Class<?>[] { String.class });
Object jse = getEngineMethod.invoke(manager, new Object[] {"js"});
oqlSupported = (jse != null);
} catch (Exception exp) {
@ -205,9 +205,9 @@ public class OQLEngine {
}
if (q.className != null) {
Enumeration objects = clazz.getInstances(q.isInstanceOf);
Enumeration<JavaHeapObject> objects = clazz.getInstances(q.isInstanceOf);
while (objects.hasMoreElements()) {
JavaHeapObject obj = (JavaHeapObject) objects.nextElement();
JavaHeapObject obj = objects.nextElement();
Object[] args = new Object[] { wrapJavaObject(obj) };
boolean b = (whereCode == null);
if (!b) {
@ -265,14 +265,14 @@ public class OQLEngine {
// create JavaScript engine
Method getEngineMethod = managerClass.getMethod("getEngineByName",
new Class[] { String.class });
new Class<?>[] { String.class });
engine = getEngineMethod.invoke(manager, new Object[] {"js"});
// initialize engine with init file (hat.js)
InputStream strm = getInitStream();
Class<?> engineClass = Class.forName("javax.script.ScriptEngine");
evalMethod = engineClass.getMethod("eval",
new Class[] { Reader.class });
new Class<?>[] { Reader.class });
evalMethod.invoke(engine, new Object[] {new InputStreamReader(strm)});
// initialize ScriptEngine.eval(String) and
@ -280,13 +280,13 @@ public class OQLEngine {
Class<?> invocableClass = Class.forName("javax.script.Invocable");
evalMethod = engineClass.getMethod("eval",
new Class[] { String.class });
new Class<?>[] { String.class });
invokeMethod = invocableClass.getMethod("invokeFunction",
new Class[] { String.class, Object[].class });
new Class<?>[] { String.class, Object[].class });
// initialize ScriptEngine.put(String, Object) method
Method putMethod = engineClass.getMethod("put",
new Class[] { String.class, Object.class });
new Class<?>[] { String.class, Object.class });
// call ScriptEngine.put to initialize built-in heap object
putMethod.invoke(engine, new Object[] {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -58,10 +58,10 @@ class AllClassesQuery extends QueryHandler {
startHtml("All Classes (including platform)");
}
Iterator classes = snapshot.getClasses();
Iterator<JavaClass> classes = snapshot.getClasses();
String lastPackage = null;
while (classes.hasNext()) {
JavaClass clazz = (JavaClass) classes.next();
JavaClass clazz = classes.next();
if (excludePlatform && PlatformClasses.isPlatformClass(clazz)) {
// skip this..
continue;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -151,7 +151,7 @@ class ClassQuery extends QueryHandler {
}
out.println("<h2>References to this object:</h2>");
out.flush();
Enumeration referers = obj.getReferers();
Enumeration<JavaThing> referers = obj.getReferers();
while (referers.hasMoreElements()) {
JavaHeapObject ref = (JavaHeapObject) referers.nextElement();
printThing(ref);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -37,7 +37,7 @@ import java.util.*;
public class FinalizerObjectsQuery extends QueryHandler {
public void run() {
Enumeration objs = snapshot.getFinalizerObjects();
Enumeration<?> objs = snapshot.getFinalizerObjects();
startHtml("Objects pending finalization");
out.println("<a href='/finalizerSummary/'>Finalizer summary</a>");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -37,7 +37,7 @@ import java.util.*;
public class FinalizerSummaryQuery extends QueryHandler {
public void run() {
Enumeration objs = snapshot.getFinalizerObjects();
Enumeration<?> objs = snapshot.getFinalizerObjects();
startHtml("Finalizer Summary");
out.println("<p align='center'>");
@ -74,7 +74,7 @@ public class FinalizerSummaryQuery extends QueryHandler {
private long count;
}
private void printFinalizerSummary(Enumeration objs) {
private void printFinalizerSummary(Enumeration<?> objs) {
int count = 0;
Map<JavaClass, HistogramElement> map = new HashMap<JavaClass, HistogramElement>();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -111,10 +111,10 @@ class InstancesCountQuery extends QueryHandler {
}
out.print("</a> ");
if (snapshot.getHasNewSet()) {
Enumeration objects = clazz.getInstances(false);
Enumeration<JavaHeapObject> objects = clazz.getInstances(false);
int newInst = 0;
while (objects.hasMoreElements()) {
JavaHeapObject obj = (JavaHeapObject)objects.nextElement();
JavaHeapObject obj = objects.nextElement();
if (obj.isNew()) {
newInst++;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -73,11 +73,11 @@ class InstancesQuery extends QueryHandler {
out.print("<strong>");
printClass(clazz);
out.print("</strong><br><br>");
Enumeration objects = clazz.getInstances(includeSubclasses);
Enumeration<JavaHeapObject> objects = clazz.getInstances(includeSubclasses);
long totalSize = 0;
long instances = 0;
while (objects.hasMoreElements()) {
JavaHeapObject obj = (JavaHeapObject) objects.nextElement();
JavaHeapObject obj = objects.nextElement();
if (newObjects && !obj.isNew())
continue;
printThing(obj);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -47,15 +47,15 @@ public class RefsByTypeQuery extends QueryHandler {
} else {
Map<JavaClass, Long> referrersStat = new HashMap<JavaClass, Long>();
final Map<JavaClass, Long> refereesStat = new HashMap<JavaClass, Long>();
Enumeration instances = clazz.getInstances(false);
Enumeration<JavaHeapObject> instances = clazz.getInstances(false);
while (instances.hasMoreElements()) {
JavaHeapObject instance = (JavaHeapObject) instances.nextElement();
JavaHeapObject instance = instances.nextElement();
if (instance.getId() == -1) {
continue;
}
Enumeration e = instance.getReferers();
Enumeration<JavaThing> e = instance.getReferers();
while (e.hasMoreElements()) {
JavaHeapObject ref = (JavaHeapObject) e.nextElement();
JavaHeapObject ref = (JavaHeapObject)e.nextElement();
JavaClass cl = ref.getClazz();
if (cl == null) {
System.out.println("null class for " + ref);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -34,12 +34,13 @@ package com.sun.tools.hat.internal.util;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import com.sun.tools.hat.internal.model.JavaHeapObject;
public class CompositeEnumeration implements Enumeration {
Enumeration e1;
Enumeration e2;
public class CompositeEnumeration implements Enumeration<JavaHeapObject> {
Enumeration<JavaHeapObject> e1;
Enumeration<JavaHeapObject> e2;
public CompositeEnumeration(Enumeration e1, Enumeration e2) {
public CompositeEnumeration(Enumeration<JavaHeapObject> e1, Enumeration<JavaHeapObject> e2) {
this.e1 = e1;
this.e2 = e2;
}
@ -48,7 +49,7 @@ public class CompositeEnumeration implements Enumeration {
return e1.hasMoreElements() || e2.hasMoreElements();
}
public Object nextElement() {
public JavaHeapObject nextElement() {
if (e1.hasMoreElements()) {
return e1.nextElement();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -39,7 +39,7 @@ import java.util.*;
// Warnings from List filters and List[] requestLists is hard to fix.
// Remove SuppressWarning when we fix the warnings from List filters
// and List[] requestLists. The generic array is not supported.
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
class EventRequestManagerImpl extends MirrorImpl
implements EventRequestManager
{

View File

@ -59,6 +59,7 @@ class ZipFileAttributeView implements BasicFileAttributeView
this.isZipView = isZipView;
}
@SuppressWarnings("unchecked") // Cast to V
static <V extends FileAttributeView> V get(ZipPath path, Class<V> type) {
if (type == null)
throw new NullPointerException();

View File

@ -271,6 +271,7 @@ public class ZipFileSystemProvider extends FileSystemProvider {
}
@Override
@SuppressWarnings("unchecked") // Cast to A
public <A extends BasicFileAttributes> A
readAttributes(Path path, Class<A> type, LinkOption... options)
throws IOException

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, 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
@ -165,7 +165,7 @@ class InheritedChannel {
// Have to use reflection and also make assumption on how FD
// is implemented.
Class paramTypes[] = { int.class };
Class<?> paramTypes[] = { int.class };
Constructor<?> ctr = Reflect.lookupConstructor("java.io.FileDescriptor",
paramTypes);
Object args[] = { new Integer(fdVal) };