diff options
Diffstat (limited to 'libjava/classpath/java/net')
-rw-r--r-- | libjava/classpath/java/net/MimeTypeMapper.java | 13 | ||||
-rw-r--r-- | libjava/classpath/java/net/MulticastSocket.java | 6 | ||||
-rw-r--r-- | libjava/classpath/java/net/NetworkInterface.java | 7 | ||||
-rw-r--r-- | libjava/classpath/java/net/Proxy.java | 2 | ||||
-rw-r--r-- | libjava/classpath/java/net/ResolverCache.java | 4 | ||||
-rw-r--r-- | libjava/classpath/java/net/ServerSocket.java | 7 | ||||
-rw-r--r-- | libjava/classpath/java/net/Socket.java | 23 | ||||
-rw-r--r-- | libjava/classpath/java/net/URI.java | 2 | ||||
-rw-r--r-- | libjava/classpath/java/net/URL.java | 11 | ||||
-rw-r--r-- | libjava/classpath/java/net/URLClassLoader.java | 29 | ||||
-rw-r--r-- | libjava/classpath/java/net/class-dependencies.conf | 122 |
11 files changed, 58 insertions, 168 deletions
diff --git a/libjava/classpath/java/net/MimeTypeMapper.java b/libjava/classpath/java/net/MimeTypeMapper.java index 8153694..b0d400c 100644 --- a/libjava/classpath/java/net/MimeTypeMapper.java +++ b/libjava/classpath/java/net/MimeTypeMapper.java @@ -232,7 +232,8 @@ class MimeTypeMapper implements FileNameMap /** * The MIME types above are put into this Hashtable for faster lookup. */ - private Hashtable mime_types = new Hashtable(150); + private Hashtable<String, String> mime_types + = new Hashtable<String, String>(150); /** * Create a new <code>MimeTypeMapper</code> object. @@ -257,7 +258,7 @@ class MimeTypeMapper implements FileNameMap } } - public static void fillFromFile (Map table, String fname) + public static void fillFromFile (Map<String, String> table, String fname) throws IOException { LineNumberReader reader = @@ -325,17 +326,17 @@ class MimeTypeMapper implements FileNameMap */ public static void main(String[] args) throws IOException { - TreeMap map = new TreeMap(); + TreeMap<String, String> map = new TreeMap<String, String>(); // It is fine to hard-code the name here. This is only ever // used by maintainers, who can hack it if they need to re-run // it. fillFromFile(map, "/etc/mime.types"); - Iterator it = map.keySet().iterator(); + Iterator<String> it = map.keySet().iterator(); boolean first = true; while (it.hasNext()) { - String key = (String) it.next(); - String value = (String) map.get(key); + String key = it.next(); + String value = map.get(key); // Put the "," first since it is easier to make correct syntax this way. System.out.println(" " + (first ? " " : ", ") + "{ \"" + key + "\", \"" + value + "\" }"); diff --git a/libjava/classpath/java/net/MulticastSocket.java b/libjava/classpath/java/net/MulticastSocket.java index 2841192..114d11f 100644 --- a/libjava/classpath/java/net/MulticastSocket.java +++ b/libjava/classpath/java/net/MulticastSocket.java @@ -1,5 +1,5 @@ /* MulticastSocket.java -- Class for using multicast sockets - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -337,7 +337,7 @@ public class MulticastSocket extends DatagramSocket /** * Sets the "Time to Live" value for a socket. The value must be between - * 1 and 255. + * 0 and 255, inclusive. * * @param ttl The new TTL value * @@ -350,7 +350,7 @@ public class MulticastSocket extends DatagramSocket if (isClosed()) throw new SocketException("socket is closed"); - if (ttl <= 0 || ttl > 255) + if (ttl < 0 || ttl > 255) throw new IllegalArgumentException("Invalid ttl: " + ttl); getImpl().setTimeToLive(ttl); diff --git a/libjava/classpath/java/net/NetworkInterface.java b/libjava/classpath/java/net/NetworkInterface.java index 6c78ead..a3a6058 100644 --- a/libjava/classpath/java/net/NetworkInterface.java +++ b/libjava/classpath/java/net/NetworkInterface.java @@ -40,12 +40,8 @@ package java.net; import gnu.classpath.SystemProperties; -import java.util.Collection; -import java.util.Collections; import java.util.Enumeration; -import java.util.HashMap; import java.util.Iterator; -import java.util.Map; import java.util.Vector; /** @@ -100,7 +96,8 @@ public final class NetworkInterface public Enumeration<InetAddress> getInetAddresses() { SecurityManager s = System.getSecurityManager(); - Vector inetAddresses = new Vector(netif.addresses); + Vector<InetAddress> inetAddresses + = new Vector<InetAddress>(netif.addresses); if (s == null) return inetAddresses.elements(); diff --git a/libjava/classpath/java/net/Proxy.java b/libjava/classpath/java/net/Proxy.java index 6f9f1b6..3151774 100644 --- a/libjava/classpath/java/net/Proxy.java +++ b/libjava/classpath/java/net/Proxy.java @@ -57,7 +57,7 @@ public class Proxy * For compatability with Sun's JDK */ private static final long serialVersionUID = -2231209257930100533L; - }; + } public static final Proxy NO_PROXY = new Proxy(Type.DIRECT, null); diff --git a/libjava/classpath/java/net/ResolverCache.java b/libjava/classpath/java/net/ResolverCache.java index f879066..d57df49 100644 --- a/libjava/classpath/java/net/ResolverCache.java +++ b/libjava/classpath/java/net/ResolverCache.java @@ -97,12 +97,12 @@ class ResolverCache /** * The cache itself. */ - private static HashMap cache = new HashMap(); + private static HashMap<Object, Entry> cache = new HashMap<Object, Entry>(); /** * List of entries which may expire. */ - private static LinkedList killqueue = new LinkedList(); + private static LinkedList<Entry> killqueue = new LinkedList<Entry>(); /** * Return the hostname for the specified IP address. diff --git a/libjava/classpath/java/net/ServerSocket.java b/libjava/classpath/java/net/ServerSocket.java index d5f2a17..9cefd29 100644 --- a/libjava/classpath/java/net/ServerSocket.java +++ b/libjava/classpath/java/net/ServerSocket.java @@ -85,9 +85,7 @@ public class ServerSocket * This constructor is only used by java.nio. */ - // FIXME: Workaround a bug in gcj. - //ServerSocket (PlainSocketImpl impl) throws IOException - ServerSocket(SocketImpl impl) throws IOException + ServerSocket(PlainSocketImpl impl) throws IOException { if (impl == null) throw new NullPointerException("impl may not be null"); @@ -101,8 +99,6 @@ public class ServerSocket * This method is only used by java.nio. */ - // FIXME: Workaround a bug in gcj. - //PlainSocketImpl getImpl() SocketImpl getImpl() { return impl; @@ -390,6 +386,7 @@ public class ServerSocket impl.accept(socket.impl); socket.bound = true; + socket.implCreated = true; SecurityManager sm = System.getSecurityManager(); if (sm != null) diff --git a/libjava/classpath/java/net/Socket.java b/libjava/classpath/java/net/Socket.java index f4f25fe..6480527 100644 --- a/libjava/classpath/java/net/Socket.java +++ b/libjava/classpath/java/net/Socket.java @@ -1,5 +1,5 @@ /* Socket.java -- Client socket implementation - Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2006 + Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -83,6 +83,12 @@ public class Socket SocketImpl impl; /** + * True if impl.create() has been called. + */ + // package-private because ServerSocket.implAccept() needs to access it. + boolean implCreated; + + /** * True if the socket is bound. * Package private so it can be set from ServerSocket when accept is called. */ @@ -326,11 +332,23 @@ public class Socket private SocketImpl getImpl() throws SocketException { + if (! implCreated) + { + try + { + impl.create(true); + } + catch (IOException x) + { + throw (SocketException) new SocketException().initCause(x); + } + implCreated = true; + } return impl; } /** - * Binds the socket to the givent local address/port + * Binds the socket to the given local address/port * * @param bindpoint The address/port to bind to * @@ -359,7 +377,6 @@ public class Socket // bind to address/port try { - getImpl().create(true); getImpl().bind(tmp.getAddress(), tmp.getPort()); bound = true; } diff --git a/libjava/classpath/java/net/URI.java b/libjava/classpath/java/net/URI.java index 689843c..43b10fc 100644 --- a/libjava/classpath/java/net/URI.java +++ b/libjava/classpath/java/net/URI.java @@ -693,7 +693,7 @@ public final class URI String portStr = getURIGroup(matcher, AUTHORITY_PORT_GROUP); - if (portStr != null) + if (portStr != null && ! portStr.isEmpty()) try { port = Integer.parseInt(portStr); diff --git a/libjava/classpath/java/net/URL.java b/libjava/classpath/java/net/URL.java index 8f72d06..16a606f 100644 --- a/libjava/classpath/java/net/URL.java +++ b/libjava/classpath/java/net/URL.java @@ -190,7 +190,8 @@ public final class URL implements Serializable * This a table where we cache protocol handlers to avoid the overhead * of looking them up each time. */ - private static HashMap ph_cache = new HashMap(); + private static HashMap<String, URLStreamHandler> ph_cache + = new HashMap<String, URLStreamHandler>(); /** * Whether or not to cache protocol handlers. @@ -901,7 +902,7 @@ public final class URL implements Serializable // First, see if a protocol handler is in our cache. if (cache_handlers) { - if ((ph = (URLStreamHandler) ph_cache.get(protocol)) != null) + if ((ph = ph_cache.get(protocol)) != null) return ph; } @@ -934,9 +935,9 @@ public final class URL implements Serializable // Cache the systemClassLoader if (systemClassLoader == null) { - systemClassLoader = (ClassLoader) AccessController.doPrivileged - (new PrivilegedAction() { - public Object run() + systemClassLoader = AccessController.doPrivileged + (new PrivilegedAction<ClassLoader>() { + public ClassLoader run() { return ClassLoader.getSystemClassLoader(); } diff --git a/libjava/classpath/java/net/URLClassLoader.java b/libjava/classpath/java/net/URLClassLoader.java index 7e2353a..6df2818 100644 --- a/libjava/classpath/java/net/URLClassLoader.java +++ b/libjava/classpath/java/net/URLClassLoader.java @@ -145,7 +145,7 @@ public class URLClassLoader extends SecureClassLoader // Instance variables /** Locations to load classes from */ - private final Vector urls = new Vector(); + private final Vector<URL> urls = new Vector<URL>(); /** * Store pre-parsed information for each url into this vector: each @@ -153,7 +153,7 @@ public class URLClassLoader extends SecureClassLoader * attribute which adds to the URLs that will be searched, but this * does not add to the list of urls. */ - private final Vector urlinfos = new Vector(); + private final Vector<URLLoader> urlinfos = new Vector<URLLoader>(); /** Factory used to get the protocol handlers of the URLs */ private final URLStreamHandlerFactory factory; @@ -301,7 +301,6 @@ public class URLClassLoader extends SecureClassLoader if ("file".equals (protocol)) { File dir = new File(file); - URL absUrl; try { absoluteURL = dir.getCanonicalFile().toURL(); @@ -329,12 +328,12 @@ public class URLClassLoader extends SecureClassLoader // First see if we can find a handler with the correct name. try { - Class handler = Class.forName(URL_LOADER_PREFIX + protocol); - Class[] argTypes = new Class[] { URLClassLoader.class, - URLStreamHandlerCache.class, - URLStreamHandlerFactory.class, - URL.class, - URL.class }; + Class<?> handler = Class.forName(URL_LOADER_PREFIX + protocol); + Class<?>[] argTypes = new Class<?>[] { URLClassLoader.class, + URLStreamHandlerCache.class, + URLStreamHandlerFactory.class, + URL.class, + URL.class }; Constructor k = handler.getDeclaredConstructor(argTypes); loader = (URLLoader) k.newInstance(new Object[] { this, @@ -395,7 +394,7 @@ public class URLClassLoader extends SecureClassLoader } urlinfos.add(loader); - ArrayList extra = loader.getClassPath(); + ArrayList<URLLoader> extra = loader.getClassPath(); if (extra != null) urlinfos.addAll(extra); } @@ -602,10 +601,10 @@ public class URLClassLoader extends SecureClassLoader Class result = null; if (sm != null && securityContext != null) { - result = (Class)AccessController.doPrivileged - (new PrivilegedAction() + result = AccessController.doPrivileged + (new PrivilegedAction<Class>() { - public Object run() + public Class run() { return defineClass(className, classData, 0, classData.length, @@ -848,9 +847,9 @@ public class URLClassLoader extends SecureClassLoader + securityContext); URLClassLoader loader = - (URLClassLoader) AccessController.doPrivileged(new PrivilegedAction() + AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>() { - public Object run() + public URLClassLoader run() { return new URLClassLoader(parent, (AccessControlContext) securityContext); diff --git a/libjava/classpath/java/net/class-dependencies.conf b/libjava/classpath/java/net/class-dependencies.conf deleted file mode 100644 index 8b130f5..0000000 --- a/libjava/classpath/java/net/class-dependencies.conf +++ /dev/null @@ -1,122 +0,0 @@ -# This property file contains dependencies of classes, methods, and -# field on other methods or classes. -# -# Syntax: -# -# <used>: <needed 1> [... <needed N>] -# -# means that when <used> is included, <needed 1> (... <needed N>) must -# be included as well. -# -# <needed X> and <used> are of the form -# -# <class.methodOrField(signature)> -# -# or just -# -# <class> -# -# Within dependencies, variables can be used. A variable is defined as -# follows: -# -# {variable}: value1 value2 ... value<n> -# -# variables can be used on the right side of dependencies as follows: -# -# <used>: com.bla.blu.{variable}.Class.m()V -# -# The use of the variable will expand to <n> dependencies of the form -# -# <used>: com.bla.blu.value1.Class.m()V -# <used>: com.bla.blu.value2.Class.m()V -# ... -# <used>: com.bla.blu.value<n>.Class.m()V -# -# Variables can be redefined when building a system to select the -# required support for features like encodings, protocols, etc. -# -# Hints: -# -# - For methods and fields, the signature is mandatory. For -# specification, please see the Java Virtual Machine Specification by -# SUN. Unlike in the spec, field signatures (types) are in brackets. -# -# - Package names must be separated by '/' (and not '.'). E.g., -# java/lang/Class (this is necessary, because the '.' is used to -# separate method or field names from classes) -# -# - In case <needed> refers to a class, only the class itself will be -# included in the resulting binary, NOT necessarily all its methods -# and fields. If you want to refer to all methods and fields, you can -# write class.* as an abbreviation. -# -# - Abbreviations for packages are also possible: my/package/* means all -# methods and fields of all classes in my/package. -# -# - A line with a trailing '\' continues in the next line. - -java/net/InetAddress: \ - java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \ - java/lang/InternalError.<init>(Ljava/lang/String;)V \ - java/net/UnknownHostException.<init>(Ljava/lang/String;)V - -java/net/DatagramSocketImpl: \ - java/net/DatagramSocketImpl.fd(Ljava/io/FileDescriptor;) \ - java/net/DatagramSocketImpl.localPort(I) - -java/net/PlainDatagramSocketImpl: \ - java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \ - java/lang/InternalError.<init>(Ljava/lang/String;)V \ - java/io/IOException.<init>(Ljava/lang/String;)V \ - java/io/FileDescriptor.<init>()V \ - java/lang/Boolean.<init>(Z)V \ - java/lang/Integer.<init>(I)V \ - java/net/InetAddress.getByName(Ljava/lang/String;)Ljava/net/InetAddress; \ - java/net/InetAddress.getAddress()[B \ - java/lang/Boolean.booleanValue()Z \ - java/lang/Integer.intValue()I \ - java/net/SocketException.<init>(Ljava/lang/String;)V \ - java/net/DatagramPacket.getData()[B \ - java/net/SocketImpl.address(Ljava/net/InetAddress;) \ - java/net/PlainSocketImpl.native_fd(I) \ - java/net/SocketImpl.fd(Ljava/io/FileDescriptor;) \ - java/net/SocketImpl.address(Ljava/net/InetAddress;) \ - java/net/PlainDatagramSocketImpl.native_fd(I) \ - java/net/SocketImpl.localport(I) \ - java/net/SocketImpl.port(I) - -java/net/PlainSocketImpl: \ - java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \ - java/lang/InternalError.<init>(Ljava/lang/String;)V \ - java/io/IOException.<init>(Ljava/lang/String;)V \ - java/io/FileDescriptor.<init>()V \ - java/lang/Boolean.<init>(Z)V \ - java/lang/Integer.<init>(I)V \ - java/net/InetAddress.getByName(Ljava/lang/String;)Ljava/net/InetAddress; \ - java/net/InetAddress.getAddress()[B \ - java/lang/Boolean.booleanValue()Z \ - java/lang/Integer.intValue()I \ - java/net/SocketException.<init>(Ljava/lang/String;)V \ - java/net/DatagramPacket.getData()[B \ - java/net/SocketImpl.address(Ljava/net/InetAddress;) \ - java/net/PlainSocketImpl.native_fd(I) \ - java/net/SocketImpl.fd(Ljava/io/FileDescriptor;) \ - java/net/SocketImpl.address(Ljava/net/InetAddress;) \ - java/net/PlainDatagramSocketImpl.native_fd(I) \ - java/net/SocketImpl.localport(I) \ - java/net/SocketImpl.port(I) - -# All protocols supported are loaded via URL.getURLStreamHandler from -# class gnu.java.net.protocol.<protocol>.Handler. -# -# This introduces a dependency for all protocols. To allow an easy selection -# and addition of protocols, the library variable {protocols} can be set to -# the set of supported protocols. -# -{protocols}: http file jar - -java/net/URL.getURLStreamHandler(Ljava/lang/String;)Ljava/net/URLStreamHandler;: \ - gnu/java/net/protocol/{protocols}/Handler.* \ - com/aicas/java/net/protocol/rom/Handler.* - -# end of file |