|
From: <ls...@us...> - 2007-01-07 18:39:40
|
Revision: 3042
http://jnode.svn.sourceforge.net/jnode/?rev=3042&view=rev
Author: lsantha
Date: 2007-01-07 10:39:36 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/gnu/gnu/java/io/Base64InputStream.java
trunk/core/src/classpath/gnu/gnu/java/lang/InstrumentationImpl.java
trunk/core/src/classpath/gnu/gnu/java/lang/management/BeanImpl.java
trunk/core/src/classpath/gnu/gnu/java/lang/management/MemoryMXBeanImpl.java
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/lang/reflect/ClassSignatureParser.java
trunk/core/src/classpath/gnu/gnu/java/lang/reflect/GenericSignatureParser.java
trunk/core/src/classpath/gnu/gnu/java/lang/reflect/MethodSignatureParser.java
trunk/core/src/classpath/gnu/gnu/java/nio/charset/ByteCharset.java
trunk/core/src/classpath/gnu/gnu/java/nio/charset/ISO_8859_1.java
trunk/core/src/classpath/gnu/gnu/java/nio/charset/US_ASCII.java
trunk/core/src/classpath/gnu/gnu/java/rmi/server/ActivatableRef.java
trunk/core/src/classpath/gnu/gnu/java/rmi/server/RMIObjectInputStream.java
trunk/core/src/classpath/gnu/gnu/java/security/Engine.java
trunk/core/src/classpath/gnu/gnu/java/security/x509/X509Certificate.java
trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/CertificatePolicies.java
trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/ExtendedKeyUsage.java
trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/Extension.java
trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/GeneralNames.java
trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/IssuerAlternativeNames.java
trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/SubjectAlternativeNames.java
trunk/core/src/classpath/gnu/gnu/java/util/regex/RESyntax.java
trunk/core/src/classpath/gnu/gnu/java/util/regex/RETokenNamedProperty.java
trunk/core/src/classpath/gnu/gnu/java/util/regex/RETokenRepeated.java
trunk/core/src/classpath/gnu/gnu/javax/crypto/RSACipherImpl.java
trunk/core/src/classpath/gnu/gnu/javax/crypto/jce/cipher/CipherAdapter.java
trunk/core/src/classpath/gnu/gnu/javax/crypto/pad/PKCS7.java
trunk/core/src/classpath/gnu/gnu/javax/net/ssl/provider/InputSecurityParameters.java
trunk/core/src/classpath/gnu/gnu/javax/net/ssl/provider/SimpleSessionContext.java
Modified: trunk/core/src/classpath/gnu/gnu/java/io/Base64InputStream.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/io/Base64InputStream.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/io/Base64InputStream.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -139,7 +139,9 @@
while (count < len)
{
int i;
- while (Character.isWhitespace((char) (i = in.read())));
+ while (Character.isWhitespace((char) (i = in.read())))
+ ;
+
int pos = BASE_64.indexOf((char) i);
if (pos >= 0)
{
@@ -173,11 +175,13 @@
case 1:
throw new IOException("malformed Base-64 input");
case 2:
- while (Character.isWhitespace((char) (i = in.read())));
+ while (Character.isWhitespace((char) (i = in.read())))
+ ;
if (i != BASE_64_PAD)
throw new IOException("malformed Base-64 input");
case 3:
- while (Character.isWhitespace((char) (i = in.read())));
+ while (Character.isWhitespace((char) (i = in.read())))
+ ;
}
eof = true;
break;
Modified: trunk/core/src/classpath/gnu/gnu/java/lang/InstrumentationImpl.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/lang/InstrumentationImpl.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/InstrumentationImpl.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -1,6 +1,6 @@
/* InstrumentationImpl.java -- GNU implementation of
java.lang.instrument.Instrumentation
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -63,11 +63,11 @@
{
/* List of transformers */
- /* FIXME[GENERICS]: Should be ClassFileTransformer list */
- private ArrayList transformers = new ArrayList();
+ private ArrayList<ClassFileTransformer> transformers =
+ new ArrayList<ClassFileTransformer>();
- private InstrumentationImpl()
+ InstrumentationImpl()
{
}
@@ -210,9 +210,8 @@
*
* @return the new class file
*/
- /* FIXME[GENERICS]: Should be Class<?> */
public byte[] callTransformers(ClassLoader loader, String className,
- Class classBeingRedefined, ProtectionDomain protectionDomain,
+ Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
byte[] classfileBuffer)
{
byte[] newBuffer = null;
@@ -220,11 +219,10 @@
ClassFileTransformer current;
synchronized (transformers)
{
- Iterator i = transformers.iterator();
+ Iterator<ClassFileTransformer> i = transformers.iterator();
while (i.hasNext())
{
- /* FIXME[GENERICS]: Remove cast */
- current = (ClassFileTransformer) i.next();
+ current = i.next();
try
{
newBuffer = current.transform(loader, className,
Modified: trunk/core/src/classpath/gnu/gnu/java/lang/management/BeanImpl.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/lang/management/BeanImpl.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/management/BeanImpl.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -201,32 +201,36 @@
return ((Enum) value).name();
Class vClass = value.getClass();
if (vClass.isArray())
- return value;
+ vClass = vClass.getComponentType();
String cName = vClass.getName();
String[] allowedTypes = OpenType.ALLOWED_CLASSNAMES;
for (int a = 0; a < allowedTypes.length; ++a)
if (cName.equals(allowedTypes[a]))
return value;
+ OpenMBeanInfo info = (OpenMBeanInfo) getMBeanInfo();
+ MBeanAttributeInfo[] attribs =
+ (MBeanAttributeInfo[]) info.getAttributes();
+ OpenType type = null;
+ for (int a = 0; a < attribs.length; ++a)
+ if (attribs[a].getName().equals(attribute))
+ type = ((OpenMBeanAttributeInfo) attribs[a]).getOpenType();
if (value instanceof List)
{
+ try
+ {
+ Class e =
+ Class.forName(((ArrayType) type).getElementOpenType().getClassName());
List l = (List) value;
- Class e = null;
- TypeVariable[] vars = vClass.getTypeParameters();
- for (int a = 0; a < vars.length; ++a)
- if (vars[a].getName().equals("E"))
- e = (Class) vars[a].getGenericDeclaration();
- if (e == null)
- e = Object.class;
Object[] array = (Object[]) Array.newInstance(e, l.size());
return l.toArray(array);
}
- OpenMBeanInfo info = (OpenMBeanInfo) getMBeanInfo();
- OpenMBeanAttributeInfo[] attribs =
- (OpenMBeanAttributeInfo[]) info.getAttributes();
- OpenType type = null;
- for (int a = 0; a < attribs.length; ++a)
- if (attribs[a].getName().equals("attribute"))
- type = attribs[a].getOpenType();
+ catch (ClassNotFoundException e)
+ {
+ throw (InternalError) (new InternalError("The class of the list " +
+ "element type could not " +
+ "be created").initCause(e));
+ }
+ }
if (value instanceof Map)
{
TabularType ttype = (TabularType) type;
@@ -425,6 +429,34 @@
return new OpenMBeanParameterInfoSupport("TransParam",
"Translated parameter",
SimpleType.VOID);
+ if (type.startsWith("java.util.Map"))
+ {
+ int lparam = type.indexOf("<");
+ int comma = type.indexOf(",", lparam);
+ int rparam = type.indexOf(">", comma);
+ String key = type.substring(lparam + 1, comma).trim();
+ OpenType k = translate(key).getOpenType();
+ OpenType v = translate(type.substring(comma + 1, rparam).trim()).getOpenType();
+ CompositeType ctype = new CompositeType(Map.class.getName(), Map.class.getName(),
+ new String[] { "key", "value" },
+ new String[] { "Map key", "Map value"},
+ new OpenType[] { k, v});
+ TabularType ttype = new TabularType(key, key, ctype,
+ new String[] { "key" });
+ return new OpenMBeanParameterInfoSupport("TransParam",
+ "Translated parameter",
+ ttype);
+ }
+ if (type.startsWith("java.util.List"))
+ {
+ int lparam = type.indexOf("<");
+ int rparam = type.indexOf(">");
+ OpenType e = translate(type.substring(lparam + 1, rparam).trim()).getOpenType();
+ return new OpenMBeanParameterInfoSupport("TransParam",
+ "Translated parameter",
+ new ArrayType(1, e)
+ );
+ }
Class c;
try
{
@@ -432,8 +464,9 @@
}
catch (ClassNotFoundException e)
{
- throw new InternalError("The class for a type used in a management bean " +
- "could not be loaded.");
+ throw (InternalError)
+ (new InternalError("The class for a type used in a management bean " +
+ "could not be loaded.").initCause(e));
}
if (c.isEnum())
{
@@ -450,9 +483,9 @@
try
{
c.getMethod("from", new Class[] { CompositeData.class });
- Method[] methods = c.getMethods();
- List names = new ArrayList();
- List types = new ArrayList();
+ Method[] methods = c.getDeclaredMethods();
+ List<String> names = new ArrayList<String>();
+ List<OpenType> types = new ArrayList<OpenType>();
for (int a = 0; a < methods.length; ++a)
{
String name = methods[a].getName();
@@ -462,10 +495,10 @@
types.add(getTypeFromClass(methods[a].getReturnType()));
}
}
- String[] fields = (String[]) names.toArray();
+ String[] fields = names.toArray(new String[names.size()]);
CompositeType ctype = new CompositeType(c.getName(), c.getName(),
fields, fields,
- (OpenType[]) types.toArray());
+ types.toArray(new OpenType[types.size()]));
return new OpenMBeanParameterInfoSupport("TransParam",
"Translated parameter",
ctype);
@@ -474,46 +507,11 @@
{
/* Ignored; we expect this if this isn't a from(CompositeData) class */
}
- if (Map.class.isAssignableFrom(c))
- {
- OpenType k = SimpleType.VOID;
- OpenType v = SimpleType.VOID;
- TypeVariable[] vars = c.getTypeParameters();
- for (int a = 0; a < vars.length; ++a)
- {
- if (vars[a].getName().equals("K"))
- k = getTypeFromClass((Class) vars[a].getGenericDeclaration());
- if (vars[a].getName().equals("V"))
- v = getTypeFromClass((Class) vars[a].getGenericDeclaration());
- }
- CompositeType ctype = new CompositeType(Map.class.getName(), Map.class.getName(),
- new String[] { "key", "value" },
- new String[] { "Map key", "Map value"},
- new OpenType[] { k, v});
- TabularType ttype = new TabularType(c.getName(), c.getName(), ctype,
- new String[] { "key" });
- return new OpenMBeanParameterInfoSupport("TransParam",
- "Translated parameter",
- ttype);
- }
- if (List.class.isAssignableFrom(c))
- {
- OpenType e = SimpleType.VOID;
- TypeVariable[] vars = c.getTypeParameters();
- for (int a = 0; a < vars.length; ++a)
- {
- if (vars[a].getName().equals("E"))
- e = getTypeFromClass((Class) vars[a].getGenericDeclaration());
- }
- return new OpenMBeanParameterInfoSupport("TransParam",
- "Translated parameter",
- new ArrayType(1, e)
- );
- }
if (c.isArray())
{
int depth;
- for (depth = 0; c.getName().charAt(depth) == '['; ++depth);
+ for (depth = 0; c.getName().charAt(depth) == '['; ++depth)
+ ;
OpenType ot = getTypeFromClass(c.getComponentType());
return new OpenMBeanParameterInfoSupport("TransParam",
"Translated parameter",
Modified: trunk/core/src/classpath/gnu/gnu/java/lang/management/MemoryMXBeanImpl.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/lang/management/MemoryMXBeanImpl.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/management/MemoryMXBeanImpl.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -37,6 +37,8 @@
package gnu.java.lang.management;
+import gnu.classpath.ListenerData;
+
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryNotificationInfo;
import java.lang.management.MemoryUsage;
@@ -168,49 +170,6 @@
VMMemoryMXBeanImpl.setVerbose(verbose);
}
- private class ListenerData
- {
- private NotificationListener listener;
- private NotificationFilter filter;
- private Object passback;
-
- public ListenerData(NotificationListener listener,
- NotificationFilter filter, Object passback)
- {
- this.listener = listener;
- this.filter = filter;
- this.passback = passback;
- }
-
- public NotificationListener getListener()
- {
- return listener;
- }
-
- public NotificationFilter getFilter()
- {
- return filter;
- }
-
- public Object getPassback()
- {
- return passback;
- }
-
- public boolean equals(Object obj)
- {
- if (obj instanceof ListenerData)
- {
- ListenerData data = (ListenerData) obj;
- return (data.getListener() == listener &&
- data.getFilter() == filter &&
- data.getPassback() == passback);
- }
- return false;
- }
-
- }
-
public void addNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object passback)
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 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/management/MemoryPoolMXBeanImpl.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -40,8 +40,8 @@
import gnu.classpath.SystemProperties;
import java.lang.management.MemoryPoolMXBean;
+import java.lang.management.MemoryType;
import java.lang.management.MemoryUsage;
-import java.lang.management.MemoryType;
import javax.management.NotCompliantMBeanException;
@@ -136,7 +136,8 @@
public MemoryType getType()
{
- return null;
+ return
+ MemoryType.valueOf(VMMemoryPoolMXBeanImpl.getType(name));
}
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 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/management/OperatingSystemMXBeanImpl.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -82,14 +82,14 @@
return System.getProperty("os.name");
}
+ public double getSystemLoadAverage()
+ {
+ return VMOperatingSystemMXBeanImpl.getSystemLoadAverage();
+ }
+
public String getVersion()
{
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 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/management/ThreadMXBeanImpl.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -85,6 +85,18 @@
"gnu.java.lang.management.ThreadTimeInitallyEnabled";
/**
+ * Constant for monitor usage monitoring support.
+ */
+ private static final String MONITOR_SUPPORT =
+ "gnu.java.lang.management.MonitorUsageMonitoringSupport";
+
+ /**
+ * Constant for ownable synchronizer usage monitoring support.
+ */
+ private static final String SYNCHRONIZER_SUPPORT =
+ "gnu.java.lang.management.OwnableSynchronizerUsageMonitoringSupport";
+
+ /**
* Flag to indicate whether time monitoring is enabled or not.
*/
private boolean timeEnabled;
@@ -112,6 +124,23 @@
contentionEnabled = false;
}
+ public ThreadInfo[] dumpAllThreads(boolean lockedMonitors,
+ boolean lockedSynchronizers)
+ {
+ return getThreadInfo(getAllThreadIds(), lockedMonitors,
+ lockedSynchronizers);
+ }
+
+ public long[] findDeadlockedThreads()
+ {
+ checkMonitorPermissions();
+ if (!isSynchronizerUsageSupported())
+ throw new UnsupportedOperationException("Ownable synchronizer usage " +
+ "monitoring is not provided " +
+ "by this VM.");
+ return VMThreadMXBeanImpl.findDeadlockedThreads();
+ }
+
public long[] findMonitorDeadlockedThreads()
{
checkMonitorPermissions();
@@ -207,6 +236,27 @@
return infos;
}
+ public ThreadInfo[] getThreadInfo(long[] ids, boolean lockedMonitors,
+ boolean lockedSynchronizers)
+ {
+ checkMonitorPermissions();
+ if (lockedMonitors && !isObjectMonitorUsageSupported())
+ throw new UnsupportedOperationException("Monitor usage monitoring is " +
+ "not provided by this VM.");
+ if (lockedSynchronizers && !isSynchronizerUsageSupported())
+ throw new UnsupportedOperationException("Ownable synchronizer usage " +
+ "monitoring is not provided " +
+ "by this VM.");
+ ThreadInfo[] infos = getThreadInfo(ids, Integer.MAX_VALUE);
+ if (lockedMonitors)
+ for (ThreadInfo info : infos)
+ VMThreadMXBeanImpl.getMonitorInfo(info);
+ if (lockedSynchronizers)
+ for (ThreadInfo info : infos)
+ VMThreadMXBeanImpl.getLockInfo(info);
+ return infos;
+ }
+
public long getThreadUserTime(long id)
{
if (!isThreadCpuTimeSupported())
@@ -231,6 +281,16 @@
return SystemProperties.getProperty(CURRENT_THREAD_TIME_SUPPORT) != null;
}
+ public boolean isObjectMonitorUsageSupported()
+ {
+ return SystemProperties.getProperty(MONITOR_SUPPORT) != null;
+ }
+
+ public boolean isSynchronizerUsageSupported()
+ {
+ return SystemProperties.getProperty(SYNCHRONIZER_SUPPORT) != null;
+ }
+
public boolean isThreadContentionMonitoringEnabled()
{
if (isThreadContentionMonitoringSupported())
@@ -287,30 +347,5 @@
"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();
- }
}
Modified: trunk/core/src/classpath/gnu/gnu/java/lang/reflect/ClassSignatureParser.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/lang/reflect/ClassSignatureParser.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/reflect/ClassSignatureParser.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -61,7 +61,7 @@
}
// SuperclassSignature
superclassType = readClassTypeSignature();
- ArrayList interfaces = new ArrayList();
+ ArrayList<Type> interfaces = new ArrayList<Type>();
while (peekChar() == 'L')
{
// SuperinterfaceSignature
Modified: trunk/core/src/classpath/gnu/gnu/java/lang/reflect/GenericSignatureParser.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/lang/reflect/GenericSignatureParser.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/reflect/GenericSignatureParser.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -60,11 +60,10 @@
return this;
}
- /* FIXME[GENERICS]: Remove cast */
public Type[] getBounds()
{
resolve(bounds);
- return (Type[]) bounds.clone();
+ return bounds.clone();
}
public GenericDeclaration getGenericDeclaration()
@@ -141,10 +140,9 @@
return this;
}
- /* FIXME[GENERICS]: Remove cast */
public Type[] getActualTypeArguments()
{
- return (Type[]) typeArgs.clone();
+ return typeArgs.clone();
}
public Type getRawType()
@@ -276,12 +274,11 @@
GenericDeclaration d = decl;
while (d != null)
{
- TypeVariable[] vars = d.getTypeParameters();
- for (int a = 0; a < vars.length ; ++a)
+ for (TypeVariable t : d.getTypeParameters())
{
- if (vars[a].getName().equals(name))
+ if (t.getName().equals(name))
{
- return vars[a];
+ return t;
}
}
d = getParent(d);
@@ -414,7 +411,7 @@
TypeVariable[] readFormalTypeParameters()
{
consume('<');
- ArrayList params = new ArrayList();
+ ArrayList<TypeVariable> params = new ArrayList<TypeVariable>();
do
{
// TODO should we handle name clashes?
@@ -430,7 +427,7 @@
{
String identifier = readIdentifier();
consume(':');
- ArrayList bounds = new ArrayList();
+ ArrayList<Type> bounds = new ArrayList<Type>();
if (peekChar() != ':')
{
bounds.add(readFieldTypeSignature());
@@ -501,7 +498,7 @@
private Type[] readTypeArguments()
{
consume('<');
- ArrayList list = new ArrayList();
+ ArrayList<Type> list = new ArrayList<Type>();
do
{
list.add(readTypeArgument());
Modified: trunk/core/src/classpath/gnu/gnu/java/lang/reflect/MethodSignatureParser.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/lang/reflect/MethodSignatureParser.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/lang/reflect/MethodSignatureParser.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -72,7 +72,7 @@
typeParameters = new TypeVariable[0];
}
consume('(');
- ArrayList args = new ArrayList();
+ ArrayList<Type> args = new ArrayList<Type>();
while (peekChar() != ')')
{
args.add(readTypeSignature());
@@ -81,7 +81,7 @@
args.toArray(argTypes);
consume(')');
retType = readTypeSignature();
- ArrayList throwsSigs = new ArrayList();
+ ArrayList<Type> throwsSigs = new ArrayList<Type>();
while (peekChar() == '^')
{
consume('^');
Modified: trunk/core/src/classpath/gnu/gnu/java/nio/charset/ByteCharset.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/nio/charset/ByteCharset.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/nio/charset/ByteCharset.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -115,8 +115,8 @@
return CoderResult.OVERFLOW;
}
- if((c = lookup[(int) (b & 0xFF)]) == NONE);
- // return CoderResult.unmappableForLength (1);
+ if((c = lookup[(int) (b & 0xFF)]) == NONE)
+ return CoderResult.unmappableForLength (1);
out.put (c);
}
@@ -156,6 +156,22 @@
}
}
+ public boolean canEncode(char c)
+ {
+ byte b = (c < lookup.length) ? lookup[c] : 0;
+ return b != 0 || c == 0;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ {
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ }
+ return true;
+ }
+
protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
{
// TODO: Optimize this in the case in.hasArray() / out.hasArray()
Modified: trunk/core/src/classpath/gnu/gnu/java/nio/charset/ISO_8859_1.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/nio/charset/ISO_8859_1.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/nio/charset/ISO_8859_1.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -128,6 +128,19 @@
super (cs, 1.0f, 1.0f);
}
+ public boolean canEncode(char c)
+ {
+ return c <= 0xff;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ return true;
+ }
+
protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
{
// TODO: Optimize this in the case in.hasArray() / out.hasArray()
Modified: trunk/core/src/classpath/gnu/gnu/java/nio/charset/US_ASCII.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/nio/charset/US_ASCII.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/nio/charset/US_ASCII.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -134,6 +134,19 @@
super (cs, 1.0f, 1.0f);
}
+ public boolean canEncode(char c)
+ {
+ return c <= 0x7f;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ return true;
+ }
+
protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
{
// TODO: Optimize this in the case in.hasArray() / out.hasArray()
@@ -141,7 +154,7 @@
{
char c = in.get ();
- if (c > Byte.MAX_VALUE)
+ if (c > 0x7f)
{
in.position (in.position () - 1);
return CoderResult.unmappableForLength (1);
Modified: trunk/core/src/classpath/gnu/gnu/java/rmi/server/ActivatableRef.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/rmi/server/ActivatableRef.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/rmi/server/ActivatableRef.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -112,8 +112,10 @@
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException
{
+ actId = (ActivationID) in.readObject();
+ String type = in.readUTF();
+ // XXX handle type.equals("") (null reference)
super.readExternal(in);
- actId = (ActivationID) in.readObject();
}
/**
@@ -121,8 +123,10 @@
*/
public void writeExternal(ObjectOutput out) throws IOException
{
+ out.writeObject(actId);
+ // XXX write a "" if the "nested" reference is a null reference
+ out.writeUTF("UnicastRef2");
super.writeExternal(out);
- out.writeObject(actId);
}
/**
Modified: trunk/core/src/classpath/gnu/gnu/java/rmi/server/RMIObjectInputStream.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/rmi/server/RMIObjectInputStream.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/rmi/server/RMIObjectInputStream.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -1,5 +1,5 @@
/* RMIObjectInputStream.java --
- Copyright (c) 1996, 1997, 1998, 1999, 2002, 2004
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2004, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,11 +39,11 @@
package gnu.java.rmi.server;
+import gnu.classpath.VMStackWalker;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
-import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
import java.rmi.server.RMIClassLoader;
import java.util.ArrayList;
@@ -57,16 +57,14 @@
}
protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
- String annotation = (String)getAnnotation();
-
try {
- if(annotation == null)
- return (RMIClassLoader.loadClass(desc.getName()));
- else
- return (RMIClassLoader.loadClass(annotation, desc.getName()));
+ return RMIClassLoader.loadClass(
+ (String)getAnnotation(),
+ desc.getName(),
+ VMStackWalker.firstNonNullClassLoader());
}
- catch (MalformedURLException _) {
- throw new ClassNotFoundException(desc.getName());
+ catch (MalformedURLException x) {
+ throw new ClassNotFoundException(desc.getName(), x);
}
}
@@ -81,45 +79,16 @@
protected Class resolveProxyClass(String intfs[]) throws IOException,
ClassNotFoundException
{
- String annotation = (String) getAnnotation();
-
- Class clss[] = new Class[intfs.length];
-
- for (int i = 0; i < intfs.length; i++)
- {
- if (annotation == null)
- clss[i] = RMIClassLoader.loadClass(intfs[i]);
- else
- clss[i] = RMIClassLoader.loadClass(annotation, intfs[i]);
- }
-
- ClassLoader loader;
-
- if (clss.length > 0)
- {
- // Chain all class loaders (they may differ).
- ArrayList loaders = new ArrayList(intfs.length);
- ClassLoader cx;
- for (int i = 0; i < clss.length; i++)
- {
- cx = clss[i].getClassLoader();
- if (!loaders.contains(cx))
- {
- loaders.add(0, cx);
- }
- }
- loader = new CombinedClassLoader(loaders);
- }
- else
- loader = ClassLoader.getSystemClassLoader();
-
try
{
- return Proxy.getProxyClass(loader, clss);
+ return RMIClassLoader.loadProxyClass(
+ (String)getAnnotation(),
+ intfs,
+ VMStackWalker.firstNonNullClassLoader());
}
- catch (IllegalArgumentException e)
+ catch (MalformedURLException x)
{
- throw new ClassNotFoundException(null, e);
+ throw new ClassNotFoundException(null, x);
}
}
Modified: trunk/core/src/classpath/gnu/gnu/java/security/Engine.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/Engine.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/security/Engine.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -42,6 +42,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
+import java.util.Enumeration;
/**
* Generic implementation of the getInstance methods in the various
@@ -78,25 +79,22 @@
/** This class cannot be instantiated. */
private Engine() { }
- // Class method.
- // ------------------------------------------------------------------------
-
/**
- * Get the implementation for <i>algorithm</i> for service
- * <i>service</i> from <i>provider</i>. The service is e.g.
- * "Signature", and the algorithm "DSA".
+ * Return the implementation for <i>algorithm</i> for service <i>service</i>
+ * from <i>provider</i>. The service is e.g. "Signature", and the algorithm
+ * "DSA".
*
* @param service The service name.
* @param algorithm The name of the algorithm to get.
* @param provider The provider to get the implementation from.
- * @return The engine class for the specified algorithm; the object
- * returned is typically a subclass of the SPI class for that
- * service, but callers should check that this is so.
- * @throws NoSuchAlgorithmException If the implementation cannot be
- * found or cannot be instantiated.
- * @throws InvocationTargetException If the SPI class's constructor
- * throws an exception.
- * @throws IllegalArgumentException If any of the three arguments are null.
+ * @return The engine class for the specified algorithm; the object returned
+ * is typically a subclass of the SPI class for that service, but
+ * callers should check that this is so.
+ * @throws NoSuchAlgorithmException If the implementation cannot be found or
+ * cannot be instantiated.
+ * @throws InvocationTargetException If the SPI class's constructor throws an
+ * exception.
+ * @throws IllegalArgumentException If any of the three arguments is null.
*/
public static Object getInstance(String service, String algorithm,
Provider provider)
@@ -106,107 +104,145 @@
}
/**
- * Get the implementation for <i>algorithm</i> for service
- * <i>service</i> from <i>provider</i>, passing <i>initArgs</i> to the
- * SPI class's constructor (which cannot be null; pass a zero-length
- * array if the SPI takes no arguments). The service is e.g.
- * "Signature", and the algorithm "DSA".
+ * Return the implementation for <i>algorithm</i> for service <i>service</i>
+ * from <i>provider</i>, passing <i>initArgs</i> to the SPI class's
+ * constructor (which cannot be null; pass a zero-length array if the SPI
+ * takes no arguments). The service is e.g. "Signature", and the algorithm
+ * "DSA".
*
* @param service The service name.
* @param algorithm The name of the algorithm to get.
* @param provider The provider to get the implementation from.
- * @param initArgs The arguments to pass to the SPI class's
- * constructor (cannot be null).
- * @return The engine class for the specified algorithm; the object
- * returned is typically a subclass of the SPI class for that
- * service, but callers should check that this is so.
- * @throws NoSuchAlgorithmException If the implementation cannot be
- * found or cannot be instantiated.
- * @throws InvocationTargetException If the SPI class's constructor
- * throws an exception.
- * @throws IllegalArgumentException If any of the four arguments are null.
+ * @param initArgs The arguments to pass to the SPI class's constructor
+ * (cannot be null).
+ * @return The engine class for the specified algorithm; the object returned
+ * is typically a subclass of the SPI class for that service, but
+ * callers should check that this is so.
+ * @throws NoSuchAlgorithmException If the implementation cannot be found or
+ * cannot be instantiated.
+ * @throws InvocationTargetException If the SPI class's constructor throws an
+ * exception.
+ * @throws IllegalArgumentException If any of the four arguments is
+ * <code>null</code> or if either <code>service</code>, or
+ * <code>algorithm</code> is an empty string.
*/
public static Object getInstance(String service, String algorithm,
Provider provider, Object[] initArgs)
throws InvocationTargetException, NoSuchAlgorithmException
{
- if (service != null)
+ if (service == null)
+ throw new IllegalArgumentException("service MUST NOT be null");
service = service.trim();
-
- if (algorithm != null)
+ if (service.length() == 0)
+ throw new IllegalArgumentException("service MUST NOT be empty");
+ if (algorithm == null)
+ throw new IllegalArgumentException("algorithm MUST NOT be null");
algorithm = algorithm.trim();
+ if (algorithm.length() == 0)
+ throw new IllegalArgumentException("algorithm MUST NOT be empty");
+ if (provider == null)
+ throw new IllegalArgumentException("provider MUST NOT be null");
+ if (initArgs == null)
+ throw new IllegalArgumentException("Constructor's parameters MUST NOT be null");
- if (service == null || service.length() == 0
- || algorithm == null || algorithm.length() == 0
- || provider == null || initArgs == null)
- throw new IllegalArgumentException();
-
- // If there is no property "service.algorithm"
- if (provider.getProperty(service + "." + algorithm) == null)
+ Enumeration enumer = provider.propertyNames();
+ String key;
+ String alias;
+ int count = 0;
+ boolean algorithmFound = false;
+ StringBuilder sb = new StringBuilder();
+ while (enumer.hasMoreElements())
{
- // Iterate through aliases, until we find the class name or resolve
- // too many aliases.
- String alias = null;
- int count = 0;
- while ((alias = provider.getProperty(
- ALG_ALIAS + service + "." + algorithm)) != null)
+ key = (String) enumer.nextElement();
+ if (key.equalsIgnoreCase(service + "." + algorithm))
{
- if (algorithm.equals(alias)) // Refers to itself!
+ // remove the service portion from the key
+ algorithm = key.substring(service.length() + 1);
+ algorithmFound = true;
break;
+ }
+ else if (key.equalsIgnoreCase(ALG_ALIAS + service + "." + algorithm))
+ {
+ alias = (String) provider.getProperty(key);
+ if (! algorithm.equalsIgnoreCase(alias)) // does not refer to itself
+ {
algorithm = alias;
if (count++ > MAX_ALIASES)
- throw new NoSuchAlgorithmException("too many aliases");
+ {
+ sb.append("Algorithm [").append(algorithm)
+ .append("] of type [").append(service)
+ .append("] from provider [").append(provider)
+ .append("] has too many aliases");
+ throw new NoSuchAlgorithmException(sb.toString());
}
- if (provider.getProperty(service + "." + algorithm) == null)
- throw new NoSuchAlgorithmException(algorithm);
+ // need to reset enumeration to now look for the alias
+ enumer = provider.propertyNames();
+ }
+ }
}
- // Find and instantiate the implementation.
+ if (! algorithmFound)
+ {
+ sb.append("Algorithm [").append(algorithm).append("] of type [")
+ .append(service).append("] from provider [")
+ .append(provider).append("] is not found");
+ throw new NoSuchAlgorithmException(sb.toString());
+ }
+
+ // Find and instantiate the implementation
Class clazz = null;
ClassLoader loader = provider.getClass().getClassLoader();
Constructor constructor = null;
- String error = algorithm;
-
+ String className = provider.getProperty(service + "." + algorithm);
+ sb.append("Class [").append(className).append("] for algorithm [")
+ .append(algorithm).append("] of type [").append(service)
+ .append("] from provider [").append(provider).append("] ");
+ Throwable cause = null;
try
{
if (loader != null)
- clazz = loader.loadClass(provider.getProperty(service+"."+algorithm));
+ clazz = loader.loadClass(className);
else
- clazz = Class.forName(provider.getProperty(service+"."+algorithm));
+ clazz = Class.forName(className);
constructor = getCompatibleConstructor(clazz, initArgs);
return constructor.newInstance(initArgs);
}
- catch (ClassNotFoundException cnfe)
+ catch (ClassNotFoundException x)
{
- error = "class not found: " + algorithm;
+ sb.append("cannot not be found");
+ cause = x;
}
- catch (IllegalAccessException iae)
+ catch (IllegalAccessException x)
{
- error = "illegal access: " + iae.getMessage();
+ sb.append("cannot be accessed");
+ cause = x;
}
- catch (InstantiationException ie)
+ catch (InstantiationException x)
{
- error = "instantiation exception: " + ie.getMessage();
+ sb.append("cannot be instantiated");
+ cause = x;
}
- catch (ExceptionInInitializerError eiie)
+ catch (ExceptionInInitializerError x)
{
- error = "exception in initializer: " + eiie.getMessage();
+ sb.append("cannot be initialized");
+ cause = x;
}
- catch (SecurityException se)
+ catch (SecurityException x)
{
- error = "security exception: " + se.getMessage();
+ sb.append("caused a security violation");
+ cause = x;
}
- catch (NoSuchMethodException nsme)
+ catch (NoSuchMethodException x)
{
- error = "no appropriate constructor found";
+ sb.append("does not have/expose an appropriate constructor");
+ cause = x;
}
- throw new NoSuchAlgorithmException(error);
+ NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
+ x.initCause(cause);
+ throw x;
}
- // Own methods.
- // ------------------------------------------------------------------------
-
/**
* Find a constructor in the given class that can take the specified
* argument list, allowing any of which to be null.
Modified: trunk/core/src/classpath/gnu/gnu/java/security/x509/X509Certificate.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/x509/X509Certificate.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/security/x509/X509Certificate.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -1,5 +1,5 @@
/* X509Certificate.java -- X.509 certificate.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,6 +48,7 @@
import gnu.java.security.x509.ext.BasicConstraints;
import gnu.java.security.x509.ext.ExtendedKeyUsage;
import gnu.java.security.x509.ext.Extension;
+import gnu.java.security.x509.ext.GeneralName;
import gnu.java.security.x509.ext.IssuerAlternativeNames;
import gnu.java.security.x509.ext.KeyUsage;
import gnu.java.security.x509.ext.SubjectAlternativeNames;
@@ -103,6 +104,7 @@
// Constants and fields.
// ------------------------------------------------------------------------
+ private static final long serialVersionUID = -2491127588187038216L;
private static final Logger logger = SystemLogger.SYSTEM;
protected static final OID ID_DSA = new OID ("1.2.840.10040.4.1");
@@ -133,7 +135,7 @@
protected transient PublicKey subjectKey;
protected transient BitString issuerUniqueId;
protected transient BitString subjectUniqueId;
- protected transient Map extensions;
+ protected transient Map<OID, Extension> extensions;
// Signature.
protected transient OID sigAlgId;
@@ -157,7 +159,7 @@
throws CertificateException, IOException
{
super();
- extensions = new HashMap();
+ extensions = new HashMap<OID, Extension>();
try
{
parse(encoded);
@@ -178,7 +180,7 @@
protected X509Certificate()
{
- extensions = new HashMap();
+ extensions = new HashMap<OID, Extension>();
}
// X509Certificate methods.
@@ -316,17 +318,15 @@
return null;
}
- public List getExtendedKeyUsage() throws CertificateParsingException
+ public List<String> getExtendedKeyUsage() throws CertificateParsingException
{
Extension e = getExtension(ExtendedKeyUsage.ID);
if (e != null)
{
- List a = ((ExtendedKeyUsage) e.getValue()).getPurposeIds();
- List b = new ArrayList(a.size());
- for (Iterator it = a.iterator(); it.hasNext(); )
- {
- b.add(it.next().toString());
- }
+ List<OID> a = ((ExtendedKeyUsage) e.getValue()).getPurposeIds();
+ List<String> b = new ArrayList<String>(a.size());
+ for (OID oid : a)
+ b.add(oid.toString());
return Collections.unmodifiableList(b);
}
return null;
@@ -342,24 +342,44 @@
return -1;
}
- public Collection getSubjectAlternativeNames()
+ public Collection<List<?>> getSubjectAlternativeNames()
throws CertificateParsingException
{
Extension e = getExtension(SubjectAlternativeNames.ID);
if (e != null)
{
- return ((SubjectAlternativeNames) e.getValue()).getNames();
+ List<GeneralName> names
+ = ((SubjectAlternativeNames) e.getValue()).getNames();
+ List<List<?>> list = new ArrayList<List<?>>(names.size());
+ for (GeneralName name : names)
+ {
+ List<Object> n = new ArrayList<Object>(2);
+ n.add(name.kind().tag());
+ n.add(name.name());
+ list.add(n);
+ }
+ return list;
}
return null;
}
- public Collection getIssuerAlternativeNames()
+ public Collection<List<?>> getIssuerAlternativeNames()
throws CertificateParsingException
{
Extension e = getExtension(IssuerAlternativeNames.ID);
if (e != null)
{
- return ((IssuerAlternativeNames) e.getValue()).getNames();
+ List<GeneralName> names
+ = ((IssuerAlternativeNames) e.getValue()).getNames();
+ List<List<?>> list = new ArrayList<List<?>>(names.size());
+ for (GeneralName name : names)
+ {
+ List<Object> n = new ArrayList<Object>(2);
+ n.add(name.kind().tag());
+ n.add(name.name());
+ list.add(n);
+ }
+ return list;
}
return null;
}
@@ -378,24 +398,22 @@
return false;
}
- public Set getCriticalExtensionOIDs()
+ public Set<String> getCriticalExtensionOIDs()
{
- HashSet s = new HashSet();
- for (Iterator it = extensions.values().iterator(); it.hasNext(); )
+ HashSet<String> s = new HashSet<String>();
+ for (Extension e : extensions.values())
{
- Extension e = (Extension) it.next();
if (e.isCritical())
s.add(e.getOid().toString());
}
return Collections.unmodifiableSet(s);
}
- public Set getNonCriticalExtensionOIDs()
+ public Set<String> getNonCriticalExtensionOIDs()
{
- HashSet s = new HashSet();
- for (Iterator it = extensions.values().iterator(); it.hasNext(); )
+ HashSet<String> s = new HashSet<String>();
+ for (Extension e : extensions.values())
{
- Extension e = (Extension) it.next();
if (!e.isCritical())
s.add(e.getOid().toString());
}
Modified: trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/CertificatePolicies.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/CertificatePolicies.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/CertificatePolicies.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -1,5 +1,5 @@
/* CertificatePolicies.java -- certificate policy extension.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -61,8 +61,8 @@
public static final OID ID = new OID("2.5.29.32");
- private final List policies;
- private final Map policyQualifierInfos;
+ private final List<OID> policies;
+ private final Map<OID, List<PolicyQualifierInfo>> policyQualifierInfos;
// Constructor.
// -------------------------------------------------------------------------
@@ -76,8 +76,9 @@
throw new IOException("malformed CertificatePolicies");
int len = 0;
- LinkedList policyList = new LinkedList();
- HashMap qualifierMap = new HashMap();
+ LinkedList<OID> policyList = new LinkedList<OID>();
+ HashMap<OID, List<PolicyQualifierInfo>> qualifierMap
+ = new HashMap<OID, List<PolicyQualifierInfo>>();
while (len < pol.getLength())
{
DERValue policyInfo = der.read();
@@ -92,7 +93,7 @@
{
DERValue qual = der.read();
int len2 = 0;
- LinkedList quals = new LinkedList();
+ LinkedList<PolicyQualifierInfo> quals = new LinkedList<PolicyQualifierInfo>();
while (len2 < qual.getLength())
{
val = der.read();
@@ -109,8 +110,8 @@
policyQualifierInfos = Collections.unmodifiableMap(qualifierMap);
}
- public CertificatePolicies (final List policies,
- final Map policyQualifierInfos)
+ public CertificatePolicies (final List<OID> policies,
+ final Map<OID, List<PolicyQualifierInfo>> policyQualifierInfos)
{
for (Iterator it = policies.iterator(); it.hasNext(); )
if (!(it.next() instanceof OID))
@@ -129,54 +130,69 @@
throw new IllegalArgumentException
("policyQualifierInfos values must be Lists of PolicyQualifierInfos");
}
- this.policies = Collections.unmodifiableList (new ArrayList (policies));
+ this.policies = Collections.unmodifiableList (new ArrayList<OID>(policies));
this.policyQualifierInfos = Collections.unmodifiableMap
- (new HashMap (policyQualifierInfos));
+ (new HashMap<OID, List<PolicyQualifierInfo>>(policyQualifierInfos));
}
// Instance methods.
// -------------------------------------------------------------------------
- public List getPolicies()
+ public List<OID> getPolicies()
{
return policies;
}
- public List getPolicyQualifierInfos(OID oid)
+ /**
+ * Returns the list of policy OIDs, formatted as dotted-decimal strings.
+ *
+ * @return
+ */
+ public List<String> getPolicyStrings()
{
- return (List) policyQualifierInfos.get(oid);
+ List<String> l = new ArrayList<String>(policies.size());
+ for (OID oid : policies)
+ {
+ l.add(oid.toString());
+ }
+ return l;
}
+ public List<PolicyQualifierInfo> getPolicyQualifierInfos(OID oid)
+ {
+ return policyQualifierInfos.get(oid);
+ }
+
public byte[] getEncoded()
{
if (encoded == null)
{
- List pol = new ArrayList (policies.size());
- for (Iterator it = policies.iterator(); it.hasNext(); )
+ List<DERValue> pol = new ArrayList<DERValue>(policies.size());
+ for (Iterator<OID> it = policies.iterator(); it.hasNext(); )
{
- OID policy = (OID) it.next();
- List qualifiers = getPolicyQualifierInfos (policy);
- List l = new ArrayList (qualifiers == null ? 1 : 2);
- l.add (new DERValue (DER.OBJECT_IDENTIFIER, policy));
+ OID policy = it.next();
+ List<PolicyQualifierInfo> qualifiers = getPolicyQualifierInfos(policy);
+ List<DERValue> l = new ArrayList<DERValue>(qualifiers == null ? 1 : 2);
+ l.add(new DERValue(DER.OBJECT_IDENTIFIER, policy));
if (qualifiers != null)
{
- List ll = new ArrayList (qualifiers.size());
- for (Iterator it2 = qualifiers.iterator(); it.hasNext(); )
+ List<DERValue> ll = new ArrayList<DERValue>(qualifiers.size());
+ for (Iterator<PolicyQualifierInfo> it2 = qualifiers.iterator(); it.hasNext(); )
{
- PolicyQualifierInfo info = (PolicyQualifierInfo) it2.next();
+ PolicyQualifierInfo info = it2.next();
try
{
- ll.add (DERReader.read (info.getEncoded()));
+ ll.add(DERReader.read(info.getEncoded()));
}
catch (IOException ioe)
{
}
}
- l.add (new DERValue (DER.CONSTRUCTED|DER.SEQUENCE, ll));
+ l.add(new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, ll));
}
- pol.add (new DERValue (DER.CONSTRUCTED|DER.SEQUENCE, l));
+ pol.add(new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, l));
}
- encoded = new DERValue (DER.CONSTRUCTED|DER.SEQUENCE, pol).getEncoded();
+ encoded = new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, pol).getEncoded();
}
return (byte[]) encoded.clone();
}
Modified: trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/ExtendedKeyUsage.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/ExtendedKeyUsage.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/ExtendedKeyUsage.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -1,5 +1,5 @@
/* ExtendedKeyUsage.java -- the extended key usage extension.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -56,7 +56,7 @@
public static final OID ID = new OID("2.5.29.37");
- private final List purposeIds;
+ private final List<OID> purposeIds;
// Constructor.
// -------------------------------------------------------------------------
@@ -69,13 +69,13 @@
if (!usageList.isConstructed())
throw new IOException("malformed ExtKeyUsageSyntax");
int len = 0;
- purposeIds = new LinkedList();
+ purposeIds = new LinkedList<OID>();
while (len < usageList.getLength())
{
DERValue val = der.read();
if (val.getTag() != DER.OBJECT_IDENTIFIER)
throw new IOException("malformed KeyPurposeId");
- purposeIds.add(val.getValue());
+ purposeIds.add((OID) val.getValue());
len += val.getEncodedLength();
}
}
@@ -83,7 +83,7 @@
// Instance method.
// -------------------------------------------------------------------------
- public List getPurposeIds()
+ public List<OID> getPurposeIds()
{
return Collections.unmodifiableList(purposeIds);
}
Modified: trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/Extension.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/Extension.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/Extension.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -1,5 +1,5 @@
/* Extension.java -- an X.509 certificate or CRL extension.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -171,6 +171,10 @@
{
value = new ReasonCode(encval);
}
+ else if (oid.equals(NameConstraints.ID))
+ {
+ value = new NameConstraints(encval);
+ }
else
{
value = new Value(encval);
@@ -226,11 +230,11 @@
public DERValue getDerValue()
{
- List ext = new ArrayList (3);
- ext.add (new DERValue (DER.OBJECT_IDENTIFIER, oid));
- ext.add (new DERValue (DER.BOOLEAN, Boolean.valueOf (critical)));
- ext.add (new DERValue (DER.OCTET_STRING, value.getEncoded()));
- return new DERValue (DER.CONSTRUCTED|DER.SEQUENCE, ext);
+ List<DERValue> ext = new ArrayList<DERValue>(3);
+ ext.add(new DERValue(DER.OBJECT_IDENTIFIER, oid));
+ ext.add(new DERValue(DER.BOOLEAN, Boolean.valueOf(critical)));
+ ext.add(new DERValue(DER.OCTET_STRING, value.getEncoded()));
+ return new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, ext);
}
// Own methods.
Modified: trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/GeneralNames.java
===================================================================
--- trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/GeneralNames.java 2007-01-07 18:38:08 UTC (rev 3041)
+++ trunk/core/src/classpath/gnu/gnu/java/security/x509/ext/GeneralNames.java 2007-01-07 18:39:36 UTC (rev 3042)
@@ -38,106 +38,38 @@
package gnu.java.security.x509.ext;
-import gnu.java.security.OID;
-import gnu.java.security.der.DER;
import gnu.java.security.der.DERReader;
import gnu.java.security.der.DERValue;
import java.io.IOException;
-import java.net.InetAddress;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import javax.security.auth.x500.X500Principal;
-
public class GeneralNames
{
// Instance methods.
// -------------------------------------------------------------------------
- public static final int OTHER_NAME = 0;
- public static final int RFC822_NAME = 1;
- public static final int DNS_NAME = 2;
- public static final int X400_ADDRESS = 3;
- public static final int DIRECTORY_NAME = 4;
- public static final int EDI_PARTY_NAME = 5;
- public static final int URI = 6;
- public static final int IP_ADDRESS = 7;
- public static final int REGISTERED_ID = 8;
+ private List<GeneralName> names;
- private List names;
-
// Constructor.
// -------------------------------------------------------------------------
public GeneralNames(final byte[] encoded) throws IOException
{
- names = new LinkedList();
+ names = new LinkedList<GeneralName>();
DERReader der = new DERReader(encoded);
DERValue nameList = der.read();
if (!nameList.isConstructed())
throw new IOException("malformed GeneralNames");
int len = 0;
- int i = 0;
while (len < nameList.getLength())
{
DERValue name = der.read();
- List namePair = new ArrayList(2);
- int tagClass = name.getTagClass();
- if (tagClass != DER.CONTEXT)
- throw new IOException("malformed GeneralName: Tag class is " + tagClass);
- namePair.add(Integer.valueOf(name.getTag()));
- DERValue val = null;
- switch (name.getTag())
- {
- case RFC822_NAME:
- case DNS_NAME:
- case X400_ADDRESS:
- case URI:
- namePair.add(new String((byte[]) name.getValue()));
- break;
-
- case OTHER_NAME:
- // MUST return the encoded bytes of the OID/OctetString sequence
- byte[] anotherName = name.getEncoded();
- anotherName[0] = (byte) (DER.CONSTRUCTED|DER.SEQUENCE);
- namePair.add(anotherName);
- // DERReader goes back on Constructed things so we need to skip over them
- DERValue skip = der.read(); // skip OID
- skip = der.read(); // skip Octet String
- break;
-
- case EDI_PARTY_NAME:
- namePair.add(name.getValue());
- break;
-
- case DIRECTORY_NAME:
- byte[] b = name.getEncoded();
- b[0] = (byte) (DER.CONSTRUCTED|DER.SEQUENCE);
- DERReader r = new DERReader (b);
- r.read ();
- namePair.add(new X500Principal(r.read ().getEncoded ()).toString());
- break;
-
- case IP_ADDRESS:
- namePair.add(InetAddress.getByAddress((byte[]) name.getValue())
- .getHostAddress());
- break;
-
- case REGISTERED_ID:
- byte[] bb = name.getEncoded();
- bb[0] = (byte) DER.OBJECT_IDENTIFIER;
- namePair.add(new OID(bb).toString());
- break;
-
- default:
- throw new IOException("unknown tag " + name.getTag());
- }
- names.add(namePair);
+ GeneralName generalName = new GeneralName(name.getEncoded());
+ names.add(generalName);
len += name.getEncodedLength();
}
}
@@ -145,21 +77,9 @@
// Instance methods.
// -------------------------------------------------------------------------
- public List getNames()
- {
- List l = new ArrayList(names.size());
- for (Iterator it = names.iterator(); it.hasNext(); )
+ public List<GeneralName> getNames()
{
- List ll = (List) it.next();
- List pair = new ArrayList(2);
- ...
[truncated message content] |