|
From: <ls...@us...> - 2007-01-07 12:37:20
|
Revision: 3017
http://jnode.svn.sourceforge.net/jnode/?rev=3017&view=rev
Author: lsantha
Date: 2007-01-07 04:37:19 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/gnu/gnu/java/lang/management/MemoryPoolMXBeanImpl.java
trunk/core/src/classpath/gnu/gnu/java/lang/management/OperatingSystemMXBeanImpl.java
trunk/core/src/classpath/gnu/gnu/java/lang/management/ThreadMXBeanImpl.java
trunk/core/src/classpath/gnu/gnu/java/net/DefaultContentHandlerFactory.java
trunk/core/src/classpath/gnu/gnu/java/net/GetLocalHostAction.java
trunk/core/src/classpath/gnu/gnu/java/net/HeaderFieldHelper.java
trunk/core/src/classpath/gnu/gnu/java/net/IndexListParser.java
trunk/core/src/classpath/gnu/gnu/java/net/loader/JarURLLoader.java
trunk/core/src/classpath/gnu/gnu/java/net/loader/URLLoader.java
trunk/core/src/classpath/gnu/gnu/java/net/loader/URLStreamHandlerCache.java
trunk/core/src/classpath/gnu/gnu/java/net/protocol/ftp/FTPConnection.java
trunk/core/src/classpath/gnu/gnu/java/net/protocol/ftp/FTPURLConnection.java
trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/ChunkedInputStream.java
trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/HTTPConnection.java
trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/HTTPURLConnection.java
trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/Headers.java
trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/Request.java
trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/SimpleCookieManager.java
trunk/core/src/classpath/gnu/gnu/java/net/protocol/jar/Connection.java
trunk/core/src/classpath/gnu/gnu/java/net/protocol/jar/Handler.java
trunk/core/src/classpath/gnu/gnu/java/security/action/GetPropertyAction.java
trunk/core/src/classpath/gnu/gnu/java/security/action/GetSecurityPropertyAction.java
Added Paths:
-----------
trunk/core/src/classpath/gnu/gnu/java/math/Fixed.java
trunk/core/src/classpath/gnu/gnu/java/net/DefaultProxySelector.java
trunk/core/src/classpath/gnu/gnu/java/security/Requires.java
trunk/core/src/classpath/gnu/gnu/java/security/util/ByteBufferOutputStream.java
trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/GeneralName.java
trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/GeneralSubtree.java
trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/NameConstraints.java
Modified: trunk/core/src/classpath/gnu/gnu/java/lang/management/MemoryPoolMXBeanImpl.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/lang/management/MemoryPoolMXBeanImpl.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/management/MemoryPoolMXBeanImpl.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -41,6 +41,7 @@
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryUsage;
+import java.lang.management.MemoryType;
import javax.management.NotCompliantMBeanException;
@@ -133,9 +134,9 @@
return null;
}
- public String getType()
+ public MemoryType getType()
{
- return VMMemoryPoolMXBeanImpl.getType(name);
+ return null;
}
public MemoryUsage getUsage()
Modified: trunk/core/src/classpath/gnu/gnu/java/lang/management/OperatingSystemMXBeanImpl.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/lang/management/OperatingSystemMXBeanImpl.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/management/OperatingSystemMXBeanImpl.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -86,5 +86,10 @@
{
return System.getProperty("os.version");
}
-
+
+
+ public double getSystemLoadAverage() {
+ //todo implement
+ throw new UnsupportedOperationException();
+ }
}
Modified: trunk/core/src/classpath/gnu/gnu/java/lang/management/ThreadMXBeanImpl.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/lang/management/ThreadMXBeanImpl.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/management/ThreadMXBeanImpl.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -287,5 +287,30 @@
"supported.");
}
+
+ public ThreadInfo[] dumpAllThreads(boolean lockedMonitors, boolean lockedSynchronizers) {
+ //todo implement
+ throw new UnsupportedOperationException();
+ }
+
+ public long[] findDeadlockedThreads() {
+ //todo implement
+ throw new UnsupportedOperationException();
+ }
+
+ public ThreadInfo[] getThreadInfo(long[] ids, boolean lockedMonitors, boolean lockedSynchronizers) {
+ //todo implement
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isObjectMonitorUsageSupported() {
+ //todo implement
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSynchronizerUsageSupported() {
+ //todo implement
+ throw new UnsupportedOperationException();
+ }
}
Added: trunk/core/src/classpath/gnu/gnu/java/math/Fixed.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/math/Fixed.java (rev 0)
+++ trunk/core/src/classpath/gnu/gnu/java/math/Fixed.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -0,0 +1,207 @@
+/* Fixed.java -- Utility methods for fixed point arithmetics
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.math;
+
+/**
+ * Utility methods for fixed point arithmetics.
+ */
+public final class Fixed
+{
+
+ /**
+ * Private constructor to avoid instantiation.
+ */
+ private Fixed()
+ {
+ // Forbidden constructor.
+ }
+
+ /**
+ * Divides two fixed point values with <code>n</code> digits.
+ *
+ * @param n the number of digits
+ * @param a the first operand as fixed point value
+ * @param b the second operand as fixed point value
+ *
+ * @return <code>a / b</code> as fixed point value
+ */
+ public static int div(int n, int a, int b)
+ {
+ return (int) ((((long) a) << n) / b);
+ }
+
+ /**
+ * Multiplies two fixed point values with <code>n</code> digits.
+ *
+ * @param n the number of digits
+ * @param a the first operand as fixed point value
+ * @param b the second operand as fixed point value
+ *
+ * @return <code>a * b</code> as fixed point value
+ */
+ public static int mul(int n, int a, int b)
+ {
+ return (int) ((((long) a) * b) >> n);
+ }
+
+ /**
+ * Returns the ceiling value of a fixed point value <code>a</code> with
+ * the <code>n</code> digits.
+ *
+ * @param n the number of digits
+ * @param a the fixed point value
+ *
+ * @return <code>ceil(a)</code> as fixed point value
+ */
+ public static int ceil(int n, int a)
+ {
+ return (a + (1 << n - 1)) & -(1 << n);
+ }
+
+ /**
+ * Returns the floor value of a fixed point value <code>a</code> with
+ * <code>n</code> digits.
+ *
+ * @param n the number of digits
+ * @param a the fixed point value
+ *
+ * @return <code>floor(a)</code> as fixed point value
+ */
+ public static int floor(int n, int a)
+ {
+ return a & -(1 << n);
+ }
+
+ /**
+ * Returns the round value of a fixed point value <code>a</code> with
+ * the <code>n</code> digits.
+ *
+ * @param n the number of digits
+ * @param a the fixed point value
+ *
+ * @return <code>round(a)</code> as fixed point value
+ */
+ public static int round(int n, int a)
+ {
+ return (a + (1 << (n - 1))) & -(1 << n);
+ }
+
+ /**
+ * Returns the fixed point value <code>a</code> with <code>n</code> digits
+ * as float.
+ *
+ * @param n the number of digits
+ * @param a the fixed point value
+ *
+ * @return the float value of <code>a</code>
+ */
+ public static float floatValue(int n, int a)
+ {
+ return ((float) a) / (1 << n);
+ }
+
+ /**
+ * Returns the fixed point value <code>a</code> with <code>n</code> digits
+ * as double.
+ *
+ * @param n the number of digits
+ * @param a the fixed point value
+ *
+ * @return the double value of <code>a</code>
+ */
+ public static double doubleValue(int n, int a)
+ {
+ return ((double) a) / (1 << n);
+ }
+
+ /**
+ * Returns the fixed point value that corresponds to the specified float
+ * value <code>a</code> with <code>n</code> digits.
+ *
+ * @param n the number of digits
+ * @param a the float value
+ *
+ * @return the fixed point value
+ */
+ public static int fixedValue(int n, float a)
+ {
+ return (int) (a * (1 << n));
+ }
+
+ /**
+ * Returns the fixed point value that corresponds to the specified double
+ * value <code>a</code> with <code>n</code> digits.
+ *
+ * @param n the number of digits
+ * @param a the double value
+ *
+ * @return the fixed point value
+ */
+ public static int fixedValue(int n, double a)
+ {
+ return (int) (a * (1 << n));
+ }
+
+ /**
+ * Returns the integer value of the specified fixed point value
+ * <code>a</code>. This simply cuts of the digits (== floor(a)).
+ *
+ * @param n the number of digits
+ * @param a the fixed point value
+ *
+ * @return the integer value
+ */
+ public static int intValue(int n, int a)
+ {
+ return a >> n;
+ }
+
+ /**
+ * Returns a fixed point decimal as rounded integer value.
+ *
+ * @param n the number of digits
+ * @param a the fixed point number
+ *
+ * @return the fixed point decimal as rounded integer value
+ */
+ public static int roundIntValue(int n, int a)
+ {
+ return (a + (1 << (n - 1))) >> n;
+ }
+}
Modified: trunk/core/src/classpath/gnu/gnu/java/net/DefaultContentHandlerFactory.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/DefaultContentHandlerFactory.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/DefaultContentHandlerFactory.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -81,8 +81,8 @@
"image/x-xpixmap"
};
- private static HashSet imageTypes
- = new HashSet(Arrays.asList(known_image_types));
+ private static HashSet<String> imageTypes
+ = new HashSet<String>(Arrays.asList(known_image_types));
public ContentHandler createContentHandler(String mimeType)
{
Added: trunk/core/src/classpath/gnu/gnu/java/net/DefaultProxySelector.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/DefaultProxySelector.java (rev 0)
+++ trunk/core/src/classpath/gnu/gnu/java/net/DefaultProxySelector.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -0,0 +1,80 @@
+/* DefaultProxySelector.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.net;
+
+import java.io.IOException;
+import java.net.Proxy;
+import java.net.ProxySelector;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+public final class DefaultProxySelector
+ extends ProxySelector
+{
+ private static final List<Proxy> proxies = new ArrayList<Proxy>();
+
+ static
+ {
+ // The default proxy selector supports only direct connections.
+ proxies.add(Proxy.NO_PROXY);
+ }
+
+ public DefaultProxySelector()
+ {
+ // Do nothing by default.
+ }
+
+ public void connectFailed(URI uri, SocketAddress sa, IOException ioe)
+ {
+ if (uri == null || sa == null || ioe == null)
+ throw new IllegalArgumentException();
+
+ // Do nothing by default.
+ }
+
+ public List<Proxy> select(URI uri)
+ {
+ if (uri == null)
+ throw new IllegalArgumentException();
+
+ return proxies;
+ }
+}
Modified: trunk/core/src/classpath/gnu/gnu/java/net/GetLocalHostAction.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/GetLocalHostAction.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/GetLocalHostAction.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -48,9 +48,9 @@
* @author Chris Burdess (do...@gn...)
*/
public class GetLocalHostAction
- implements PrivilegedAction
+ implements PrivilegedAction<InetAddress>
{
- public Object run()
+ public InetAddress run()
{
try
{
Modified: trunk/core/src/classpath/gnu/gnu/java/net/HeaderFieldHelper.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/HeaderFieldHelper.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/HeaderFieldHelper.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -49,8 +49,8 @@
*/
public class HeaderFieldHelper
{
- private Vector headerFieldKeys;
- private Vector headerFieldValues;
+ private Vector<String> headerFieldKeys;
+ private Vector<String> headerFieldValues;
public HeaderFieldHelper()
{
@@ -59,8 +59,8 @@
public HeaderFieldHelper (int size)
{
- headerFieldKeys = new Vector (size);
- headerFieldValues = new Vector (size);
+ headerFieldKeys = new Vector<String> (size);
+ headerFieldValues = new Vector<String> (size);
}
public void addHeaderField (String key, String value)
@@ -75,7 +75,7 @@
try
{
- key = (String) headerFieldKeys.elementAt (index);
+ key = headerFieldKeys.elementAt (index);
}
catch (ArrayIndexOutOfBoundsException e)
{
@@ -90,7 +90,7 @@
try
{
- value = (String) headerFieldValues.elementAt (index);
+ value = headerFieldValues.elementAt (index);
}
catch (ArrayIndexOutOfBoundsException e)
{
@@ -105,8 +105,7 @@
try
{
- value = (String) headerFieldValues.elementAt
- (headerFieldKeys.indexOf(key));
+ value = headerFieldValues.elementAt(headerFieldKeys.indexOf(key));
}
catch (ArrayIndexOutOfBoundsException e)
{
@@ -115,9 +114,9 @@
return value;
}
- public Map getHeaderFields()
+ public Map<String, String> getHeaderFields()
{
- HashMap headers = new HashMap();
+ HashMap<String, String> headers = new HashMap<String, String>();
int max = headerFieldKeys.size();
for (int index = 0; index < max; index++)
Modified: trunk/core/src/classpath/gnu/gnu/java/net/IndexListParser.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/IndexListParser.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/IndexListParser.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -43,6 +43,7 @@
import java.net.URL;
import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.Set;
import java.util.jar.JarFile;
/**
@@ -70,7 +71,8 @@
double versionNumber;
// Map each jar to the prefixes defined for the jar.
// This is intentionally kept in insertion order.
- LinkedHashMap prefixes = new LinkedHashMap();
+ LinkedHashMap<URL, Set<String>> prefixes
+ = new LinkedHashMap<URL, Set<String>>();
/**
* Parses the given jarfile's INDEX.LIST file if it exists.
@@ -107,7 +109,7 @@
while ((line = br.readLine()) != null)
{
URL jarURL = new URL(baseURL, line);
- HashSet values = new HashSet();
+ HashSet<String> values = new HashSet<String>();
// Read the names in the section.
while ((line = br.readLine()) != null)
@@ -174,7 +176,7 @@
*
* @return an map of all the headers, or null if no INDEX.LIST was found
*/
- public LinkedHashMap getHeaders()
+ public LinkedHashMap<URL, Set<String>> getHeaders()
{
return prefixes;
}
Modified: trunk/core/src/classpath/gnu/gnu/java/net/loader/JarURLLoader.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/loader/JarURLLoader.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/loader/JarURLLoader.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -32,7 +32,7 @@
// Base jar: url for all resources loaded from jar.
final URL baseJarURL;
// The "Class-Path" attribute of this Jar's manifest.
- ArrayList classPath;
+ ArrayList<URLLoader> classPath;
// If not null, a mapping from INDEX.LIST for this jar only.
// This is a set of all prefixes and top-level files that
// ought to be available in this jar.
@@ -90,20 +90,20 @@
IndexListParser parser = new IndexListParser(jarfile, baseJarURL,
baseURL);
- LinkedHashMap indexMap = parser.getHeaders();
+ LinkedHashMap<URL, Set<String>> indexMap = parser.getHeaders();
if (indexMap != null)
{
// Note that the index also computes
// the resulting Class-Path -- there are jars out there
// where the index lists some required jars which do
// not appear in the Class-Path attribute in the manifest.
- this.classPath = new ArrayList();
- Iterator it = indexMap.entrySet().iterator();
+ this.classPath = new ArrayList<URLLoader>();
+ Iterator<Map.Entry<URL, Set<String>>> it = indexMap.entrySet().iterator();
while (it.hasNext())
{
- Map.Entry entry = (Map.Entry) it.next();
- URL subURL = (URL) entry.getKey();
- Set prefixes = (Set) entry.getValue();
+ Map.Entry<URL, Set<String>> entry = it.next();
+ URL subURL = entry.getKey();
+ Set<String> prefixes = entry.getValue();
if (subURL.equals(baseURL))
this.indexSet = prefixes;
else
@@ -127,7 +127,7 @@
= attributes.getValue(Attributes.Name.CLASS_PATH))
!= null))
{
- this.classPath = new ArrayList();
+ this.classPath = new ArrayList<URLLoader>();
StringTokenizer st = new StringTokenizer(classPathString, " ");
while (st.hasMoreElements ())
{
@@ -144,7 +144,7 @@
cache, factory,
subURL, subURL);
this.classPath.add(subLoader);
- ArrayList extra = subLoader.getClassPath();
+ ArrayList<URLLoader> extra = subLoader.getClassPath();
if (extra != null)
this.classPath.addAll(extra);
}
@@ -208,7 +208,7 @@
}
}
- public ArrayList getClassPath()
+ public ArrayList<URLLoader> getClassPath()
{
return classPath;
}
Modified: trunk/core/src/classpath/gnu/gnu/java/net/loader/URLLoader.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/loader/URLLoader.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/loader/URLLoader.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -140,7 +140,7 @@
* Return a list of new URLLoader objects representing any
* class path entries added by this container.
*/
- public ArrayList getClassPath()
+ public ArrayList<URLLoader> getClassPath()
{
return null;
}
Modified: trunk/core/src/classpath/gnu/gnu/java/net/loader/URLStreamHandlerCache.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/loader/URLStreamHandlerCache.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/loader/URLStreamHandlerCache.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -51,7 +51,8 @@
* private protocol handler cache (also a HashMap), so we can avoid
* creating handlers each time the same protocol comes.
*/
- private HashMap factoryCache = new HashMap(5);
+ private HashMap<URLStreamHandlerFactory, HashMap<String, URLStreamHandler>> factoryCache
+ = new HashMap<URLStreamHandlerFactory, HashMap<String, URLStreamHandler>>(5);
public URLStreamHandlerCache()
{
@@ -62,7 +63,7 @@
// Since we only support three protocols so far, 5 is enough
// for cache initial size.
if (factory != null && factoryCache.get(factory) == null)
- factoryCache.put(factory, new HashMap(5));
+ factoryCache.put(factory, new HashMap<String, URLStreamHandler>(5));
}
public synchronized URLStreamHandler get(URLStreamHandlerFactory factory,
@@ -71,8 +72,8 @@
if (factory == null)
return null;
// Check if there're handler for the same protocol in cache.
- HashMap cache = (HashMap) factoryCache.get(factory);
- URLStreamHandler handler = (URLStreamHandler) cache.get(protocol);
+ HashMap<String, URLStreamHandler> cache = factoryCache.get(factory);
+ URLStreamHandler handler = cache.get(protocol);
if (handler == null)
{
// Add it to cache.
Modified: trunk/core/src/classpath/gnu/gnu/java/net/protocol/ftp/FTPConnection.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/protocol/ftp/FTPConnection.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/protocol/ftp/FTPConnection.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -1139,7 +1139,7 @@
* @param pathname the directory pathname, or null
* @return a list of filenames(strings)
*/
- public List nameList(String pathname)
+ public List<String> nameList(String pathname)
throws IOException
{
if (dtp == null || transferMode == MODE_STREAM)
@@ -1164,7 +1164,7 @@
in = new BufferedInputStream(in);
in = new CRLFInputStream(in); // TODO ensure that TYPE is correct
LineInputStream li = new LineInputStream(in);
- List ret = new ArrayList();
+ ArrayList<String> ret = new ArrayList<String>();
for (String line = li.readLine();
line != null;
line = li.readLine())
Modified: trunk/core/src/classpath/gnu/gnu/java/net/protocol/ftp/FTPURLConnection.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/protocol/ftp/FTPURLConnection.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/protocol/ftp/FTPURLConnection.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -50,7 +50,9 @@
import java.net.URL;
import java.net.URLConnection;
import java.security.AccessController;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -112,7 +114,7 @@
{
username = "anonymous";
GetLocalHostAction a = new GetLocalHostAction();
- InetAddress localhost =(InetAddress) AccessController.doPrivileged(a);
+ InetAddress localhost = AccessController.doPrivileged(a);
password = SystemProperties.getProperty("user.name") + "@" +
((localhost == null) ? "localhost" : localhost.getHostName());
}
@@ -232,9 +234,9 @@
return null;
}
- public Map getRequestProperties()
+ public Map<String, List<String>> getRequestProperties()
{
- Map map = new HashMap();
+ Map<String, List<String>> map = new HashMap<String, List<String>>();
addRequestPropertyValue(map, "passive");
addRequestPropertyValue(map, "representationType");
addRequestPropertyValue(map, "fileStructure");
@@ -242,10 +244,13 @@
return map;
}
- private void addRequestPropertyValue(Map map, String key)
+ private void addRequestPropertyValue(Map<String, List<String>> map,
+ String key)
{
String value = getRequestProperty(key);
- map.put(key, value);
+ ArrayList<String> l = new ArrayList<String>();
+ l.add(value);
+ map.put(key, l);
}
public void setRequestProperty(String key, String value)
Modified: trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/ChunkedInputStream.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/ChunkedInputStream.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/ChunkedInputStream.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -58,10 +58,6 @@
public class ChunkedInputStream
extends InputStream
{
-
- private static final byte CR = 0x0d;
- private static final byte LF = 0x0a;
-
Headers headers;
/** The underlying stream. */
Modified: trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/HTTPConnection.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/HTTPConnection.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/HTTPConnection.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -48,6 +48,7 @@
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.net.SocketException;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -128,7 +129,7 @@
*/
protected int minorVersion;
- private final List handshakeCompletedListeners;
+ private final List<HandshakeCompletedListener> handshakeCompletedListeners;
/**
* The socket this connection communicates on.
@@ -153,7 +154,7 @@
/**
* Nonce values seen by this connection.
*/
- private Map nonceCounts;
+ private Map<String, Integer> nonceCounts;
/**
* The cookie manager for this connection.
@@ -227,17 +228,24 @@
* @param secure whether to use a secure connection
* @param connectionTimeout the connection timeout
* @param timeout the socket read timeout
+ *
+ * @throws IllegalArgumentException if either connectionTimeout or
+ * timeout less than zero.
*/
public HTTPConnection(String hostname, int port, boolean secure,
int connectionTimeout, int timeout)
{
+ if (connectionTimeout < 0 || timeout < 0)
+ throw new IllegalArgumentException();
+
this.hostname = hostname;
this.port = port;
this.secure = secure;
this.connectionTimeout = connectionTimeout;
this.timeout = timeout;
majorVersion = minorVersion = 1;
- handshakeCompletedListeners = new ArrayList(2);
+ handshakeCompletedListeners
+ = new ArrayList<HandshakeCompletedListener>(2);
}
/**
@@ -350,7 +358,8 @@
/**
* The pool
*/
- final LinkedList connectionPool = new LinkedList();
+ final LinkedList<HTTPConnection> connectionPool
+ = new LinkedList<HTTPConnection>();
/**
* Maximum size of the pool.
@@ -471,14 +480,32 @@
{
String ttl =
SystemProperties.getProperty("classpath.net.http.keepAliveTTL");
- connectionTTL = (ttl != null && ttl.length() > 0) ?
- 1000 * Math.max(1, Integer.parseInt(ttl)) : 10000;
+ connectionTTL = 10000;
+ if (ttl != null && ttl.length() > 0)
+ try
+ {
+ int v = 1000 * Integer.parseInt(ttl);
+ if (v >= 0)
+ connectionTTL = v;
+ }
+ catch (NumberFormatException _)
+ {
+ // Ignore.
+ }
String mc = SystemProperties.getProperty("http.maxConnections");
- maxConnections = (mc != null && mc.length() > 0) ?
- Math.max(Integer.parseInt(mc), 1) : 5;
- if (maxConnections < 1)
- maxConnections = 1;
+ maxConnections = 5;
+ if (mc != null && mc.length() > 0)
+ try
+ {
+ int v = Integer.parseInt(mc);
+ if (v > 0)
+ maxConnections = v;
+ }
+ catch (NumberFormatException _)
+ {
+ // Ignore.
+ }
HTTPConnection c = null;
@@ -490,12 +517,23 @@
{
c = cc;
it.remove();
+ // Update the timeout.
+ if (c.socket != null)
+ try
+ {
+ c.socket.setSoTimeout(timeout);
+ }
+ catch (SocketException _)
+ {
+ // Ignore.
+ }
break;
}
}
if (c == null)
{
- c = new HTTPConnection(host, port, secure, connectionTimeout, timeout);
+ c = new HTTPConnection(host, port, secure,
+ connectionTimeout, timeout);
c.setPool(this);
}
return c;
@@ -821,7 +859,7 @@
{
return 0;
}
- return((Integer) nonceCounts.get(nonce)).intValue();
+ return nonceCounts.get(nonce).intValue();
}
/**
@@ -832,7 +870,7 @@
int current = getNonceCount(nonce);
if (nonceCounts == null)
{
- nonceCounts = new HashMap();
+ nonceCounts = new HashMap<String, Integer>();
}
nonceCounts.put(nonce, new Integer(current + 1));
}
Modified: trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/HTTPURLConnection.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/HTTPURLConnection.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/HTTPURLConnection.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -50,11 +50,11 @@
import java.security.cert.Certificate;
import java.util.Collections;
import java.util.Date;
+import java.util.List;
import java.util.Map;
import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;
-import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSocketFactory;
@@ -75,7 +75,7 @@
// These are package private for use in anonymous inner classes.
String proxyHostname;
- int proxyPort;
+ int proxyPort = -1;
String agent;
boolean keepAlive;
@@ -99,18 +99,21 @@
{
super(url);
requestHeaders = new Headers();
- proxyHostname = SystemProperties.getProperty("http.proxyHost");
- if (proxyHostname != null && proxyHostname.length() > 0)
+ String proxy = SystemProperties.getProperty("http.proxyHost");
+ if (proxy != null && proxy.length() > 0)
{
String port = SystemProperties.getProperty("http.proxyPort");
if (port != null && port.length() > 0)
{
+ try
+ {
proxyPort = Integer.parseInt(port);
+ proxyHostname = proxy;
}
- else
+ catch (NumberFormatException _)
{
- proxyHostname = null;
- proxyPort = -1;
+ // Ignore.
+ }
}
}
agent = SystemProperties.getProperty("http.agent");
@@ -149,6 +152,14 @@
final Credentials creds = (username == null) ? null :
new Credentials (username, password);
+ if ("POST".equals(method))
+ {
+ String contentType = requestHeaders.getValue("Content-Type");
+ if (null == contentType)
+ requestHeaders.addValue("Content-Type",
+ "application/x-www-form-urlencoded");
+ }
+
boolean retry;
do
{
@@ -159,7 +170,8 @@
if (secure)
{
SSLSocketFactory factory = getSSLSocketFactory();
- HostnameVerifier verifier = getHostnameVerifier();
+ // FIXME: use the verifier
+ // HostnameVerifier verifier = getHostnameVerifier();
if (factory != null)
{
connection.setSSLSocketFactory(factory);
@@ -414,12 +426,12 @@
return requestHeaders.getValue(key);
}
- public Map getRequestProperties()
+ public Map<String, List<String>> getRequestProperties()
{
if (connected)
throw new IllegalStateException("Already connected");
- Map m = requestHeaders.getAsMap();
+ Map<String, List<String>> m = requestHeaders.getAsMap();
return Collections.unmodifiableMap(m);
}
@@ -495,7 +507,7 @@
return errorSink;
}
- public Map getHeaderFields()
+ public Map<String,List<String>> getHeaderFields()
{
if (!connected)
{
@@ -508,7 +520,7 @@
return null;
}
}
- Map m = response.getHeaders().getAsMap();
+ Map<String,List<String>> m = response.getHeaders().getAsMap();
m.put(null, Collections.singletonList(getStatusLine(response)));
return Collections.unmodifiableMap(m);
}
@@ -654,13 +666,13 @@
}
/**
- * Set the connection timeout speed, in milliseconds, or zero if the timeout
+ * Set the read timeout, in milliseconds, or zero if the timeout
* is to be considered infinite.
*
* Overloaded.
*
*/
- public void setConnectTimeout(int timeout)
+ public void setReadTimeout(int timeout)
throws IllegalArgumentException
{
super.setConnectTimeout( timeout );
@@ -668,9 +680,9 @@
return;
try
{
- connection.getSocket().setSoTimeout( timeout );
+ connection.getSocket().setSoTimeout(timeout);
}
- catch(IOException se)
+ catch (IOException se)
{
// Ignore socket exceptions.
}
Modified: trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/Headers.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/Headers.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/Headers.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -42,6 +42,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.lang.Iterable;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.ArrayList;
@@ -49,6 +50,7 @@
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -60,12 +62,13 @@
* @author Chris Burdess (do...@gn...)
* @author David Daney (dd...@av...)
*/
-class Headers
+class Headers implements Iterable<Headers.HeaderElement>
{
/**
* A list of HeaderElements
*/
- private final ArrayList headers = new ArrayList();
+ private final ArrayList<HeaderElement> headers
+ = new ArrayList<HeaderElement>();
/**
* The HTTP dateformat used to parse date header fields.
@@ -102,7 +105,7 @@
*
* @return the Iterator.
*/
- Iterator iterator()
+ public Iterator<HeaderElement> iterator()
{
return headers.iterator();
}
@@ -118,7 +121,7 @@
{
for (int i = headers.size() - 1; i >= 0; i--)
{
- HeaderElement e = (HeaderElement)headers.get(i);
+ HeaderElement e = headers.get(i);
if (e.name.equalsIgnoreCase(header))
{
return e.value;
@@ -219,7 +222,7 @@
{
for (int i = headers.size() - 1; i >= 0; i--)
{
- HeaderElement e = (HeaderElement)headers.get(i);
+ HeaderElement e = headers.get(i);
if (e.name.equalsIgnoreCase(name))
{
e.value = value;
@@ -240,9 +243,9 @@
*/
public void putAll(Headers o)
{
- for (Iterator it = o.iterator(); it.hasNext(); )
+ for (Iterator<HeaderElement> it = o.iterator(); it.hasNext(); )
{
- HeaderElement e = (HeaderElement)it.next();
+ HeaderElement e = it.next();
remove(e.name);
addValue(e.name, e.value);
}
@@ -256,9 +259,9 @@
*/
public void remove(String name)
{
- for (Iterator it = headers.iterator(); it.hasNext(); )
+ for (Iterator<HeaderElement> it = headers.iterator(); it.hasNext(); )
{
- HeaderElement e = (HeaderElement)it.next();
+ HeaderElement e = it.next();
if (e.name.equalsIgnoreCase(name))
it.remove();
}
@@ -358,26 +361,26 @@
*
* @return a Map containing all the headers.
*/
- public Map getAsMap()
+ public Map<String,List<String>> getAsMap()
{
- LinkedHashMap m = new LinkedHashMap();
- for (Iterator it = headers.iterator(); it.hasNext(); )
+ LinkedHashMap<String,List<String>> m = new LinkedHashMap<String,List<String>>();
+ for (Iterator<HeaderElement> it = headers.iterator(); it.hasNext(); )
{
- HeaderElement e = (HeaderElement)it.next();
- ArrayList l = (ArrayList)m.get(e.name);
+ HeaderElement e = it.next();
+ ArrayList<String> l = (ArrayList<String>)m.get(e.name);
if (l == null)
{
- l = new ArrayList(1);
+ l = new ArrayList<String>(1);
l.add(e.value);
m.put(e.name, l);
}
else
l.add(0, e.value);
}
- for (Iterator it = m.entrySet().iterator(); it.hasNext(); )
+ for (Iterator<Map.Entry<String,List<String>>> it = m.entrySet().iterator(); it.hasNext(); )
{
- Map.Entry me = (Map.Entry)it.next();
- ArrayList l = (ArrayList)me.getValue();
+ Map.Entry<String,List<String>> me = it.next();
+ List<String> l = me.getValue();
me.setValue(Collections.unmodifiableList(l));
}
return m;
@@ -397,7 +400,7 @@
if (i >= headers.size() || i < 0)
return null;
- return ((HeaderElement)headers.get(i)).name;
+ return headers.get(i).name;
}
/**
@@ -414,8 +417,6 @@
if (i >= headers.size() || i < 0)
return null;
- return ((HeaderElement)headers.get(i)).value;
+ return headers.get(i).value;
}
-
}
-
Modified: trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/Request.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/Request.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/Request.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -96,7 +96,7 @@
/**
* Map of response header handlers.
*/
- protected Map responseHeaderHandlers;
+ protected Map<String, ResponseHeaderHandler> responseHeaderHandlers;
/**
* The authenticator.
@@ -121,7 +121,7 @@
this.method = method;
this.path = path;
requestHeaders = new Headers();
- responseHeaderHandlers = new HashMap();
+ responseHeaderHandlers = new HashMap<String, ResponseHeaderHandler>();
}
/**
@@ -302,9 +302,8 @@
String line = method + ' ' + requestUri + ' ' + version + CRLF;
out.write(line.getBytes(US_ASCII));
// Request headers
- for (Iterator i = requestHeaders.iterator(); i.hasNext(); )
+ for (Headers.HeaderElement elt : requestHeaders)
{
- Headers.HeaderElement elt = (Headers.HeaderElement)i.next();
line = elt.name + HEADER_SEP + elt.value + CRLF;
out.write(line.getBytes(US_ASCII));
}
@@ -439,9 +438,8 @@
void notifyHeaderHandlers(Headers headers)
{
- for (Iterator i = headers.iterator(); i.hasNext(); )
+ for (Headers.HeaderElement entry : headers)
{
- Headers.HeaderElement entry = (Headers.HeaderElement) i.next();
// Handle Set-Cookie
if ("Set-Cookie".equalsIgnoreCase(entry.name))
handleSetCookie(entry.value);
@@ -461,7 +459,6 @@
throws IOException
{
long contentLength = -1;
- Headers trailer = null;
// Persistent connections are the default in HTTP/1.1
boolean doClose = "close".equalsIgnoreCase(getHeader("Connection")) ||
Modified: trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/SimpleCookieManager.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/SimpleCookieManager.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/protocol/http/SimpleCookieManager.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -1,5 +1,5 @@
/* CookieManager.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,6 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
/**
@@ -59,23 +58,23 @@
* The cookie cache.
* This is a dictionary mapping domains to maps of cookies by name.
*/
- protected Map cookies;
+ protected Map<String, Map<String, Cookie>> cookies;
/**
* Constructor.
*/
public SimpleCookieManager()
{
- cookies = new HashMap();
+ cookies = new HashMap<String, Map<String, Cookie>>();
}
public void setCookie(Cookie cookie)
{
String domain = cookie.getDomain();
- Map map =(Map) cookies.get(domain);
+ Map<String, Cookie> map = cookies.get(domain);
if (map == null)
{
- map = new HashMap();
+ map = new HashMap<String, Cookie>();
cookies.put(domain, map);
}
String name = cookie.getName();
@@ -84,7 +83,7 @@
public Cookie[] getCookies(String host, boolean secure, String path)
{
- List matches = new ArrayList();
+ ArrayList<Cookie> matches = new ArrayList<Cookie>();
Date now = new Date();
if (Character.isLetter(host.charAt(0)))
{
@@ -102,17 +101,16 @@
return ret;
}
- private void addCookies(List matches, String domain, boolean secure,
- String path, Date now)
+ private void addCookies(ArrayList<Cookie> matches, String domain,
+ boolean secure, String path, Date now)
{
- Map map = (Map) cookies.get(domain);
+ Map<String, Cookie> map = cookies.get(domain);
if (map != null)
{
- List expired = new ArrayList();
- for (Iterator i = map.entrySet().iterator(); i.hasNext(); )
+ ArrayList<String> expired = new ArrayList<String>();
+ for (Map.Entry<String, Cookie> entry : map.entrySet())
{
- Map.Entry entry = (Map.Entry) i.next();
- Cookie cookie = (Cookie) entry.getValue();
+ Cookie cookie = entry.getValue();
Date expires = cookie.getExpiryDate();
if (expires != null && expires.before(now))
{
@@ -129,7 +127,7 @@
}
}
// Good housekeeping
- for (Iterator i = expired.iterator(); i.hasNext(); )
+ for (Iterator<String> i = expired.iterator(); i.hasNext(); )
{
map.remove(i.next());
}
Modified: trunk/core/src/classpath/gnu/gnu/java/net/protocol/jar/Connection.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/protocol/jar/Connection.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/protocol/jar/Connection.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -76,7 +76,8 @@
public static class JarFileCache
{
- private static Hashtable cache = new Hashtable();
+ private static Hashtable<URL, JarFile> cache
+ = new Hashtable<URL, JarFile>();
private static final int READBUFSIZE = 4*1024;
public static synchronized JarFile get (URL url, boolean useCaches)
@@ -85,7 +86,7 @@
JarFile jf;
if (useCaches)
{
- jf = (JarFile) cache.get (url);
+ jf = cache.get (url);
if (jf != null)
return jf;
}
Modified: trunk/core/src/classpath/gnu/gnu/java/net/protocol/jar/Handler.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/net/protocol/jar/Handler.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/net/protocol/jar/Handler.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -1,5 +1,5 @@
/* gnu.java.net.protocol.jar.Handler - jar protocol handler for java.net
- Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,6 +45,9 @@
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.StringTokenizer;
/**
* @author Kresten Krab Thorup (kr...@gn...)
@@ -114,7 +117,7 @@
file = file.substring(0, idx + 1) + url_string;
}
- setURL (url, "jar", url.getHost(), url.getPort(), file, null);
+ setURL (url, "jar", url.getHost(), url.getPort(), flat(file), null);
return;
}
@@ -149,6 +152,45 @@
}
/**
+ * Makes the given jar url string 'flat' by removing any . and .. from
+ * jar file path because ZipFile entries can only handle flat paths.
+ * Inside jar files '/' is always the path separator.
+ */
+ private static String flat(String url_string)
+ {
+ int jar_stop = url_string.indexOf("!/");
+ String jar_path = url_string.substring(jar_stop + 1, url_string.length());
+
+ if (jar_path.indexOf("/.") < 0)
+ return url_string;
+
+ ArrayList<String> tokens = new ArrayList<String>();
+ StringTokenizer st = new StringTokenizer(jar_path, "/");
+ while (st.hasMoreTokens())
+ {
+ String token = st.nextToken();
+ if (token.equals("."))
+ continue;
+ else if (token.equals(".."))
+ {
+ if (! tokens.isEmpty())
+ tokens.remove(tokens.size() - 1);
+ }
+ else
+ tokens.add(token);
+ }
+
+ StringBuffer path = new StringBuffer(url_string.length());
+ path.append(url_string.substring(0, jar_stop + 1));
+
+ Iterator<String> it = tokens.iterator();
+ while (it.hasNext())
+ path.append('/').append(it.next());
+
+ return path.toString();
+ }
+
+ /**
* This method converts a Jar URL object into a String.
*
* @param url The URL object to convert
Added: trunk/core/src/classpath/gnu/gnu/java/security/Requires.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/Requires.java (rev 0)
+++ trunk/core/src/classpath/gnu/gnu/java/security/Requires.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -0,0 +1,59 @@
+/* Requires.java -- mark methods as requiring permission.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.security;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+import java.security.Permission;
+
+/**
+ *
+ *
+ * @author Casey Marshall (cs...@gn...)
+ */
+@Documented @Retention(CLASS) @Target(METHOD)
+public @interface Requires
+{
+ Class<? extends Permission> permissionClass();
+ String target();
+ String action();
+}
Modified: trunk/core/src/classpath/gnu/gnu/java/security/action/GetPropertyAction.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/action/GetPropertyAction.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/security/action/GetPropertyAction.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -49,7 +49,7 @@
* String port = AccessController.doPrivileged(action);
* </code>
*/
-public class GetPropertyAction implements PrivilegedAction
+public class GetPropertyAction implements PrivilegedAction<String>
{
String name;
String value = null;
@@ -68,7 +68,7 @@
setParameters(propName, defaultValue);
}
- public Object run()
+ public String run()
{
return System.getProperty(name, value);
}
Modified: trunk/core/src/classpath/gnu/gnu/java/security/action/GetSecurityPropertyAction.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/action/GetSecurityPropertyAction.java 2007-01-07 12:36:12 UTC (rev 3016)
+++ trunk/core/src/classpath/gnu/gnu/java/security/action/GetSecurityPropertyAction.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -50,7 +50,7 @@
* String passwd = AccessController.doPrivileged(action);
* </code>
*/
-public class GetSecurityPropertyAction implements PrivilegedAction
+public class GetSecurityPropertyAction implements PrivilegedAction<String>
{
private String name;
private String value;
@@ -83,7 +83,7 @@
return this;
}
- public Object run()
+ public String run()
{
String val = Security.getProperty(name);
if (val == null)
Added: trunk/core/src/classpath/gnu/gnu/java/security/util/ByteBufferOutputStream.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/util/ByteBufferOutputStream.java (rev 0)
+++ trunk/core/src/classpath/gnu/gnu/java/security/util/ByteBufferOutputStream.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -0,0 +1,118 @@
+/* ByteBufferOutputStream.java -- output stream with a growable underlying
+ byte buffer.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.security.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import java.nio.ByteBuffer;
+
+/**
+ * An output stream that writes bytes to a ByteBuffer, which will be resized
+ * if more space is needed.
+ *
+ * @author Casey Marshall (cs...@gn...)
+ */
+public class ByteBufferOutputStream extends OutputStream
+{
+ private ByteBuffer buffer;
+
+ public ByteBufferOutputStream()
+ {
+ this(256);
+ }
+
+ public ByteBufferOutputStream(int initialCapacity)
+ {
+ buffer = ByteBuffer.allocate(initialCapacity);
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(int)
+ */
+ public @Override synchronized void write(int b) throws IOException
+ {
+ if (!buffer.hasRemaining())
+ growBuffer();
+ buffer.put((byte) b);
+ }
+
+ public @Override synchronized void write(byte[] b, int offset, int length)
+ {
+ if (buffer.remaining() < length)
+ growBuffer();
+ buffer.put(b, offset, length);
+ }
+
+ public @Override void write(byte[] b)
+ {
+ write(b, 0, b.length);
+ }
+
+ /**
+ * Get the current state of the buffer. The returned buffer will have
+ * its position set to zero, its capacity set to the current limit,
+ * and its limit set to its capacity.
+ *
+ * @return The buffer.
+ */
+ public ByteBuffer buffer()
+ {
+ return ((ByteBuffer) buffer.duplicate().flip()).slice();
+ }
+
+ public String toString()
+ {
+ return super.toString() + " [ buffer: " + buffer + " ]";
+ }
+
+ private void growBuffer()
+ {
+ int newCapacity = buffer.capacity();
+ if (newCapacity < 16384) // If the buffer isn't huge yet, double its size
+ newCapacity = newCapacity << 1;
+ else // Otherwize, increment by a bit.
+ newCapacity += 4096;
+ ByteBuffer newBuffer = ByteBuffer.allocate(newCapacity);
+ buffer.flip();
+ newBuffer.put(buffer);
+ buffer = newBuffer;
+ }
+}
Added: trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/GeneralName.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/GeneralName.java (rev 0)
+++ trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/GeneralName.java 2007-01-07 12:37:19 UTC (rev 3017)
@@ -0,0 +1,232 @@
+/* GeneralName.java -- a GeneralName.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.security.x509.ext;
+
+import gnu.java.security.der.DER;
+import gnu.java.security.der.DERReader;
+import gnu.java.security.der.DERValue;
+import gnu.java.security.x509.Util;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+/**...
[truncated message content] |