Imported GNU Classpath 0.92
2006-08-14 Mark Wielaard <mark@klomp.org> Imported GNU Classpath 0.92 * HACKING: Add more importing hints. Update automake version requirement. * configure.ac (gconf-peer): New enable AC argument. Add --disable-gconf-peer and --enable-default-preferences-peer to classpath configure when gconf is disabled. * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and gnu/java/awt/dnd/peer/gtk to bc. Classify gnu/java/security/Configuration.java as generated source file. * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java, gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java, gnu/java/lang/management/VMClassLoadingMXBeanImpl.java, gnu/java/lang/management/VMRuntimeMXBeanImpl.java, gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java, gnu/java/lang/management/VMThreadMXBeanImpl.java, gnu/java/lang/management/VMMemoryMXBeanImpl.java, gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub classes. * java/lang/management/VMManagementFactory.java: Likewise. * java/net/VMURLConnection.java: Likewise. * gnu/java/nio/VMChannel.java: Likewise. * java/lang/Thread.java (getState): Add stub implementation. * java/lang/Class.java (isEnum): Likewise. * java/lang/Class.h (isEnum): Likewise. * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed. * javax/naming/spi/NamingManager.java: New override for StackWalker functionality. * configure, sources.am, Makefile.in, gcj/Makefile.in, include/Makefile.in, testsuite/Makefile.in: Regenerated. From-SVN: r116139
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* File.java -- Class representing a file on disk
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
@@ -82,7 +82,7 @@ public class File implements Serializable, Comparable
|
||||
|
||||
/**
|
||||
* This is the string that is used to separate the host name from the
|
||||
* path name in paths than include the host name. It is the value of
|
||||
* path name in paths that include the host name. It is the value of
|
||||
* the <code>path.separator</code> system property.
|
||||
*/
|
||||
public static final String pathSeparator
|
||||
@@ -484,9 +484,9 @@ public class File implements Serializable, Comparable
|
||||
/**
|
||||
* This method returns a canonical representation of the pathname of
|
||||
* this file. The actual form of the canonical representation is
|
||||
* different. On the GNU system, the canonical form differs from the
|
||||
* absolute form in that all relative file references to "." and ".."
|
||||
* are resolved and removed.
|
||||
* system-dependent. On the GNU system, conversion to canonical
|
||||
* form involves the removal of redundant separators, references to
|
||||
* "." and "..", and symbolic links.
|
||||
* <p>
|
||||
* Note that this method, unlike the other methods which return path
|
||||
* names, can throw an IOException. This is because native method
|
||||
@@ -542,7 +542,8 @@ public class File implements Serializable, Comparable
|
||||
/**
|
||||
* This method returns a <code>String</code> the represents this file's
|
||||
* parent. <code>null</code> is returned if the file has no parent. The
|
||||
* parent is determined via a simple operation which removes the
|
||||
* parent is determined via a simple operation which removes the name
|
||||
* after the last file separator character, as determined by the platform.
|
||||
*
|
||||
* @return The parent directory of this file
|
||||
*/
|
||||
@@ -1199,7 +1200,38 @@ public class File implements Serializable, Comparable
|
||||
*/
|
||||
public static File[] listRoots()
|
||||
{
|
||||
return VMFile.listRoots();
|
||||
File[] roots = VMFile.listRoots();
|
||||
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
{
|
||||
// Only return roots to which the security manager permits read access.
|
||||
int count = roots.length;
|
||||
for (int i = 0; i < roots.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
s.checkRead (roots[i].path);
|
||||
}
|
||||
catch (SecurityException sx)
|
||||
{
|
||||
roots[i] = null;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
if (count != roots.length)
|
||||
{
|
||||
File[] newRoots = new File[count];
|
||||
int k = 0;
|
||||
for (int i = 0; i < roots.length; i++)
|
||||
{
|
||||
if (roots[i] != null)
|
||||
newRoots[k++] = roots[i];
|
||||
}
|
||||
roots = newRoots;
|
||||
}
|
||||
}
|
||||
return roots;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -274,12 +274,7 @@ public final class FilePermission extends Permission implements Serializable
|
||||
break;
|
||||
|
||||
default:
|
||||
if (f2.charAt(f2.length() - 1) == File.separatorChar)
|
||||
{
|
||||
if (! f1.equals(f2.substring(0, f2.length() - 1)))
|
||||
return false;
|
||||
}
|
||||
else if (!f1.equals(f2))
|
||||
if (!f1.equals(f2))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -424,7 +424,23 @@ public class ObjectInputStream extends InputStream
|
||||
clearHandles();
|
||||
throw new WriteAbortedException("Exception thrown during writing of stream", e);
|
||||
}
|
||||
|
||||
|
||||
case TC_ENUM:
|
||||
{
|
||||
/* TC_ENUM classDesc newHandle enumConstantName */
|
||||
if (dump)
|
||||
dumpElementln("ENUM=");
|
||||
ObjectStreamClass osc = (ObjectStreamClass) readObject();
|
||||
String constantName = (String) readObject();
|
||||
if (dump)
|
||||
dumpElementln("CONSTANT NAME = " + constantName);
|
||||
Class clazz = osc.forClass();
|
||||
Enum instance = Enum.valueOf(clazz, constantName);
|
||||
assignNewHandle(instance);
|
||||
ret_val = instance;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new IOException("Unknown marker on stream: " + marker);
|
||||
}
|
||||
|
||||
@@ -253,7 +253,17 @@ public class ObjectOutputStream extends OutputStream
|
||||
ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject(clazz);
|
||||
if (osc == null)
|
||||
throw new NotSerializableException(clazz.getName());
|
||||
|
||||
|
||||
if (osc.isEnum())
|
||||
{
|
||||
/* TC_ENUM classDesc newHandle enumConstantName */
|
||||
realOutput.writeByte(TC_ENUM);
|
||||
writeObject(osc);
|
||||
assignNewHandle(obj);
|
||||
writeObject(((Enum) obj).name());
|
||||
break;
|
||||
}
|
||||
|
||||
if ((replacementEnabled || obj instanceof Serializable)
|
||||
&& ! replaceDone)
|
||||
{
|
||||
@@ -432,7 +442,10 @@ public class ObjectOutputStream extends OutputStream
|
||||
{
|
||||
realOutput.writeByte(TC_CLASSDESC);
|
||||
realOutput.writeUTF(osc.getName());
|
||||
realOutput.writeLong(osc.getSerialVersionUID());
|
||||
if (osc.isEnum())
|
||||
realOutput.writeLong(0L);
|
||||
else
|
||||
realOutput.writeLong(osc.getSerialVersionUID());
|
||||
assignNewHandle(osc);
|
||||
|
||||
int flags = osc.getFlags();
|
||||
|
||||
@@ -219,6 +219,12 @@ public class ObjectStreamClass implements Serializable
|
||||
return (flags & ObjectStreamConstants.SC_EXTERNALIZABLE) != 0;
|
||||
}
|
||||
|
||||
// Returns true iff the class that this ObjectStreamClass represents
|
||||
// implements Externalizable.
|
||||
boolean isEnum()
|
||||
{
|
||||
return (flags & ObjectStreamConstants.SC_ENUM) != 0;
|
||||
}
|
||||
|
||||
// Returns the <code>ObjectStreamClass</code> that represents the
|
||||
// class that is the superclass of the class this
|
||||
@@ -587,6 +593,9 @@ outer:
|
||||
|
||||
if (writeObjectMethod != null)
|
||||
flags |= ObjectStreamConstants.SC_WRITE_METHOD;
|
||||
|
||||
if (cl.isEnum() || cl == Enum.class)
|
||||
flags |= ObjectStreamConstants.SC_ENUM;
|
||||
}
|
||||
|
||||
|
||||
@@ -596,7 +605,7 @@ outer:
|
||||
{
|
||||
SetAccessibleAction setAccessible = new SetAccessibleAction();
|
||||
|
||||
if (!isSerializable() || isExternalizable())
|
||||
if (!isSerializable() || isExternalizable() || isEnum())
|
||||
{
|
||||
fields = NO_FIELDS;
|
||||
return;
|
||||
|
||||
@@ -50,8 +50,6 @@ package java.io;
|
||||
*/
|
||||
public interface ObjectStreamConstants
|
||||
{
|
||||
// FIXME: Javadoc comment these values.
|
||||
|
||||
/**
|
||||
* The serialization stream protocol version 1. This version was
|
||||
* the default serialization protocol before JDK 1.2.
|
||||
@@ -70,37 +68,159 @@ public interface ObjectStreamConstants
|
||||
*/
|
||||
int PROTOCOL_VERSION_2 = 2;
|
||||
|
||||
/**
|
||||
* The magic number that is written as part of the stream header.
|
||||
*/
|
||||
short STREAM_MAGIC = (short)0xaced;
|
||||
|
||||
/**
|
||||
* The stream version number that is written as part of the stream header.
|
||||
* Note that this is different from the protocol version that specifies
|
||||
* the data format for the stream.
|
||||
*/
|
||||
short STREAM_VERSION = 5;
|
||||
|
||||
/**
|
||||
* Token value to designate a <code>null</code> reference in the stream.
|
||||
*/
|
||||
byte TC_NULL = (byte)112; //0x70
|
||||
|
||||
/**
|
||||
* Token value to designate a reference to an already serialized object.
|
||||
*/
|
||||
byte TC_REFERENCE = (byte)113; //0x71
|
||||
|
||||
/**
|
||||
* Token value to designate a class descriptor is next in the stream.
|
||||
*/
|
||||
byte TC_CLASSDESC = (byte)114; //0x72
|
||||
|
||||
/**
|
||||
* Token value to designate a new object is next in the stream.
|
||||
*/
|
||||
byte TC_OBJECT = (byte)115; //0x73
|
||||
|
||||
/**
|
||||
* Token value to designate a new string is next in the stream.
|
||||
*/
|
||||
byte TC_STRING = (byte)116; //0x74
|
||||
|
||||
/**
|
||||
* Token value to designate a new array is next in the stream.
|
||||
*/
|
||||
byte TC_ARRAY = (byte)117; //0x75
|
||||
|
||||
/**
|
||||
* Token reference to designate a reference to a class.
|
||||
*/
|
||||
byte TC_CLASS = (byte)118; //0x76
|
||||
|
||||
/**
|
||||
* Token value to designate a block of primitive data is next in the stream.
|
||||
* The next byte in the stream holds the size of the block (in bytes).
|
||||
*/
|
||||
byte TC_BLOCKDATA = (byte)119; //0x77
|
||||
|
||||
/**
|
||||
* Token value to designate the end of a block of primitve data.
|
||||
*/
|
||||
byte TC_ENDBLOCKDATA = (byte)120; //0x78
|
||||
|
||||
/**
|
||||
* Token value to designate a reset of the stream state.
|
||||
*/
|
||||
byte TC_RESET = (byte)121; //0x79
|
||||
|
||||
/**
|
||||
* Token value to designate a long block of primitive data is next in the
|
||||
* stream. The next long in the stream holds the size of the block
|
||||
* (in bytes).
|
||||
*/
|
||||
byte TC_BLOCKDATALONG = (byte)122; //0x7A
|
||||
|
||||
/**
|
||||
* Token value to designate an exception occured during serialization.
|
||||
*/
|
||||
byte TC_EXCEPTION = (byte)123; //0x7B
|
||||
|
||||
/**
|
||||
* Token value to designate a long string is next in the stream.
|
||||
*/
|
||||
byte TC_LONGSTRING = (byte)124; //0x7C
|
||||
|
||||
/**
|
||||
* Token value to designate a proxy class descriptor is next in the stream.
|
||||
*/
|
||||
byte TC_PROXYCLASSDESC = (byte)125; //0x7D
|
||||
|
||||
/**
|
||||
* Token value to designate an enum constant is next in the stream.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
byte TC_ENUM = (byte)126; //0x7E
|
||||
|
||||
/**
|
||||
* The first token value.
|
||||
*/
|
||||
byte TC_BASE = TC_NULL;
|
||||
byte TC_MAX = TC_PROXYCLASSDESC;
|
||||
|
||||
/**
|
||||
* The last token value.
|
||||
*/
|
||||
byte TC_MAX = TC_ENUM;
|
||||
|
||||
/**
|
||||
* The first handle that will be assigned to an object, for later references.
|
||||
*/
|
||||
int baseWireHandle = 0x7e0000;
|
||||
|
||||
/**
|
||||
* Flag used in <code>ObjectStreamClass</code> to designate that the class
|
||||
* defines the <code>writeObject</code> method.
|
||||
*/
|
||||
byte SC_WRITE_METHOD = 0x01;
|
||||
|
||||
/**
|
||||
* Flag used in <code>ObjectStreamClass</code> to designate that the class
|
||||
* is serializeable.
|
||||
*/
|
||||
byte SC_SERIALIZABLE = 0x02;
|
||||
|
||||
/**
|
||||
* Flag used in <code>ObjectStreamClass</code> to designate that the class
|
||||
* is externalizable.
|
||||
*/
|
||||
byte SC_EXTERNALIZABLE = 0x04;
|
||||
|
||||
/**
|
||||
* Flag used in <code>ObjectStreamClass</code> to designate that
|
||||
* externalizable data is written in block data mode.
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
byte SC_BLOCK_DATA = 0x08;
|
||||
|
||||
/**
|
||||
* Flag used in <code>ObjectStreamClass</code> to designate that the class
|
||||
* is an enum constant.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
byte SC_ENUM = 0x10;
|
||||
|
||||
/**
|
||||
* Constant for use with a <code>SecurityManager</code> to check if
|
||||
* substitution of objects is allowed.
|
||||
*/
|
||||
SerializablePermission SUBSTITUTION_PERMISSION
|
||||
= new SerializablePermission("enableSubstitution");
|
||||
|
||||
/**
|
||||
* Constant for use with a <code>SecurityManager</code> to check if
|
||||
* overriding of the <code>writeObject</code> and <code>readObject</code>
|
||||
* methods is allowed.
|
||||
*/
|
||||
SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION
|
||||
= new SerializablePermission("enableSubclassImplementation");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* OutputStream.java -- Base class for byte output streams
|
||||
Copyright (C) 1998, 1999, 2001, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -48,7 +48,7 @@ package java.io;
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
* @author Tom Tromey (tromey@cygnus.com)
|
||||
*/
|
||||
public abstract class OutputStream
|
||||
public abstract class OutputStream implements Closeable, Flushable
|
||||
{
|
||||
/**
|
||||
* This is the default no-argument constructor for this class. This method
|
||||
|
||||
@@ -87,8 +87,76 @@ public class PrintStream extends FilterOutputStream
|
||||
private boolean auto_flush;
|
||||
|
||||
/**
|
||||
* This method intializes a new <code>PrintStream</code> object to write
|
||||
* to the specified output sink.
|
||||
* This method initializes a new <code>PrintStream</code> object to write
|
||||
* to the specified output File. Doesn't autoflush.
|
||||
*
|
||||
* @param file The <code>File</code> to write to.
|
||||
* @throws FileNotFoundException if an error occurs while opening the file.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public PrintStream (File file)
|
||||
throws FileNotFoundException
|
||||
{
|
||||
this (new FileOutputStream(file), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes a new <code>PrintStream</code> object to write
|
||||
* to the specified output File. Doesn't autoflush.
|
||||
*
|
||||
* @param file The <code>File</code> to write to.
|
||||
* @param encoding The name of the character encoding to use for this
|
||||
* object.
|
||||
* @throws FileNotFoundException If an error occurs while opening the file.
|
||||
* @throws UnsupportedEncodingException If the charset specified by
|
||||
* <code>encoding</code> is invalid.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public PrintStream (File file, String encoding)
|
||||
throws FileNotFoundException,UnsupportedEncodingException
|
||||
{
|
||||
this (new FileOutputStream(file), false, encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes a new <code>PrintStream</code> object to write
|
||||
* to the specified output File. Doesn't autoflush.
|
||||
*
|
||||
* @param fileName The name of the <code>File</code> to write to.
|
||||
* @throws FileNotFoundException if an error occurs while opening the file,
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public PrintStream (String fileName)
|
||||
throws FileNotFoundException
|
||||
{
|
||||
this (new FileOutputStream(new File(fileName)), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes a new <code>PrintStream</code> object to write
|
||||
* to the specified output File. Doesn't autoflush.
|
||||
*
|
||||
* @param fileName The name of the <code>File</code> to write to.
|
||||
* @param encoding The name of the character encoding to use for this
|
||||
* object.
|
||||
* @throws FileNotFoundException if an error occurs while opening the file.
|
||||
* @throws UnsupportedEncodingException If the charset specified by
|
||||
* <code>encoding</code> is invalid.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public PrintStream (String fileName, String encoding)
|
||||
throws FileNotFoundException,UnsupportedEncodingException
|
||||
{
|
||||
this (new FileOutputStream(new File(fileName)), false, encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes a new <code>PrintStream</code> object to write
|
||||
* to the specified output sink. Doesn't autoflush.
|
||||
*
|
||||
* @param out The <code>OutputStream</code> to write to.
|
||||
*/
|
||||
@@ -98,7 +166,7 @@ public class PrintStream extends FilterOutputStream
|
||||
}
|
||||
|
||||
/**
|
||||
* This method intializes a new <code>PrintStream</code> object to write
|
||||
* This method initializes a new <code>PrintStream</code> object to write
|
||||
* to the specified output sink. This constructor also allows "auto-flush"
|
||||
* functionality to be specified where the stream will be flushed after
|
||||
* every <code>print</code> or <code>println</code> call, when the
|
||||
@@ -127,7 +195,7 @@ public class PrintStream extends FilterOutputStream
|
||||
}
|
||||
|
||||
/**
|
||||
* This method intializes a new <code>PrintStream</code> object to write
|
||||
* This method initializes a new <code>PrintStream</code> object to write
|
||||
* to the specified output sink. This constructor also allows "auto-flush"
|
||||
* functionality to be specified where the stream will be flushed after
|
||||
* every <code>print</code> or <code>println</code> call, when the
|
||||
|
||||
Reference in New Issue
Block a user