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