提交 0878054f 编写于 作者: W weijun

7116857: Warnings in javax.security and some sun.misc

Reviewed-by: smarks
上级 e5894de1
......@@ -369,7 +369,7 @@ public final class ServicePermission extends Permission
switch(a[i-matchlen]) {
case ',':
seencomma = true;
/*FALLTHROUGH*/
break;
case ' ': case '\r': case '\n':
case '\f': case '\t':
break;
......
......@@ -28,7 +28,9 @@ package sun.misc;
import java.io.IOException;
public class CEFormatException extends IOException {
static final long serialVersionUID = -7139121221067081482L;
public CEFormatException(String s) {
super(s);
}
}
......@@ -27,4 +27,7 @@ package sun.misc;
import java.io.IOException;
/** This exception is thrown when EOF is reached */
public class CEStreamExhausted extends IOException { };
public class CEStreamExhausted extends IOException {
static final long serialVersionUID = -5889118049525891904L;
}
......@@ -79,9 +79,9 @@ public class ClassLoaderUtil {
URLClassPath ucp = SharedSecrets.getJavaNetAccess()
.getURLClassPath(classLoader);
ArrayList loaders = ucp.loaders;
Stack urls = ucp.urls;
HashMap lmap = ucp.lmap;
ArrayList<?> loaders = ucp.loaders;
Stack<?> urls = ucp.urls;
HashMap<?,?> lmap = ucp.lmap;
/*
*The urls variable in the URLClassPath object holds URLs that have not yet
......
......@@ -33,10 +33,10 @@ import java.util.NoSuchElementException;
* enumerations.
*/
public class CompoundEnumeration<E> implements Enumeration<E> {
private Enumeration[] enums;
private Enumeration<E>[] enums;
private int index = 0;
public CompoundEnumeration(Enumeration[] enums) {
public CompoundEnumeration(Enumeration<E>[] enums) {
this.enums = enums;
}
......@@ -58,6 +58,6 @@ public class CompoundEnumeration<E> implements Enumeration<E> {
if (!next()) {
throw new NoSuchElementException();
}
return (E)enums[index].nextElement();
return enums[index].nextElement();
}
}
......@@ -34,6 +34,8 @@ package sun.misc;
public class ExtensionInstallationException extends Exception {
static final long serialVersionUID = 3139688306909345924L;
/*
* <p>
* Construct a new exception with an exception reason
......
......@@ -325,7 +325,7 @@ public class FloatingDecimal{
// can do int arithmetic rather than long!
int ivalue = (int)lvalue;
ndigits = 10;
digits = (char[])(perThreadBuffer.get());
digits = perThreadBuffer.get();
digitno = ndigits-1;
c = ivalue%10;
ivalue /= 10;
......@@ -345,7 +345,7 @@ public class FloatingDecimal{
// same algorithm as above (same bugs, too )
// but using long arithmetic.
ndigits = 20;
digits = (char[])(perThreadBuffer.get());
digits = perThreadBuffer.get();
digitno = ndigits-1;
c = (int)(lvalue%10L);
lvalue /= 10L;
......@@ -477,9 +477,9 @@ public class FloatingDecimal{
}
// Begin to unpack
// Discover obvious special cases of NaN and Infinity.
binExp = (int)( (fBits&singleExpMask) >> singleExpShift );
binExp = (fBits&singleExpMask) >> singleExpShift;
fractBits = fBits&singleFractMask;
if ( binExp == (int)(singleExpMask>>singleExpShift) ) {
if ( binExp == (singleExpMask>>singleExpShift) ) {
isExceptional = true;
if ( fractBits == 0L ){
digits = infinity;
......@@ -900,7 +900,7 @@ public class FloatingDecimal{
}
public String toJavaFormatString() {
char result[] = (char[])(perThreadBuffer.get());
char result[] = perThreadBuffer.get();
int i = getChars(result);
return new String(result, 0, i);
}
......@@ -978,14 +978,14 @@ public class FloatingDecimal{
}
// Per-thread buffer for string/stringbuffer conversion
private static ThreadLocal perThreadBuffer = new ThreadLocal() {
protected synchronized Object initialValue() {
private static ThreadLocal<char[]> perThreadBuffer = new ThreadLocal<char[]>() {
protected synchronized char[] initialValue() {
return new char[26];
}
};
public void appendTo(Appendable buf) {
char result[] = (char[])(perThreadBuffer.get());
char result[] = perThreadBuffer.get();
int i = getChars(result);
if (buf instanceof StringBuilder)
((StringBuilder) buf).append(result, 0, i);
......@@ -995,6 +995,7 @@ public class FloatingDecimal{
assert false;
}
@SuppressWarnings("fallthrough")
public static FloatingDecimal
readJavaFormatString( String in ) throws NumberFormatException {
boolean isNegative = false;
......@@ -2209,7 +2210,7 @@ public class FloatingDecimal{
// exponent correctly, even in the case of
// Double.MAX_VALUE overflowing to infinity.
significand = (( ((long)exponent +
significand = (( (exponent +
(long)DoubleConsts.EXP_BIAS) <<
(DoubleConsts.SIGNIFICAND_WIDTH-1))
& DoubleConsts.EXP_BIT_MASK) |
......
......@@ -333,7 +333,7 @@ public class FormattedFloatingDecimal{
// can do int arithmetic rather than long!
int ivalue = (int)lvalue;
ndigits = 10;
digits = (char[])(perThreadBuffer.get());
digits = perThreadBuffer.get();
digitno = ndigits-1;
c = ivalue%10;
ivalue /= 10;
......@@ -353,7 +353,7 @@ public class FormattedFloatingDecimal{
// same algorithm as above (same bugs, too )
// but using long arithmetic.
ndigits = 20;
digits = (char[])(perThreadBuffer.get());
digits = perThreadBuffer.get();
digitno = ndigits-1;
c = (int)(lvalue%10L);
lvalue /= 10L;
......@@ -554,9 +554,9 @@ public class FormattedFloatingDecimal{
}
// Begin to unpack
// Discover obvious special cases of NaN and Infinity.
binExp = (int)( (fBits&singleExpMask) >> singleExpShift );
binExp = (fBits&singleExpMask) >> singleExpShift;
fractBits = fBits&singleFractMask;
if ( binExp == (int)(singleExpMask>>singleExpShift) ) {
if ( binExp == (singleExpMask>>singleExpShift) ) {
isExceptional = true;
if ( fractBits == 0L ){
digits = infinity;
......@@ -1140,8 +1140,8 @@ public class FormattedFloatingDecimal{
}
// Per-thread buffer for string/stringbuffer conversion
private static ThreadLocal perThreadBuffer = new ThreadLocal() {
protected synchronized Object initialValue() {
private static ThreadLocal<char[]> perThreadBuffer = new ThreadLocal<char[]>() {
protected synchronized char[] initialValue() {
return new char[26];
}
};
......
......@@ -38,6 +38,8 @@ import java.lang.LinkageError;
public
class InvalidJarIndexException extends RuntimeException {
static final long serialVersionUID = -6159797516569680148L;
/**
* Constructs an <code>InvalidJarIndexException</code> with no
* detail message.
......
......@@ -52,7 +52,9 @@ public abstract class LRUCache<N,V> {
public V forName(N name) {
if (oa == null) {
oa = (V[])new Object[size];
@SuppressWarnings("unchecked")
V[] temp = (V[])new Object[size];
oa = temp;
} else {
for (int i = 0; i < oa.length; i++) {
V ob = oa[i];
......
......@@ -35,12 +35,12 @@ import java.util.NoSuchElementException;
* @author Herb Jellinek
*/
public class Queue {
public class Queue<T> {
int length = 0;
QueueElement head = null;
QueueElement tail = null;
QueueElement<T> head = null;
QueueElement<T> tail = null;
public Queue() {
}
......@@ -48,9 +48,9 @@ public class Queue {
/**
* Enqueue an object.
*/
public synchronized void enqueue(Object obj) {
public synchronized void enqueue(T obj) {
QueueElement newElt = new QueueElement(obj);
QueueElement<T> newElt = new QueueElement<>(obj);
if (head == null) {
head = newElt;
......@@ -72,7 +72,7 @@ public class Queue {
* @exception java.lang.InterruptedException if any thread has
* interrupted this thread.
*/
public Object dequeue() throws InterruptedException {
public T dequeue() throws InterruptedException {
return dequeue(0L);
}
......@@ -85,13 +85,13 @@ public class Queue {
* @exception java.lang.InterruptedException if any thread has
* interrupted this thread.
*/
public synchronized Object dequeue(long timeOut)
public synchronized T dequeue(long timeOut)
throws InterruptedException {
while (tail == null) {
wait(timeOut);
}
QueueElement elt = tail;
QueueElement<T> elt = tail;
tail = elt.prev;
if (tail == null) {
head = null;
......@@ -115,8 +115,8 @@ public class Queue {
* order. Use the Enumeration methods on the returned object to
* fetch the elements sequentially.
*/
public final synchronized Enumeration elements() {
return new LIFOQueueEnumerator(this);
public final synchronized Enumeration<T> elements() {
return new LIFOQueueEnumerator<>(this);
}
/**
......@@ -124,8 +124,8 @@ public class Queue {
* order. Use the Enumeration methods on the returned object to
* fetch the elements sequentially.
*/
public final synchronized Enumeration reverseElements() {
return new FIFOQueueEnumerator(this);
public final synchronized Enumeration<T> reverseElements() {
return new FIFOQueueEnumerator<>(this);
}
public synchronized void dump(String msg) {
......@@ -133,8 +133,8 @@ public class Queue {
System.err.println("["+length+" elt(s); head = "+
(head == null ? "null" : (head.obj)+"")+
" tail = "+(tail == null ? "null" : (tail.obj)+""));
QueueElement cursor = head;
QueueElement last = null;
QueueElement<T> cursor = head;
QueueElement<T> last = null;
while (cursor != null) {
System.err.println(" "+cursor);
last = cursor;
......@@ -147,11 +147,11 @@ public class Queue {
}
}
final class FIFOQueueEnumerator implements Enumeration {
Queue queue;
QueueElement cursor;
final class FIFOQueueEnumerator<T> implements Enumeration<T> {
Queue<T> queue;
QueueElement<T> cursor;
FIFOQueueEnumerator(Queue q) {
FIFOQueueEnumerator(Queue<T> q) {
queue = q;
cursor = q.tail;
}
......@@ -160,10 +160,10 @@ final class FIFOQueueEnumerator implements Enumeration {
return (cursor != null);
}
public Object nextElement() {
public T nextElement() {
synchronized (queue) {
if (cursor != null) {
QueueElement result = cursor;
QueueElement<T> result = cursor;
cursor = cursor.prev;
return result.obj;
}
......@@ -172,11 +172,11 @@ final class FIFOQueueEnumerator implements Enumeration {
}
}
final class LIFOQueueEnumerator implements Enumeration {
Queue queue;
QueueElement cursor;
final class LIFOQueueEnumerator<T> implements Enumeration<T> {
Queue<T> queue;
QueueElement<T> cursor;
LIFOQueueEnumerator(Queue q) {
LIFOQueueEnumerator(Queue<T> q) {
queue = q;
cursor = q.head;
}
......@@ -185,10 +185,10 @@ final class LIFOQueueEnumerator implements Enumeration {
return (cursor != null);
}
public Object nextElement() {
public T nextElement() {
synchronized (queue) {
if (cursor != null) {
QueueElement result = cursor;
QueueElement<T> result = cursor;
cursor = cursor.next;
return result.obj;
}
......@@ -197,13 +197,13 @@ final class LIFOQueueEnumerator implements Enumeration {
}
}
class QueueElement {
QueueElement next = null;
QueueElement prev = null;
class QueueElement<T> {
QueueElement<T> next = null;
QueueElement<T> prev = null;
Object obj = null;
T obj = null;
QueueElement(Object obj) {
QueueElement(T obj) {
this.obj = obj;
}
......
......@@ -36,7 +36,7 @@ package sun.misc;
public class RequestProcessor implements Runnable {
private static Queue requestQueue;
private static Queue<Request> requestQueue;
private static Thread dispatcher;
/**
......@@ -55,16 +55,13 @@ public class RequestProcessor implements Runnable {
lazyInitialize();
while (true) {
try {
Object obj = requestQueue.dequeue();
if (obj instanceof Request) { // ignore bogons
Request req = (Request)obj;
Request req = requestQueue.dequeue();
try {
req.execute();
} catch (Throwable t) {
// do nothing at the moment...maybe report an error
// in the future
}
}
} catch (InterruptedException e) {
// do nothing at the present time.
}
......@@ -92,7 +89,7 @@ public class RequestProcessor implements Runnable {
*/
private static synchronized void lazyInitialize() {
if (requestQueue == null) {
requestQueue = new Queue();
requestQueue = new Queue<Request>();
}
}
......
......@@ -43,6 +43,8 @@ package sun.misc;
public class ServiceConfigurationError extends Error {
static final long serialVersionUID = 8769866263384244465L;
/**
* Constructs a new instance with the specified detail string.
*/
......
......@@ -836,10 +836,9 @@ public class URLClassPath {
Set<String> visited) {
Resource res;
Object[] jarFiles;
boolean done = false;
String[] jarFiles;
int count = 0;
LinkedList jarFilesList = null;
LinkedList<String> jarFilesList = null;
/* If there no jar files in the index that can potential contain
* this resource then return immediately.
......@@ -848,11 +847,11 @@ public class URLClassPath {
return null;
do {
jarFiles = jarFilesList.toArray();
int size = jarFilesList.size();
jarFiles = jarFilesList.toArray(new String[size]);
/* loop through the mapped jar file list */
while(count < size) {
String jarName = (String)jarFiles[count++];
String jarName = jarFiles[count++];
JarLoader newLoader;
final URL url;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册