7090158: Networking Libraries don't build with javac -Werror

Minor changes to networking java files to remove warnings

Co-authored-by: Alexandre Boulgakov <sasha_bu@hotmail.com>
Reviewed-by: chegar, weijun, hawtin
This commit is contained in:
Kurchi Subhra Hazra 2011-09-16 12:09:04 -07:00 committed by Chris Hegarty
parent 49849e0dcf
commit 3580661098
66 changed files with 318 additions and 280 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2005, 2011, 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
@ -26,6 +26,8 @@
BUILDDIR = ../../../..
PACKAGE = com.sun.net.httpserver
PRODUCT = sun
JAVAC_MAX_WARNINGS = true
JAVAC_WARNINGS_FATAL = true
include $(BUILDDIR)/common/Defs.gmk
#

View File

@ -26,6 +26,9 @@
BUILDDIR = ../../../..
PACKAGE = com.sun.net.ssl
PRODUCT = sun
JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation
JAVAC_MAX_WARNINGS = true
JAVAC_WARNINGS_FATAL = true
include $(BUILDDIR)/common/Defs.gmk
#

View File

@ -27,6 +27,9 @@ BUILDDIR = ../..
PACKAGE = java.net
LIBRARY = net
PRODUCT = sun
JAVAC_MAX_WARNINGS = true
JAVAC_WARNINGS_FATAL = true
JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
include $(BUILDDIR)/common/Defs.gmk
#

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1998, 2011, 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

View File

@ -28,7 +28,6 @@
#
BUILDDIR = ../..
JAVAC_MAX_WARNINGS = true
include $(BUILDDIR)/common/Defs.gmk
#

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1995, 2011, 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
@ -26,6 +26,8 @@
BUILDDIR = ../..
PACKAGE = sun.net
PRODUCT = sun
SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = others spi

View File

@ -24,6 +24,8 @@
#
BUILDDIR = ../../..
SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
include $(BUILDDIR)/common/Defs.gmk
SUBDIRS_misc = nameservice

View File

@ -28,7 +28,8 @@
#
BUILDDIR = ../../../../..
JAVAC_MAX_WARNINGS = true
JAVAC_WARNINGS_FATAL = true
# dns should probably be its own module
PACKAGE = sun.net.spi.nameservice.dns
PRODUCT = sun

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2011, 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,13 +54,13 @@ public abstract class BasicAuthenticator extends Authenticator {
public Result authenticate (HttpExchange t)
{
Headers rmap = (Headers) t.getRequestHeaders();
Headers rmap = t.getRequestHeaders();
/*
* look for auth token
*/
String auth = rmap.getFirst ("Authorization");
if (auth == null) {
Headers map = (Headers) t.getResponseHeaders();
Headers map = t.getResponseHeaders();
map.set ("WWW-Authenticate", "Basic realm=" + "\""+realm+"\"");
return new Authenticator.Retry (401);
}
@ -83,7 +83,7 @@ public abstract class BasicAuthenticator extends Authenticator {
} else {
/* reject the request again with 401 */
Headers map = (Headers) t.getResponseHeaders();
Headers map = t.getResponseHeaders();
map.set ("WWW-Authenticate", "Basic realm=" + "\""+realm+"\"");
return new Authenticator.Failure(401);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2011, 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
@ -117,7 +117,7 @@ public class Headers implements Map<String,List<String>> {
* @return the first string value associated with the key
*/
public String getFirst (String key) {
List<String> l = map.get(normalize((String)key));
List<String> l = map.get(normalize(key));
if (l == null) {
return null;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2011, 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,29 +81,27 @@ public abstract class HttpServerProvider {
if (cn == null)
return false;
try {
Class c = Class.forName(cn, true,
Class<?> c = Class.forName(cn, true,
ClassLoader.getSystemClassLoader());
provider = (HttpServerProvider)c.newInstance();
return true;
} catch (ClassNotFoundException x) {
throw new ServiceConfigurationError(x);
} catch (IllegalAccessException x) {
throw new ServiceConfigurationError(x);
} catch (InstantiationException x) {
throw new ServiceConfigurationError(x);
} catch (SecurityException x) {
} catch (ClassNotFoundException |
IllegalAccessException |
InstantiationException |
SecurityException x) {
throw new ServiceConfigurationError(x);
}
}
private static boolean loadProviderAsService() {
Iterator i = Service.providers(HttpServerProvider.class,
@SuppressWarnings("unchecked")
Iterator<HttpServerProvider> i = Service.providers(HttpServerProvider.class,
ClassLoader.getSystemClassLoader());
for (;;) {
try {
if (!i.hasNext())
return false;
provider = (HttpServerProvider)i.next();
provider = i.next();
return true;
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2011, 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
@ -77,7 +77,7 @@ final class SSLSecurity {
{
Provider provider = service.getProvider();
String className = service.getClassName();
Class implClass;
Class<?> implClass;
try {
ClassLoader cl = provider.getClass().getClassLoader();
if (cl == null) {
@ -133,8 +133,8 @@ final class SSLSecurity {
* or someone has removed classes from the jsse.jar file.
*/
Class typeClassJavax;
Class typeClassCom;
Class<?> typeClassJavax;
Class<?> typeClassCom;
Object obj = null;
/*
@ -237,7 +237,7 @@ final class SSLSecurity {
/*
* Checks whether one class is the superclass of another
*/
private static boolean checkSuperclass(Class subclass, Class superclass) {
private static boolean checkSuperclass(Class<?> subclass, Class<?> superclass) {
if ((subclass == null) || (superclass == null))
return false;
@ -276,7 +276,6 @@ final class SSLSecurity {
* object. This also mean that anything going down into the SPI
* needs to be wrapped, as well as anything coming back up.
*/
final class SSLContextSpiWrapper extends SSLContextSpi {
private javax.net.ssl.SSLContext theSSLContext;

View File

@ -165,10 +165,10 @@ class VerifierWrapper implements javax.net.ssl.HostnameVerifier {
private static String getServername(X509Certificate peerCert) {
try {
// compare to subjectAltNames if dnsName is present
Collection subjAltNames = peerCert.getSubjectAlternativeNames();
Collection<List<?>> subjAltNames = peerCert.getSubjectAlternativeNames();
if (subjAltNames != null) {
for (Iterator itr = subjAltNames.iterator(); itr.hasNext(); ) {
List next = (List)itr.next();
for (Iterator<List<?>> itr = subjAltNames.iterator(); itr.hasNext(); ) {
List<?> next = itr.next();
if (((Integer)next.get(0)).intValue() == 2) {
// compare dNSName with host in url
String dnsName = ((String)next.get(1));

View File

@ -26,8 +26,6 @@ package java.net;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.Enumeration;
import sun.net.ResourceManager;
/**
@ -153,11 +151,13 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
* Set the TTL (time-to-live) option.
* @param TTL to be set.
*/
@Deprecated
protected abstract void setTTL(byte ttl) throws IOException;
/**
* Get the TTL (time-to-live) option.
*/
@Deprecated
protected abstract byte getTTL() throws IOException;
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2011, 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
@ -96,7 +96,7 @@ abstract public class ContentHandler {
* @exception IOException if an I/O error occurs while reading the object.
* @since 1.3
*/
public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
Object obj = getContent(urlc);
for (int i = 0; i < classes.length; i++) {

View File

@ -249,7 +249,6 @@ public class CookieManager extends CookieHandler
return Collections.unmodifiableMap(cookieMap);
}
public void
put(URI uri, Map<String, List<String>> responseHeaders)
throws IOException
@ -284,7 +283,7 @@ public class CookieManager extends CookieHandler
cookies = HttpCookie.parse(headerValue);
} catch (IllegalArgumentException e) {
// Bogus header, make an empty list and log the error
cookies = java.util.Collections.EMPTY_LIST;
cookies = java.util.Collections.emptyList();
if (logger.isLoggable(PlatformLogger.SEVERE)) {
logger.severe("Invalid cookie for " + uri + ": " + headerValue);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2011, 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
@ -25,9 +25,7 @@
package java.net;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.nio.channels.DatagramChannel;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
@ -300,7 +298,7 @@ class DatagramSocket implements java.io.Closeable {
}
}
static Class implClass = null;
static Class<?> implClass = null;
void createImpl() throws SocketException {
if (impl == null) {

View File

@ -535,6 +535,7 @@ abstract public class HttpURLConnection extends URLConnection {
return responseMessage;
}
@SuppressWarnings("deprecation")
public long getHeaderFieldDate(String name, long Default) {
String dateString = getHeaderField(name);
try {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2011, 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
@ -25,9 +25,7 @@
package java.net;
import java.security.AccessController;
import java.io.ObjectStreamException;
import sun.security.action.*;
/**
* This class represents an Internet Protocol version 4 (IPv4) address.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2011, 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
@ -59,11 +59,11 @@ class Inet4AddressImpl implements InetAddressImpl {
/*
* Let's make sure we use an address of the proper family
*/
java.util.Enumeration it = netif.getInetAddresses();
java.util.Enumeration<InetAddress> it = netif.getInetAddresses();
InetAddress inetaddr = null;
while (!(inetaddr instanceof Inet4Address) &&
it.hasMoreElements())
inetaddr = (InetAddress) it.nextElement();
inetaddr = it.nextElement();
if (inetaddr instanceof Inet4Address)
ifaddr = inetaddr.getAddress();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2011, 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
@ -383,9 +383,9 @@ class Inet6Address extends InetAddress {
while (en.hasMoreElements()) {
NetworkInterface ifc = en.nextElement();
if (ifc.getName().equals (ifname)) {
Enumeration addresses = ifc.getInetAddresses();
Enumeration<InetAddress> addresses = ifc.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress addr = (InetAddress)addresses.nextElement();
InetAddress addr = addresses.nextElement();
if (!(addr instanceof Inet6Address)) {
continue;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2011, 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,10 +54,10 @@ class Inet6AddressImpl implements InetAddressImpl {
* be either an IPv6 address or an IPv4 address (case of a dual
* stack system).
*/
java.util.Enumeration it = netif.getInetAddresses();
java.util.Enumeration<InetAddress> it = netif.getInetAddresses();
InetAddress inetaddr = null;
while (it.hasMoreElements()) {
inetaddr = (InetAddress) it.nextElement();
inetaddr = it.nextElement();
if (inetaddr.getClass().isInstance(addr)) {
ifaddr = inetaddr.getAddress();
if (inetaddr instanceof Inet6Address) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2011, 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
@ -26,7 +26,6 @@
package java.net;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.Enumeration;
/**
@ -500,9 +499,9 @@ class MulticastSocket extends DatagramSocket {
*/
try {
NetworkInterface ni = NetworkInterface.getByInetAddress(ia);
Enumeration addrs = ni.getInetAddresses();
Enumeration<InetAddress> addrs = ni.getInetAddresses();
while (addrs.hasMoreElements()) {
InetAddress addr = (InetAddress)(addrs.nextElement());
InetAddress addr = addrs.nextElement();
if (addr.equals(infAddress)) {
return infAddress;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2011, 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,7 +73,7 @@ public class Proxy {
// Creates the proxy that represents a <code>DIRECT</code> connection.
private Proxy() {
type = type.DIRECT;
type = Type.DIRECT;
sa = null;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2011, 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
@ -69,7 +69,7 @@ public abstract class ProxySelector {
static {
try {
Class c = Class.forName("sun.net.spi.DefaultProxySelector");
Class<?> c = Class.forName("sun.net.spi.DefaultProxySelector");
if (c != null && ProxySelector.class.isAssignableFrom(c)) {
theProxySelector = (ProxySelector) c.newInstance();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2011, 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
@ -459,13 +459,10 @@ class Socket implements java.io.Closeable {
oldImpl = AccessController.doPrivileged
(new PrivilegedAction<Boolean>() {
public Boolean run() {
Class[] cl = new Class[2];
cl[0] = SocketAddress.class;
cl[1] = Integer.TYPE;
Class clazz = impl.getClass();
Class<?> clazz = impl.getClass();
while (true) {
try {
clazz.getDeclaredMethod("connect", cl);
clazz.getDeclaredMethod("connect", SocketAddress.class, int.class);
return Boolean.FALSE;
} catch (NoSuchMethodException e) {
clazz = clazz.getSuperclass();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2011, 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
@ -467,6 +467,7 @@ implements java.io.Serializable
* @param action the action string
* @return the action mask
*/
@SuppressWarnings("fallthrough")
private static int getMask(String action) {
if (action == null) {
@ -1231,7 +1232,7 @@ final class SocketPermissionCollection extends PermissionCollection
implements Serializable
{
// Not serialized; see serialization section at end of class
private transient List perms;
private transient List<SocketPermission> perms;
/**
* Create an empty SocketPermissions object.
@ -1239,7 +1240,7 @@ implements Serializable
*/
public SocketPermissionCollection() {
perms = new ArrayList();
perms = new ArrayList<SocketPermission>();
}
/**
@ -1267,7 +1268,7 @@ implements Serializable
// optimization to ensure perms most likely to be tested
// show up early (4301064)
synchronized (this) {
perms.add(0, permission);
perms.add(0, (SocketPermission)permission);
}
}
@ -1296,7 +1297,7 @@ implements Serializable
int len = perms.size();
//System.out.println("implies "+np);
for (int i = 0; i < len; i++) {
SocketPermission x = (SocketPermission) perms.get(i);
SocketPermission x = perms.get(i);
//System.out.println(" trying "+x);
if (((needed & x.getMask()) != 0) && x.impliesIgnoreMask(np)) {
effective |= x.getMask();
@ -1316,10 +1317,11 @@ implements Serializable
* @return an enumeration of all the SocketPermission objects.
*/
public Enumeration elements() {
@SuppressWarnings("unchecked")
public Enumeration<Permission> elements() {
// Convert Iterator into Enumeration
synchronized (this) {
return Collections.enumeration(perms);
return Collections.enumeration((List<Permission>)(List)perms);
}
}
@ -1353,7 +1355,7 @@ implements Serializable
// Don't call out.defaultWriteObject()
// Write out Vector
Vector permissions = new Vector(perms.size());
Vector<SocketPermission> permissions = new Vector<>(perms.size());
synchronized (this) {
permissions.addAll(perms);
@ -1375,8 +1377,9 @@ implements Serializable
ObjectInputStream.GetField gfields = in.readFields();
// Get the one we want
Vector permissions = (Vector)gfields.get("permissions", null);
perms = new ArrayList(permissions.size());
@SuppressWarnings("unchecked")
Vector<SocketPermission> permissions = (Vector<SocketPermission>)gfields.get("permissions", null);
perms = new ArrayList<SocketPermission>(permissions.size());
perms.addAll(permissions);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2011, 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
@ -27,7 +27,6 @@ package java.net;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Hashtable;
import java.util.StringTokenizer;
import sun.security.util.SecurityConstants;
@ -1113,7 +1112,7 @@ public final class URL implements java.io.Serializable {
/**
* A table of protocol handlers.
*/
static Hashtable handlers = new Hashtable();
static Hashtable<String,URLStreamHandler> handlers = new Hashtable<>();
private static Object streamHandlerLock = new Object();
/**
@ -1122,7 +1121,7 @@ public final class URL implements java.io.Serializable {
*/
static URLStreamHandler getURLStreamHandler(String protocol) {
URLStreamHandler handler = (URLStreamHandler)handlers.get(protocol);
URLStreamHandler handler = handlers.get(protocol);
if (handler == null) {
boolean checkedWithFactory = false;
@ -1160,7 +1159,7 @@ public final class URL implements java.io.Serializable {
try {
String clsName = packagePrefix + "." + protocol +
".Handler";
Class cls = null;
Class<?> cls = null;
try {
cls = Class.forName(clsName);
} catch (ClassNotFoundException e) {
@ -1185,7 +1184,7 @@ public final class URL implements java.io.Serializable {
// Check again with hashtable just in case another
// thread created a handler since we last checked
handler2 = (URLStreamHandler)handlers.get(protocol);
handler2 = handlers.get(protocol);
if (handler2 != null) {
return handler2;

View File

@ -25,14 +25,7 @@
package java.net;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.ref.*;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandlerFactory;
import java.util.Enumeration;
import java.util.*;
import java.util.jar.Manifest;
import java.util.jar.JarFile;
@ -352,8 +345,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
{
try {
return AccessController.doPrivileged(
new PrivilegedExceptionAction<Class>() {
public Class run() throws ClassNotFoundException {
new PrivilegedExceptionAction<Class<?>>() {
public Class<?> run() throws ClassNotFoundException {
String path = name.replace('.', '/').concat(".class");
Resource res = ucp.getResource(path, false);
if (res != null) {
@ -406,7 +399,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* Resource. The resulting Class must be resolved before it can be
* used.
*/
private Class defineClass(String name, Resource res) throws IOException {
private Class<?> defineClass(String name, Resource res) throws IOException {
long t0 = System.nanoTime();
int i = name.lastIndexOf('.');
URL url = res.getCodeSourceURL();
@ -774,7 +767,7 @@ final class FactoryURLClassLoader extends URLClassLoader {
super(urls, acc);
}
public final Class loadClass(String name, boolean resolve)
public final Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
// First check if we have permission to access the package. This

View File

@ -595,7 +595,7 @@ public abstract class URLConnection {
* @since 1.4
*/
public Map<String,List<String>> getHeaderFields() {
return Collections.EMPTY_MAP;
return Collections.emptyMap();
}
/**
@ -659,6 +659,7 @@ public abstract class URLConnection {
* <code>Default</code> argument is returned if the field is
* missing or malformed.
*/
@SuppressWarnings("deprecation")
public long getHeaderFieldDate(String name, long Default) {
String value = getHeaderField(name);
try {
@ -1153,7 +1154,7 @@ public abstract class URLConnection {
throw new IllegalStateException("Already connected");
if (requests == null)
return Collections.EMPTY_MAP;
return Collections.emptyMap();
return requests.getHeaders(null);
}
@ -1236,7 +1237,7 @@ public abstract class URLConnection {
factory = fac;
}
private static Hashtable handlers = new Hashtable();
private static Hashtable<String, ContentHandler> handlers = new Hashtable<>();
/**
* Gets the Content Handler appropriate for this connection.
@ -1250,7 +1251,7 @@ public abstract class URLConnection {
if (contentType == null)
throw new UnknownServiceException("no content-type");
try {
handler = (ContentHandler) handlers.get(contentType);
handler = handlers.get(contentType);
if (handler != null)
return handler;
} catch(Exception e) {
@ -1316,7 +1317,7 @@ public abstract class URLConnection {
try {
String clsName = packagePrefix + "." + contentHandlerClassName;
Class cls = null;
Class<?> cls = null;
try {
cls = Class.forName(clsName);
} catch (ClassNotFoundException e) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2011, 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
@ -87,7 +87,7 @@ public abstract class SSLServerSocketFactory extends ServerSocketFactory
if (clsName != null) {
log("setting up default SSLServerSocketFactory");
try {
Class cls = null;
Class<?> cls = null;
try {
cls = Class.forName(clsName);
} catch (ClassNotFoundException e) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2011, 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
@ -95,7 +95,7 @@ public abstract class SSLSocketFactory extends SocketFactory
if (clsName != null) {
log("setting up default SSLSocketFactory");
try {
Class cls = null;
Class<?> cls = null;
try {
cls = Class.forName(clsName);
} catch (ClassNotFoundException e) {

View File

@ -31,6 +31,9 @@ package sun.misc;
*/
public class REException extends Exception {
private static final long serialVersionUID = 4656584872733646963L;
REException (String s) {
super(s);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2011, 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
@ -25,10 +25,8 @@
package sun.net;
import java.lang.StringIndexOutOfBoundsException;
import java.io.*;
import java.util.Vector;
import sun.net.NetworkClient;
/**
* This class implements that basic intefaces of transfer protocols.
@ -44,7 +42,7 @@ public class TransferProtocolClient extends NetworkClient {
/** Array of strings (usually 1 entry) for the last reply
from the server. */
protected Vector serverResponse = new Vector(1);
protected Vector<String> serverResponse = new Vector<>(1);
/** code for last reply */
protected int lastReplyCode;
@ -123,11 +121,11 @@ public class TransferProtocolClient extends NetworkClient {
/** converts the server response into a string. */
public String getResponseString() {
return (String) serverResponse.elementAt(0);
return serverResponse.elementAt(0);
}
/** Returns all server response strings. */
public Vector getResponseStrings() {
public Vector<String> getResponseStrings() {
return serverResponse;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2011, 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
@ -67,16 +67,13 @@ public abstract class FtpClientProvider {
return false;
}
try {
Class c = Class.forName(cm, true, null);
Class<?> c = Class.forName(cm, true, null);
provider = (FtpClientProvider) c.newInstance();
return true;
} catch (ClassNotFoundException x) {
throw new ServiceConfigurationError(x.toString());
} catch (IllegalAccessException x) {
throw new ServiceConfigurationError(x.toString());
} catch (InstantiationException x) {
throw new ServiceConfigurationError(x.toString());
} catch (SecurityException x) {
} catch (ClassNotFoundException |
IllegalAccessException |
InstantiationException |
SecurityException x) {
throw new ServiceConfigurationError(x.toString());
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2011, 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
@ -25,13 +25,10 @@
package sun.net.httpserver;
import java.util.*;
import java.nio.*;
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import com.sun.net.httpserver.*;
import com.sun.net.httpserver.spi.*;
/**
*/
@ -47,7 +44,6 @@ class Request {
private OutputStream os;
Request (InputStream rawInputStream, OutputStream rawout) throws IOException {
this.chan = chan;
is = rawInputStream;
os = rawout;
do {
@ -121,7 +117,7 @@ class Request {
}
Headers hdrs = null;
@SuppressWarnings("fallthrough")
Headers headers () throws IOException {
if (hdrs != null) {
return hdrs;
@ -152,6 +148,7 @@ class Request {
parseloop:{
while ((c = is.read()) >= 0) {
switch (c) {
/*fallthrough*/
case ':':
if (inKey && len > 0)
keyend = len;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2011, 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
@ -29,13 +29,10 @@ import java.net.*;
import java.nio.*;
import java.io.*;
import java.nio.channels.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.locks.*;
import javax.net.ssl.*;
import javax.net.ssl.SSLEngineResult.*;
import com.sun.net.httpserver.*;
import com.sun.net.httpserver.spi.*;
/**
* given a non-blocking SocketChannel, it produces
@ -448,6 +445,7 @@ class SSLStreams {
* on the wrapper methods being idempotent. eg. if wrapAndSend()
* is called with no data to send then there must be no problem
*/
@SuppressWarnings("fallthrough")
void doHandshake (HandshakeStatus hs_status) throws IOException {
try {
handshaking.lock();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2011, 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
@ -593,8 +593,8 @@ class ServerImpl implements TimeSource {
rheaders.set ("Connection", "close");
} else if (chdr.equalsIgnoreCase ("keep-alive")) {
rheaders.set ("Connection", "keep-alive");
int idle=(int)ServerConfig.getIdleInterval()/1000;
int max=(int)ServerConfig.getMaxIdleConnections();
int idle=(int)(ServerConfig.getIdleInterval()/1000);
int max=ServerConfig.getMaxIdleConnections();
String val = "timeout="+idle+", max="+max;
rheaders.set ("Keep-Alive", val);
}

View File

@ -33,6 +33,22 @@
// - copy this file from icu4jsrc_3_2/src/com/ibm/icu/lang/UCharacterEnums.java
// - move from package com.ibm.icu.lang to package sun.net.idn
//
// 2011-09-06 Kurchi Subhra Hazra
// - Added @Deprecated tag to the following:
// - class UCharacterEnums
// - interfaces ECharacterCategory, ECharacterDirection
// - fields INITIAL_QUOTE_PUNCTUATION, FINAL_QUOTE_PUNCTUATION,
// DIRECTIONALITY_LEFT_TO_RIGHT, DIRECTIONALITY_RIGHT_TO_LEFT,
// DIRECTIONALITY_EUROPEAN_NUMBER, DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
// DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR, DIRECTIONALITY_ARABIC_NUMBER,
// DIRECTIONALITY_COMMON_NUMBER_SEPARATOR, DIRECTIONALITY_PARAGRAPH_SEPARATOR,
// DIRECTIONALITY_SEGMENT_SEPARATOR, DIRECTIONALITY_WHITESPACE,
// DIRECTIONALITY_OTHER_NEUTRALS, DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING,
// DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE, DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC,
// DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING, DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE,
// DIRECTIONALITY_POP_DIRECTIONAL_FORMAT, DIRECTIONALITY_NON_SPACING_MARK,
// DIRECTIONALITY_BOUNDARY_NEUTRAL, DIRECTIONALITY_UNDEFINED
//
package sun.net.idn;
@ -41,6 +57,8 @@ package sun.net.idn;
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
class UCharacterEnums {
/** This is just a namespace, it is not instantiatable. */
@ -54,6 +72,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static interface ECharacterCategory {
/**
* Unassigned character type
@ -245,6 +264,7 @@ class UCharacterEnums {
* @draft ICU 2.8
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final int INITIAL_QUOTE_PUNCTUATION = 28;
/**
@ -261,6 +281,7 @@ class UCharacterEnums {
* @draft ICU 2.8
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final int FINAL_QUOTE_PUNCTUATION = 29;
/**
@ -279,6 +300,8 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static interface ECharacterDirection {
/**
* Directional type L
@ -291,6 +314,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = (byte)LEFT_TO_RIGHT;
/**
@ -304,6 +328,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = (byte)RIGHT_TO_LEFT;
/**
@ -317,6 +342,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = (byte)EUROPEAN_NUMBER;
/**
@ -330,6 +356,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = (byte)EUROPEAN_NUMBER_SEPARATOR;
/**
@ -343,6 +370,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = (byte)EUROPEAN_NUMBER_TERMINATOR;
/**
@ -356,6 +384,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_ARABIC_NUMBER = (byte)ARABIC_NUMBER;
/**
@ -369,6 +398,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = (byte)COMMON_NUMBER_SEPARATOR;
/**
@ -382,6 +412,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = (byte)BLOCK_SEPARATOR;
/**
@ -395,6 +426,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = (byte)SEGMENT_SEPARATOR;
/**
@ -408,6 +440,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_WHITESPACE = (byte)WHITE_SPACE_NEUTRAL;
/**
@ -421,6 +454,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_OTHER_NEUTRALS = (byte)OTHER_NEUTRAL;
/**
@ -434,6 +468,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = (byte)LEFT_TO_RIGHT_EMBEDDING;
/**
@ -447,6 +482,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = (byte)LEFT_TO_RIGHT_OVERRIDE;
/**
@ -460,6 +496,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = (byte)RIGHT_TO_LEFT_ARABIC;
/**
@ -473,6 +510,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = (byte)RIGHT_TO_LEFT_EMBEDDING;
/**
@ -486,6 +524,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = (byte)RIGHT_TO_LEFT_OVERRIDE;
/**
@ -499,6 +538,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = (byte)POP_DIRECTIONAL_FORMAT;
/**
@ -512,6 +552,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_NON_SPACING_MARK = (byte)DIR_NON_SPACING_MARK;
/**
@ -525,6 +566,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = (byte)BOUNDARY_NEUTRAL;
/**
@ -539,6 +581,7 @@ class UCharacterEnums {
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
@Deprecated
public static final byte DIRECTIONALITY_UNDEFINED = -1;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2011, 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
@ -140,7 +140,7 @@ public final class DNSNameService implements NameService {
// create new soft reference to our thread context
//
thrCtxt = new ThreadContext(dirCtxt, nsList);
contextRef.set(new SoftReference(thrCtxt));
contextRef.set(new SoftReference<ThreadContext>(thrCtxt));
}
return thrCtxt.dirContext();
@ -193,7 +193,7 @@ public final class DNSNameService implements NameService {
Attribute attr = ne.next();
String attrID = attr.getID();
for (NamingEnumeration e = attr.getAll(); e.hasMoreElements();) {
for (NamingEnumeration<?> e = attr.getAll(); e.hasMoreElements();) {
String addr = (String)e.next();
// for canoncical name records do recursive lookup
@ -233,7 +233,7 @@ public final class DNSNameService implements NameService {
String domain = AccessController.doPrivileged(
new GetPropertyAction("sun.net.spi.nameservice.domain"));
if (domain != null && domain.length() > 0) {
domainList = new LinkedList();
domainList = new LinkedList<String>();
domainList.add(domain);
}
@ -282,7 +282,7 @@ public final class DNSNameService implements NameService {
throw new Error(nx);
}
ArrayList results = null;
ArrayList<String> results = null;
UnknownHostException uhe = null;
// If host already contains a domain name then just look it up
@ -365,7 +365,7 @@ public final class DNSNameService implements NameService {
InetAddress[] addrs = new InetAddress[results.size()];
int count = 0;
for (int i=0; i<results.size(); i++) {
String addrString = (String)results.get(i);
String addrString = results.get(i);
byte addr[] = IPAddressUtil.textToNumericFormatV4(addrString);
if (addr == null) {
addr = IPAddressUtil.textToNumericFormatV6(addrString);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2011, 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
@ -192,7 +192,7 @@ public class HeaderParser {
return Default;
}
class ParserIterator implements Iterator {
class ParserIterator implements Iterator<String> {
int index;
boolean returnsValue; // or key
@ -202,7 +202,7 @@ public class HeaderParser {
public boolean hasNext () {
return index<nkeys;
}
public Object next () {
public String next () {
return tab[index++][returnsValue?1:0];
}
public void remove () {
@ -210,20 +210,20 @@ public class HeaderParser {
}
}
public Iterator keys () {
public Iterator<String> keys () {
return new ParserIterator (false);
}
public Iterator values () {
public Iterator<String> values () {
return new ParserIterator (true);
}
public String toString () {
Iterator k = keys();
Iterator<String> k = keys();
StringBuffer sbuf = new StringBuffer();
sbuf.append ("{size="+asize+" nkeys="+nkeys+" ");
for (int i=0; k.hasNext(); i++) {
String key = (String)k.next();
String key = k.next();
String val = findValue (i);
if (val != null && "".equals (val)) {
val = null;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2011, 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
@ -35,7 +35,6 @@ import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.Iterator;
import java.util.NoSuchElementException;
@ -199,7 +198,8 @@ class MessageHeader {
return filterAndAddHeaders(excludeList, null);
}
public synchronized Map<String, List<String>> filterAndAddHeaders(String[] excludeList, Map<String, List<String>> include) {
public synchronized Map<String, List<String>> filterAndAddHeaders(
String[] excludeList, Map<String, List<String>> include) {
boolean skipIt = false;
Map<String, List<String>> m = new HashMap<String, List<String>>();
for (int i = nkeys; --i >= 0;) {
@ -228,15 +228,13 @@ class MessageHeader {
}
if (include != null) {
Iterator entries = include.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry entry = (Map.Entry)entries.next();
List l = (List)m.get(entry.getKey());
for (Map.Entry<String,List<String>> entry: include.entrySet()) {
List<String> l = m.get(entry.getKey());
if (l == null) {
l = new ArrayList();
m.put((String)entry.getKey(), l);
l = new ArrayList<String>();
m.put(entry.getKey(), l);
}
l.add(entry.getValue());
l.addAll(entry.getValue());
}
}
@ -400,6 +398,7 @@ class MessageHeader {
}
/** Parse and merge a MIME header from an input stream. */
@SuppressWarnings("fallthrough")
public void mergeHeader(InputStream is) throws java.io.IOException {
if (is == null)
return;
@ -421,6 +420,7 @@ class MessageHeader {
break;
case '\t':
c = ' ';
/*fall through*/
case ' ':
inKey = false;
break;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2011, 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
@ -25,10 +25,6 @@
package sun.net.www;
import java.io.*;
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.net.URL;
import java.net.FileNameMap;
import java.util.Hashtable;
import java.util.Enumeration;
@ -271,7 +267,7 @@ public class MimeTable implements FileNameMap {
String tempFileTemplate = (String)entries.get("temp.file.template");
if (tempFileTemplate != null) {
entries.remove("temp.file.template");
this.tempFileTemplate = tempFileTemplate;
MimeTable.tempFileTemplate = tempFileTemplate;
}
// now, parse the mime-type spec's
@ -417,10 +413,10 @@ public class MimeTable implements FileNameMap {
String user = System.getProperty("user.name");
if (user != null) {
tag = "; customized for " + user;
properties.save(os, filePreamble + tag);
properties.store(os, filePreamble + tag);
}
else {
properties.save(os, filePreamble);
properties.store(os, filePreamble);
}
}
catch (IOException e) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2011, 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
@ -26,12 +26,7 @@
package sun.net.www;
import java.net.URL;
import java.net.ContentHandler;
import java.util.*;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.BufferedInputStream;
import java.net.UnknownServiceException;
/**
* A class to represent an active connection to an object
@ -99,7 +94,7 @@ abstract public class URLConnection extends java.net.URLConnection {
public Map<String,List<String>> getRequestProperties() {
if (connected)
throw new IllegalStateException("Already connected");
return Collections.EMPTY_MAP;
return Collections.emptyMap();
}
public String getHeaderField(String name) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 1999, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2011, 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
@ -25,11 +25,8 @@
package sun.net.www.content.image;
import java.net.URL;
import java.net.URLConnection;
import java.net.*;
import sun.awt.image.*;
import java.io.InputStream;
import java.io.IOException;
import java.awt.Image;
import java.awt.Toolkit;
@ -40,7 +37,7 @@ public class gif extends ContentHandler {
return new URLImageSource(urlc);
}
public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
for (int i = 0; i < classes.length; i++) {
if (classes[i].isAssignableFrom(URLImageSource.class)) {
return new URLImageSource(urlc);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 1999, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2011, 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
@ -25,11 +25,8 @@
package sun.net.www.content.image;
import java.net.URL;
import java.net.URLConnection;
import java.net.*;
import sun.awt.image.*;
import java.io.InputStream;
import java.io.IOException;
import java.awt.Image;
import java.awt.Toolkit;
@ -39,7 +36,7 @@ public class jpeg extends ContentHandler {
return new URLImageSource(urlc);
}
public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
for (int i = 0; i < classes.length; i++) {
if (classes[i].isAssignableFrom(URLImageSource.class)) {
return new URLImageSource(urlc);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2011, 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
@ -25,10 +25,7 @@
package sun.net.www.content.image;
import java.net.URL;
import java.net.URLConnection;
import java.net.*;
import java.io.InputStream;
import java.io.IOException;
import sun.awt.image.*;
import java.awt.Image;
@ -39,7 +36,7 @@ public class png extends ContentHandler {
return new URLImageSource(urlc);
}
public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
for (int i = 0; i < classes.length; i++) {
if (classes[i].isAssignableFrom(URLImageSource.class)) {
return new URLImageSource(urlc);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 1999, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2011, 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
@ -35,7 +35,7 @@ public class x_xbitmap extends ContentHandler {
return new URLImageSource(urlc);
}
public Object getContent(URLConnection urlc, Class[] classes) throws java.io.IOException {
public Object getContent(URLConnection urlc, Class<?>[] classes) throws java.io.IOException {
for (int i = 0; i < classes.length; i++) {
if (classes[i].isAssignableFrom(URLImageSource.class)) {
return new URLImageSource(urlc);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 1999, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2011, 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
@ -35,7 +35,7 @@ public class x_xpixmap extends ContentHandler {
return new URLImageSource(urlc);
}
public Object getContent(URLConnection urlc, Class[] classes) throws java.io.IOException {
public Object getContent(URLConnection urlc, Class<?>[] classes) throws java.io.IOException {
for (int i = 0; i < classes.length; i++) {
if (classes[i].isAssignableFrom(URLImageSource.class)) {
return new URLImageSource(urlc);

View File

@ -81,7 +81,7 @@ class KeepAliveStream extends MeteredStream implements Hurryable {
// NOTE: Don't close super class
try {
if (expected > count) {
long nskip = (long) (expected - count);
long nskip = expected - count;
if (nskip <= available()) {
long n = 0;
while (n < nskip) {

View File

@ -281,7 +281,7 @@ public class GopherClient extends NetworkClient implements Runnable {
ps.print("</title></head>\n<body>\n<H1>");
ps.print(title);
ps.print("</h1><dl compact>\n");
DataInputStream ds = new DataInputStream(serverInput);
BufferedReader ds = new BufferedReader(new InputStreamReader(serverInput));
String s;
while ((s = ds.readLine()) != null) {
int len = s.length();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2011, 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
@ -25,12 +25,8 @@
package sun.net.www.protocol.http;
import java.io.IOException;
import java.net.URL;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Enumeration;
import java.util.HashMap;
/**
@ -38,13 +34,13 @@ import java.util.HashMap;
*/
public class AuthCacheImpl implements AuthCache {
HashMap hashtable;
HashMap<String,LinkedList<AuthCacheValue>> hashtable;
public AuthCacheImpl () {
hashtable = new HashMap ();
hashtable = new HashMap<String,LinkedList<AuthCacheValue>>();
}
public void setMap (HashMap map) {
public void setMap (HashMap<String,LinkedList<AuthCacheValue>> map) {
hashtable = map;
}
@ -52,21 +48,21 @@ public class AuthCacheImpl implements AuthCache {
// is the path field of AuthenticationInfo
public synchronized void put (String pkey, AuthCacheValue value) {
LinkedList list = (LinkedList) hashtable.get (pkey);
LinkedList<AuthCacheValue> list = hashtable.get (pkey);
String skey = value.getPath();
if (list == null) {
list = new LinkedList ();
hashtable.put (pkey, list);
list = new LinkedList<AuthCacheValue>();
hashtable.put(pkey, list);
}
// Check if the path already exists or a super-set of it exists
ListIterator iter = list.listIterator();
ListIterator<AuthCacheValue> iter = list.listIterator();
while (iter.hasNext()) {
AuthenticationInfo inf = (AuthenticationInfo)iter.next();
if (inf.path == null || inf.path.startsWith (skey)) {
iter.remove ();
}
}
iter.add (value);
iter.add(value);
}
// get a value from map checking both primary
@ -74,7 +70,7 @@ public class AuthCacheImpl implements AuthCache {
public synchronized AuthCacheValue get (String pkey, String skey) {
AuthenticationInfo result = null;
LinkedList list = (LinkedList) hashtable.get (pkey);
LinkedList<AuthCacheValue> list = hashtable.get (pkey);
if (list == null || list.size() == 0) {
return null;
}
@ -82,7 +78,7 @@ public class AuthCacheImpl implements AuthCache {
// list should contain only one element
return (AuthenticationInfo)list.get (0);
}
ListIterator iter = list.listIterator();
ListIterator<AuthCacheValue> iter = list.listIterator();
while (iter.hasNext()) {
AuthenticationInfo inf = (AuthenticationInfo)iter.next();
if (skey.startsWith (inf.path)) {
@ -93,7 +89,7 @@ public class AuthCacheImpl implements AuthCache {
}
public synchronized void remove (String pkey, AuthCacheValue entry) {
LinkedList list = (LinkedList) hashtable.get (pkey);
LinkedList<AuthCacheValue> list = hashtable.get (pkey);
if (list == null) {
return;
}
@ -101,7 +97,7 @@ public class AuthCacheImpl implements AuthCache {
list.clear();
return;
}
ListIterator iter = list.listIterator ();
ListIterator<AuthCacheValue> iter = list.listIterator ();
while (iter.hasNext()) {
AuthenticationInfo inf = (AuthenticationInfo)iter.next();
if (entry.equals(inf)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2011, 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
@ -122,7 +122,7 @@ public class AuthenticationHeader {
this.dontUseNegotiate = dontUseNegotiate;
rsp = response;
this.hdrname = hdrname;
schemes = new HashMap();
schemes = new HashMap<String,SchemeMapValue>();
parse();
}
@ -136,7 +136,7 @@ public class AuthenticationHeader {
HeaderParser parser;
}
HashMap schemes;
HashMap<String, SchemeMapValue> schemes;
/* Iterate through each header line, and then within each line.
* If multiple entries exist for a particular scheme (unlikely)
@ -144,11 +144,11 @@ public class AuthenticationHeader {
* preferred scheme that we support will be used.
*/
private void parse () {
Iterator iter = rsp.multiValueIterator (hdrname);
Iterator<String> iter = rsp.multiValueIterator(hdrname);
while (iter.hasNext()) {
String raw = (String)iter.next();
HeaderParser hp = new HeaderParser (raw);
Iterator keys = hp.keys();
String raw = iter.next();
HeaderParser hp = new HeaderParser(raw);
Iterator<String> keys = hp.keys();
int i, lastSchemeIndex;
for (i=0, lastSchemeIndex = -1; keys.hasNext(); i++) {
keys.next();
@ -164,7 +164,7 @@ public class AuthenticationHeader {
if (i > lastSchemeIndex) {
HeaderParser hpn = hp.subsequence (lastSchemeIndex, i);
String scheme = hpn.findKey(0);
schemes.put (scheme, new SchemeMapValue (hpn, raw));
schemes.put(scheme, new SchemeMapValue (hpn, raw));
}
}
@ -172,10 +172,10 @@ public class AuthenticationHeader {
* negotiate -> kerberos -> digest -> ntlm -> basic
*/
SchemeMapValue v = null;
if (authPref == null || (v=(SchemeMapValue)schemes.get (authPref)) == null) {
if (authPref == null || (v=schemes.get (authPref)) == null) {
if(v == null && !dontUseNegotiate) {
SchemeMapValue tmp = (SchemeMapValue)schemes.get("negotiate");
SchemeMapValue tmp = schemes.get("negotiate");
if(tmp != null) {
if(hci == null || !NegotiateAuthentication.isSupported(new HttpCallerInfo(hci, "Negotiate"))) {
tmp = null;
@ -185,7 +185,7 @@ public class AuthenticationHeader {
}
if(v == null && !dontUseNegotiate) {
SchemeMapValue tmp = (SchemeMapValue)schemes.get("kerberos");
SchemeMapValue tmp = schemes.get("kerberos");
if(tmp != null) {
// the Kerberos scheme is only observed in MS ISA Server. In
// fact i think it's a Kerberos-mechnism-only Negotiate.
@ -205,9 +205,9 @@ public class AuthenticationHeader {
}
if(v == null) {
if ((v=(SchemeMapValue)schemes.get ("digest")) == null) {
if (((v=(SchemeMapValue)schemes.get("ntlm"))==null)) {
v = (SchemeMapValue)schemes.get ("basic");
if ((v=schemes.get ("digest")) == null) {
if (((v=schemes.get("ntlm"))==null)) {
v = schemes.get ("basic");
}
}
}

View File

@ -25,6 +25,7 @@
package sun.net.www.protocol.http;
import java.util.Arrays;
import java.net.URL;
import java.net.URLConnection;
import java.net.ProtocolException;
@ -229,9 +230,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
bufSize4ES = 4096; // use the default
}
allowRestrictedHeaders = ((Boolean)java.security.AccessController.doPrivileged(
allowRestrictedHeaders = java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction(
"sun.net.http.allowRestrictedHeaders"))).booleanValue();
"sun.net.http.allowRestrictedHeaders")).booleanValue();
if (!allowRestrictedHeaders) {
restrictedHeaderSet = new HashSet<String>(restrictedHeaders.length);
for (int i=0; i < restrictedHeaders.length; i++) {
@ -289,6 +290,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
* REMIND: backwards compatibility with JDK 1.1. Should be
* eliminated for JDK 2.0.
*/
@Deprecated
private static HttpAuthenticator defaultAuth;
/* all the headers we send
@ -750,6 +752,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
/**
* @deprecated. Use java.net.Authenticator.setDefault() instead.
*/
@Deprecated
public static void setDefaultAuthenticator(HttpAuthenticator a) {
defaultAuth = a;
}
@ -830,8 +833,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
InetAddress a1 = InetAddress.getByName(h1);
InetAddress a2 = InetAddress.getByName(h2);
result[0] = a1.equals(a2);
} catch(UnknownHostException e) {
} catch(SecurityException e) {
} catch(UnknownHostException | SecurityException e) {
}
return null;
}
@ -1336,9 +1338,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// Read comments labeled "Failed Negotiate" for details.
boolean dontUseNegotiate = false;
Iterator iter = responses.multiValueIterator("Proxy-Authenticate");
Iterator<String> iter = responses.multiValueIterator("Proxy-Authenticate");
while (iter.hasNext()) {
String value = ((String)iter.next()).trim();
String value = iter.next().trim();
if (value.equalsIgnoreCase("Negotiate") ||
value.equalsIgnoreCase("Kerberos")) {
if (!inNegotiateProxy) {
@ -1414,9 +1416,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// Read comments labeled "Failed Negotiate" for details.
boolean dontUseNegotiate = false;
Iterator iter = responses.multiValueIterator("WWW-Authenticate");
Iterator<String> iter = responses.multiValueIterator("WWW-Authenticate");
while (iter.hasNext()) {
String value = ((String)iter.next()).trim();
String value = iter.next().trim();
if (value.equalsIgnoreCase("Negotiate") ||
value.equalsIgnoreCase("Kerberos")) {
if (!inNegotiate) {
@ -1585,9 +1587,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// HttpsURLConnection instance saved in
// DelegateHttpsURLConnection
uconn = (URLConnection)this.getClass().getField("httpsURLConnection").get(this);
} catch (IllegalAccessException iae) {
// ignored; use 'this'
} catch (NoSuchFieldException nsfe) {
} catch (IllegalAccessException |
NoSuchFieldException e) {
// ignored; use 'this'
}
}
@ -1786,9 +1787,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
if (respCode == HTTP_PROXY_AUTH) {
// Read comments labeled "Failed Negotiate" for details.
boolean dontUseNegotiate = false;
Iterator iter = responses.multiValueIterator("Proxy-Authenticate");
Iterator<String> iter = responses.multiValueIterator("Proxy-Authenticate");
while (iter.hasNext()) {
String value = ((String)iter.next()).trim();
String value = iter.next().trim();
if (value.equalsIgnoreCase("Negotiate") ||
value.equalsIgnoreCase("Kerberos")) {
if (!inNegotiateProxy) {
@ -1938,6 +1939,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
* Gets the authentication for an HTTP proxy, and applies it to
* the connection.
*/
@SuppressWarnings("fallthrough")
private AuthenticationInfo getHttpProxyAuthentication (AuthenticationHeader authhdr) {
/* get authorization from authenticator */
AuthenticationInfo ret = null;
@ -2004,13 +2006,13 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
}
break;
case NTLM:
if (NTLMAuthenticationProxy.proxy.supported) {
if (NTLMAuthenticationProxy.supported) {
/* tryTransparentNTLMProxy will always be true the first
* time around, but verify that the platform supports it
* otherwise don't try. */
if (tryTransparentNTLMProxy) {
tryTransparentNTLMProxy =
NTLMAuthenticationProxy.proxy.supportsTransparentAuth;
NTLMAuthenticationProxy.supportsTransparentAuth;
}
a = null;
if (tryTransparentNTLMProxy) {
@ -2043,6 +2045,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
break;
case UNKNOWN:
logger.finest("Unknown/Unsupported authentication scheme: " + scheme);
/*fall through*/
default:
throw new AssertionError("should not reach here");
}
@ -2080,6 +2083,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
* @param authHdr the AuthenticationHeader which tells what auth scheme is
* prefered.
*/
@SuppressWarnings("fallthrough")
private AuthenticationInfo getServerAuthentication (AuthenticationHeader authhdr) {
/* get authorization from authenticator */
AuthenticationInfo ret = null;
@ -2150,7 +2154,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
}
break;
case NTLM:
if (NTLMAuthenticationProxy.proxy.supported) {
if (NTLMAuthenticationProxy.supported) {
URL url1;
try {
url1 = new URL (url, "/"); /* truncate the path */
@ -2163,13 +2167,13 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
* otherwise don't try. */
if (tryTransparentNTLMServer) {
tryTransparentNTLMServer =
NTLMAuthenticationProxy.proxy.supportsTransparentAuth;
NTLMAuthenticationProxy.supportsTransparentAuth;
/* If the platform supports transparent authentication
* then check if we are in a secure environment
* whether, or not, we should try transparent authentication.*/
if (tryTransparentNTLMServer) {
tryTransparentNTLMServer =
NTLMAuthenticationProxy.proxy.isTrustedSite(url);
NTLMAuthenticationProxy.isTrustedSite(url);
}
}
a = null;
@ -2198,6 +2202,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
break;
case UNKNOWN:
logger.finest("Unknown/Unsupported authentication scheme: " + scheme);
/*fall through*/
default:
throw new AssertionError("should not reach here");
}
@ -2745,14 +2750,14 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
* The cookies in the requests message headers may have
* been modified. Use the saved user cookies instead.
*/
Map userCookiesMap = null;
Map<String, List<String>> userCookiesMap = null;
if (userCookies != null || userCookies2 != null) {
userCookiesMap = new HashMap();
userCookiesMap = new HashMap<>();
if (userCookies != null) {
userCookiesMap.put("Cookie", userCookies);
userCookiesMap.put("Cookie", Arrays.asList(userCookies));
}
if (userCookies2 != null) {
userCookiesMap.put("Cookie2", userCookies2);
userCookiesMap.put("Cookie2", Arrays.asList(userCookies2));
}
}
return requests.filterAndAddHeaders(EXCLUDE_HEADERS2, userCookiesMap);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2011, 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
@ -45,8 +45,8 @@ public abstract class Negotiator {
// Makes NegotiatorImpl, and the security classes it references, a
// runtime dependency rather than a static one.
Class clazz;
Constructor c;
Class<?> clazz;
Constructor<?> c;
try {
clazz = Class.forName("sun.net.www.protocol.http.spnego.NegotiatorImpl", true, null);
c = clazz.getConstructor(HttpCallerInfo.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2011, 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
@ -221,11 +221,11 @@ public abstract class AbstractDelegateHttpsURLConnection extends
*/
public java.security.cert.Certificate[] getLocalCertificates() {
if (cachedResponse != null) {
List l = ((SecureCacheResponse)cachedResponse).getLocalCertificateChain();
List<java.security.cert.Certificate> l = ((SecureCacheResponse)cachedResponse).getLocalCertificateChain();
if (l == null) {
return null;
} else {
return (java.security.cert.Certificate[])l.toArray();
return l.toArray(new java.security.cert.Certificate[0]);
}
}
if (http == null) {
@ -243,11 +243,11 @@ public abstract class AbstractDelegateHttpsURLConnection extends
public java.security.cert.Certificate[] getServerCertificates()
throws SSLPeerUnverifiedException {
if (cachedResponse != null) {
List l = ((SecureCacheResponse)cachedResponse).getServerCertificateChain();
List<java.security.cert.Certificate> l = ((SecureCacheResponse)cachedResponse).getServerCertificateChain();
if (l == null) {
return null;
} else {
return (java.security.cert.Certificate[])l.toArray();
return l.toArray(new java.security.cert.Certificate[0]);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2011, 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
@ -529,7 +529,7 @@ final class HttpsClient extends HttpClient
new BufferedOutputStream(serverSocket.getOutputStream()),
false, encoding);
} catch (UnsupportedEncodingException e) {
throw new InternalError(encoding+" encoding not found", e);
throw new InternalError(encoding+" encoding not found");
}
// check URL spoofing if it has not been checked under handshaking
@ -623,7 +623,7 @@ final class HttpsClient extends HttpClient
*/
@Override
public void closeIdleConnection() {
HttpClient http = (HttpClient) kac.get(url, sslSocketFactory);
HttpClient http = kac.get(url, sslSocketFactory);
if (http != null) {
http.closeServer();
}
@ -681,8 +681,7 @@ final class HttpsClient extends HttpClient
// return the X500Principal of the end-entity cert.
java.security.cert.Certificate[] certs =
session.getPeerCertificates();
principal = (X500Principal)
((X509Certificate)certs[0]).getSubjectX500Principal();
principal = ((X509Certificate)certs[0]).getSubjectX500Principal();
}
return principal;
}
@ -703,8 +702,7 @@ final class HttpsClient extends HttpClient
java.security.cert.Certificate[] certs =
session.getLocalCertificates();
if (certs != null) {
principal = (X500Principal)
((X509Certificate)certs[0]).getSubjectX500Principal();
principal = ((X509Certificate)certs[0]).getSubjectX500Principal();
}
}
return principal;

View File

@ -139,6 +139,20 @@ public class Handler extends URLStreamHandler {
}
if (nogood)
throw new RuntimeException("No email address");
setURL(u, protocol, host, port, file, null);
setURLHandler(u, protocol, host, port, file, null);
}
/**
* This method is used to suppress the deprecated warning
*
* @param u the URL to receive the result of parsing the spec
* @param spec the URL string to parse
* @param start the character position to start parsing at. This is
* just past the ':'.
* @param limit the character position to stop parsing at.
*/
@SuppressWarnings("deprecation")
private void setURLHandler(URL u, String protocol, String host, int port, String file, String ref) {
setURL(u,protocol,host,port,file,null);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,2011, 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
@ -35,7 +35,7 @@ import java.security.AccessController;
*/
class DefaultDatagramSocketImplFactory {
static Class prefixImplClass = null;
static Class<?> prefixImplClass = null;
static {
String prefix = null;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,2011, 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,8 +54,10 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
protected native int getTimeToLive() throws IOException;
@Deprecated
protected native void setTTL(byte ttl) throws IOException;
@Deprecated
protected native byte getTTL() throws IOException;
protected native void join(InetAddress inetaddr, NetworkInterface netIf)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2011, 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
@ -149,7 +149,7 @@ public class ResolverConfigurationImpl
sl = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<LinkedList<String>>() {
public LinkedList<String> run() {
LinkedList ll;
LinkedList<String> ll;
// first try search keyword (max 6 domains)
ll = resolvconf("search", 6, 1);
@ -173,7 +173,7 @@ public class ResolverConfigurationImpl
String localDomain = localDomain0();
if (localDomain != null && localDomain.length() > 0) {
sl = new LinkedList();
sl = new LinkedList<String>();
sl.add(localDomain);
return sl;
}
@ -198,7 +198,7 @@ public class ResolverConfigurationImpl
}
// no local domain so try fallback (RPC) domain or
// hostname
// hostName
sl = new LinkedList<>();
String domain = fallbackDomain0();
@ -216,22 +216,26 @@ public class ResolverConfigurationImpl
opts = new OptionsImpl();
}
@SuppressWarnings("unchecked")
public List<String> searchlist() {
synchronized (lock) {
loadConfig();
// List is mutable so return a shallow copy
return (List)searchlist.clone();
return (List<String>)searchlist.clone();
}
}
@SuppressWarnings("unchecked")
public List<String> nameservers() {
synchronized (lock) {
loadConfig();
// List is mutable so return a shallow copy
return (List)nameservers.clone();
}
return (List<String>)nameservers.clone();
}
}
public Options options() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2011, 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
@ -45,7 +45,7 @@ import java.security.PrivilegedAction;
class DefaultDatagramSocketImplFactory
{
static Class prefixImplClass = null;
static Class<?> prefixImplClass = null;
/* the windows version. */
private static float version;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,2011 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
@ -25,7 +25,6 @@
package java.net;
import java.io.IOException;
import java.io.FileDescriptor;
import sun.misc.SharedSecrets;
import sun.misc.JavaIOFileDescriptorAccess;
@ -215,11 +214,12 @@ class DualStackPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
throw new IOException("Method not implemented!");
}
@Deprecated
protected void setTTL(byte ttl) throws IOException {
throw new IOException("Method not implemented!");
}
@Deprecated
protected byte getTTL() throws IOException {
throw new IOException("Method not implemented!");
}

View File

@ -133,8 +133,10 @@ class TwoStacksPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
protected native int getTimeToLive() throws IOException;
@Deprecated
protected native void setTTL(byte ttl) throws IOException;
@Deprecated
protected native byte getTTL() throws IOException;
protected native void join(InetAddress inetaddr, NetworkInterface netIf)

View File

@ -57,8 +57,8 @@ public class ResolverConfigurationImpl
private static String os_nameservers;
// Cached lists
private static LinkedList searchlist;
private static LinkedList nameservers;
private static LinkedList<String> searchlist;
private static LinkedList<String> nameservers;
// Parse string that consists of token delimited by space or commas
// and return LinkedHashMap
@ -111,21 +111,23 @@ public class ResolverConfigurationImpl
opts = new OptionsImpl();
}
@SuppressWarnings("unchecked") // clone()
public List<String> searchlist() {
synchronized (lock) {
loadConfig();
// List is mutable so return a shallow copy
return (List)searchlist.clone();
return (List<String>)searchlist.clone();
}
}
@SuppressWarnings("unchecked") // clone()
public List<String> nameservers() {
synchronized (lock) {
loadConfig();
// List is mutable so return a shallow copy
return (List)nameservers.clone();
return (List<String>)nameservers.clone();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2011, 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
@ -148,7 +148,7 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
private Permission getPermission(JarFile jarFile) {
try {
URLConnection uc = (URLConnection)getConnection(jarFile);
URLConnection uc = getConnection(jarFile);
if (uc != null)
return uc.getPermission();
} catch (IOException ioe) {