aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/java/io
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/io')
-rw-r--r--libjava/classpath/java/io/File.java179
-rw-r--r--libjava/classpath/java/io/ObjectInputStream.java175
-rw-r--r--libjava/classpath/java/io/ObjectOutputStream.java88
-rw-r--r--libjava/classpath/java/io/StreamTokenizer.java2
-rw-r--r--libjava/classpath/java/io/class-dependencies.conf100
5 files changed, 396 insertions, 148 deletions
diff --git a/libjava/classpath/java/io/File.java b/libjava/classpath/java/io/File.java
index 5d1b3ec..f34b4dd 100644
--- a/libjava/classpath/java/io/File.java
+++ b/libjava/classpath/java/io/File.java
@@ -164,6 +164,29 @@ public class File implements Serializable, Comparable<File>
}
/**
+ * This method tests whether or not the current thread is allowed to
+ * to execute the file pointed to by this object. This will be true if and
+ * and only if 1) the file exists and 2) the <code>SecurityManager</code>
+ * (if any) allows access to the file via it's <code>checkExec</code>
+ * method 3) the file is executable.
+ *
+ * @return <code>true</code> if execution is allowed,
+ * <code>false</code> otherwise
+ *
+ * @exception SecurityException If the <code>SecurityManager</code>
+ * does not allow access to the file
+ */
+ public boolean canExecute()
+ {
+ if (!VMFile.exists(path))
+ return false;
+
+ checkExec();
+
+ return VMFile.canExecute(path);
+ }
+
+ /**
* This method creates a new file of zero length with the same name as
* the path of this <code>File</code> object if an only if that file
* does not already exist.
@@ -1123,6 +1146,153 @@ public class File implements Serializable, Comparable<File>
}
/**
+ * This method sets the owner's read permission for the File represented by
+ * this object.
+ *
+ * It is the same as calling <code>setReadable(readable, true)</code>.
+ *
+ * @param <code>readable</code> <code>true</code> to set read permission,
+ * <code>false</code> to unset the read permission.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setReadable(boolean, boolean)
+ * @since 1.6
+ */
+ public boolean setReadable(boolean readable)
+ {
+ return setReadable(readable, true);
+ }
+
+ /**
+ * This method sets the read permissions for the File represented by
+ * this object.
+ *
+ * If <code>ownerOnly</code> is set to <code>true</code> then only the
+ * read permission bit for the owner of the file is changed.
+ *
+ * If <code>ownerOnly</code> is set to <code>false</code>, the file
+ * permissions are changed so that the file can be read by everyone.
+ *
+ * On unix like systems this sets the <code>user</code>, <code>group</code>
+ * and <code>other</code> read bits and is equal to call
+ * <code>chmod a+r</code> on the file.
+ *
+ * @param <code>readable</code> <code>true</code> to set read permission,
+ * <code>false</code> to unset the read permission.
+ * @param <code>ownerOnly</code> <code>true</code> to set read permission
+ * for owner only, <code>false</code> for all.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setReadable(boolean)
+ * @since 1.6
+ */
+ public boolean setReadable(boolean readable, boolean ownerOnly)
+ {
+ checkWrite();
+ return VMFile.setReadable(path, readable, ownerOnly);
+ }
+
+ /**
+ * This method sets the owner's write permission for the File represented by
+ * this object.
+ *
+ * It is the same as calling <code>setWritable(readable, true)</code>.
+ *
+ * @param <code>writable</code> <code>true</code> to set write permission,
+ * <code>false</code> to unset write permission.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setWritable(boolean, boolean)
+ * @since 1.6
+ */
+ public boolean setWritable(boolean writable)
+ {
+ return setWritable(writable, true);
+ }
+
+ /**
+ * This method sets the write permissions for the File represented by
+ * this object.
+ *
+ * If <code>ownerOnly</code> is set to <code>true</code> then only the
+ * write permission bit for the owner of the file is changed.
+ *
+ * If <code>ownerOnly</code> is set to <code>false</code>, the file
+ * permissions are changed so that the file can be written by everyone.
+ *
+ * On unix like systems this set the <code>user</code>, <code>group</code>
+ * and <code>other</code> write bits and is equal to call
+ * <code>chmod a+w</code> on the file.
+ *
+ * @param <code>writable</code> <code>true</code> to set write permission,
+ * <code>false</code> to unset write permission.
+ * @param <code>ownerOnly</code> <code>true</code> to set write permission
+ * for owner only, <code>false</code> for all.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setWritable(boolean)
+ * @since 1.6
+ */
+ public boolean setWritable(boolean writable, boolean ownerOnly)
+ {
+ checkWrite();
+ return VMFile.setWritable(path, writable, ownerOnly);
+ }
+
+ /**
+ * This method sets the owner's execute permission for the File represented
+ * by this object.
+ *
+ * It is the same as calling <code>setExecutable(readable, true)</code>.
+ *
+ * @param <code>executable</code> <code>true</code> to set execute permission,
+ * <code>false</code> to unset execute permission.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setExecutable(boolean, boolean)
+ * @since 1.6
+ */
+ public boolean setExecutable(boolean executable)
+ {
+ return setExecutable(executable, true);
+ }
+
+ /**
+ * This method sets the execute permissions for the File represented by
+ * this object.
+ *
+ * If <code>ownerOnly</code> is set to <code>true</code> then only the
+ * execute permission bit for the owner of the file is changed.
+ *
+ * If <code>ownerOnly</code> is set to <code>false</code>, the file
+ * permissions are changed so that the file can be executed by everyone.
+ *
+ * On unix like systems this set the <code>user</code>, <code>group</code>
+ * and <code>other</code> write bits and is equal to call
+ * <code>chmod a+x</code> on the file.
+ *
+ * @param <code>executable</code> <code>true</code> to set write permission,
+ * <code>false</code> to unset write permission.
+ * @param <code>ownerOnly</code> <code>true</code> to set write permission
+ * for owner only, <code>false</code> for all.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setExecutable(boolean)
+ * @since 1.6
+ */
+ public boolean setExecutable(boolean executable, boolean ownerOnly)
+ {
+ checkWrite();
+ return VMFile.setExecutable(path, executable, ownerOnly);
+ }
+
+ /**
* This method sets the file represented by this object to be read only.
* A read only file or directory cannot be modified. Please note that
* GNU systems allow read only files to be deleted if the directory it
@@ -1315,6 +1485,15 @@ public class File implements Serializable, Comparable<File>
s.checkRead(path);
}
+ private void checkExec()
+ {
+ // Check the SecurityManager
+ SecurityManager s = System.getSecurityManager();
+
+ if (s != null)
+ s.checkExec(path);
+ }
+
/**
* Calling this method requests that the file represented by this object
* be deleted when the virtual machine exits. Note that this request cannot
diff --git a/libjava/classpath/java/io/ObjectInputStream.java b/libjava/classpath/java/io/ObjectInputStream.java
index 735d46c..37b2b64 100644
--- a/libjava/classpath/java/io/ObjectInputStream.java
+++ b/libjava/classpath/java/io/ObjectInputStream.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.io;
+import gnu.classpath.Pair;
import gnu.classpath.VMStackWalker;
import java.lang.reflect.Array;
@@ -50,10 +51,11 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.Map;
import java.util.TreeSet;
-import java.util.Vector;
/**
* @author Tom Tromey (tromey@redhat.com)
@@ -104,7 +106,7 @@ public class ObjectInputStream extends InputStream
this.blockDataInput = new DataInputStream(this);
this.realInputStream = new DataInputStream(in);
this.nextOID = baseWireHandle;
- this.objectLookupTable = new Vector<Object>();
+ handles = new HashMap<Integer,Pair<Boolean,Object>>();
this.classLookupTable = new Hashtable<Class,ObjectStreamClass>();
setBlockDataMode(true);
readStreamHeader();
@@ -132,6 +134,70 @@ public class ObjectInputStream extends InputStream
public final Object readObject()
throws ClassNotFoundException, IOException
{
+ return readObject(true);
+ }
+
+ /**
+ * <p>
+ * Returns the next deserialized object read from the
+ * underlying stream in an unshared manner. Any object
+ * returned by this method will not be returned by
+ * subsequent calls to either this method or {@link #readObject()}.
+ * </p>
+ * <p>
+ * This behaviour is achieved by:
+ * </p>
+ * <ul>
+ * <li>Marking the handles created by successful calls to this
+ * method, so that future calls to {@link #readObject()} or
+ * {@link #readUnshared()} will throw an {@link ObjectStreamException}
+ * rather than returning the same object reference.</li>
+ * <li>Throwing an {@link ObjectStreamException} if the next
+ * element in the stream is a reference to an earlier object.</li>
+ * </ul>
+ *
+ * @return a reference to the deserialized object.
+ * @throws ClassNotFoundException if the class of the object being
+ * deserialized can not be found.
+ * @throws StreamCorruptedException if information in the stream
+ * is inconsistent.
+ * @throws ObjectStreamException if the next object has already been
+ * returned by an earlier call to this
+ * method or {@link #readObject()}.
+ * @throws OptionalDataException if primitive data occurs next in the stream.
+ * @throws IOException if an I/O error occurs from the stream.
+ * @since 1.4
+ * @see #readObject()
+ */
+ public Object readUnshared()
+ throws IOException, ClassNotFoundException
+ {
+ return readObject(false);
+ }
+
+ /**
+ * Returns the next deserialized object read from the underlying stream.
+ *
+ * This method can be overriden by a class by implementing
+ * <code>private void readObject (ObjectInputStream)</code>.
+ *
+ * If an exception is thrown from this method, the stream is left in
+ * an undefined state. This method can also throw Errors and
+ * RuntimeExceptions if caused by existing readResolve() user code.
+ *
+ * @param shared true if handles created by this call should be shared
+ * with later calls.
+ * @return The object read from the underlying stream.
+ *
+ * @exception ClassNotFoundException The class that an object being
+ * read in belongs to cannot be found.
+ *
+ * @exception IOException Exception from underlying
+ * <code>InputStream</code>.
+ */
+ private final Object readObject(boolean shared)
+ throws ClassNotFoundException, IOException
+ {
if (this.useSubclassMethod)
return readObjectOverride();
@@ -146,7 +212,7 @@ public class ObjectInputStream extends InputStream
try
{
- ret_val = parseContent(marker);
+ ret_val = parseContent(marker, shared);
}
finally
{
@@ -163,13 +229,15 @@ public class ObjectInputStream extends InputStream
* byte indicating its type.
*
* @param marker the byte marker.
+ * @param shared true if handles created by this call should be shared
+ * with later calls.
* @return an object which represents the parsed content.
* @throws ClassNotFoundException if the class of an object being
* read in cannot be found.
* @throws IOException if invalid data occurs or one is thrown by the
* underlying <code>InputStream</code>.
*/
- private Object parseContent(byte marker)
+ private Object parseContent(byte marker, boolean shared)
throws ClassNotFoundException, IOException
{
Object ret_val;
@@ -207,6 +275,9 @@ public class ObjectInputStream extends InputStream
int oid = realInputStream.readInt();
if(dump) dumpElementln(Integer.toHexString(oid));
ret_val = lookupHandle(oid);
+ if (!shared)
+ throw new
+ InvalidObjectException("References can not be read unshared.");
break;
}
@@ -215,7 +286,7 @@ public class ObjectInputStream extends InputStream
if(dump) dumpElementln("CLASS");
ObjectStreamClass osc = (ObjectStreamClass)readObject();
Class clazz = osc.forClass();
- assignNewHandle(clazz);
+ assignNewHandle(clazz,shared);
ret_val = clazz;
break;
}
@@ -229,7 +300,7 @@ public class ObjectInputStream extends InputStream
// TC_PROXYCLASSDESC newHandle proxyClassDescInfo
// i.e. we have to assign the handle immediately after
// reading the marker.
- int handle = assignNewHandle("Dummy proxy");
+ int handle = assignNewHandle("Dummy proxy",shared);
/* END GCJ LOCAL */
int n_intf = this.realInputStream.readInt();
@@ -260,7 +331,7 @@ public class ObjectInputStream extends InputStream
}
}
/* GCJ LOCAL */
- rememberHandle(osc,handle);
+ rememberHandle(osc,shared,handle);
/* END GCJ LOCAL */
if (!is_consumed)
@@ -301,7 +372,8 @@ public class ObjectInputStream extends InputStream
if(dump) dumpElement("STRING=");
String s = this.realInputStream.readUTF();
if(dump) dumpElementln(s);
- ret_val = processResolution(null, s, assignNewHandle(s));
+ ret_val = processResolution(null, s, assignNewHandle(s,shared),
+ shared);
break;
}
@@ -314,12 +386,12 @@ public class ObjectInputStream extends InputStream
int length = this.realInputStream.readInt();
if(dump) dumpElementln (length + "; COMPONENT TYPE=" + componentType);
Object array = Array.newInstance(componentType, length);
- int handle = assignNewHandle(array);
+ int handle = assignNewHandle(array,shared);
readArrayElements(array, componentType);
if(dump)
for (int i = 0, len = Array.getLength(array); i < len; i++)
dumpElementln(" ELEMENT[" + i + "]=", Array.get(array, i));
- ret_val = processResolution(null, array, handle);
+ ret_val = processResolution(null, array, handle, shared);
break;
}
@@ -337,7 +409,7 @@ public class ObjectInputStream extends InputStream
{
Externalizable obj = osc.newInstance();
- int handle = assignNewHandle(obj);
+ int handle = assignNewHandle(obj,shared);
boolean read_from_blocks = ((osc.getFlags() & SC_BLOCK_DATA) != 0);
@@ -355,14 +427,14 @@ public class ObjectInputStream extends InputStream
throw new IOException("No end of block data seen for class with readExternal (ObjectInputStream) method.");
}
- ret_val = processResolution(osc, obj, handle);
+ ret_val = processResolution(osc, obj, handle,shared);
break;
} // end if (osc.realClassIsExternalizable)
Object obj = newObject(clazz, osc.firstNonSerializableParentConstructor);
- int handle = assignNewHandle(obj);
+ int handle = assignNewHandle(obj,shared);
Object prevObject = this.currentObject;
ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass;
TreeSet<ValidatorAndPriority> prevObjectValidators =
@@ -404,7 +476,7 @@ public class ObjectInputStream extends InputStream
byte writeMarker = this.realInputStream.readByte();
while (writeMarker != TC_ENDBLOCKDATA)
{
- parseContent(writeMarker);
+ parseContent(writeMarker, shared);
writeMarker = this.realInputStream.readByte();
}
if(dump) dumpElementln("yes");
@@ -419,7 +491,7 @@ public class ObjectInputStream extends InputStream
this.currentObject = prevObject;
this.currentObjectStreamClass = prevObjectStreamClass;
- ret_val = processResolution(osc, obj, handle);
+ ret_val = processResolution(osc, obj, handle, shared);
if (currentObjectValidators != null)
invokeValidators();
this.currentObjectValidators = prevObjectValidators;
@@ -453,7 +525,7 @@ public class ObjectInputStream extends InputStream
dumpElementln("CONSTANT NAME = " + constantName);
Class clazz = osc.forClass();
Enum instance = Enum.valueOf(clazz, constantName);
- assignNewHandle(instance);
+ assignNewHandle(instance,shared);
ret_val = instance;
break;
}
@@ -554,7 +626,7 @@ public class ObjectInputStream extends InputStream
ObjectStreamField[] fields = new ObjectStreamField[field_count];
ObjectStreamClass osc = new ObjectStreamClass(name, uid,
flags, fields);
- assignNewHandle(osc);
+ assignNewHandle(osc,true);
for (int i = 0; i < field_count; i++)
{
@@ -1555,13 +1627,15 @@ public class ObjectInputStream extends InputStream
* Assigns the next available handle to <code>obj</code>.
*
* @param obj The object for which we want a new handle.
+ * @param shared True if the handle should be shared
+ * with later calls.
* @return A valid handle for the specified object.
*/
- private int assignNewHandle(Object obj)
+ private int assignNewHandle(Object obj, boolean shared)
{
int handle = this.nextOID;
this.nextOID = handle + 1;
- rememberHandle(obj,handle);
+ rememberHandle(obj,shared,handle);
return handle;
}
@@ -1569,40 +1643,44 @@ public class ObjectInputStream extends InputStream
* Remember the object associated with the given handle.
*
* @param obj an object
- *
+ * @param shared true if the reference should be shared
+ * with later calls.
* @param handle a handle, must be >= baseWireHandle
*
* @see #lookupHandle
*/
- private void rememberHandle(Object obj, int handle)
+ private void rememberHandle(Object obj, boolean shared,
+ int handle)
{
- Vector olt = this.objectLookupTable;
- handle = handle - baseWireHandle;
-
- if (olt.size() <= handle)
- olt.setSize(handle + 1);
-
- olt.set(handle, obj);
+ handles.put(handle, new Pair<Boolean,Object>(shared, obj));
}
/**
* Look up the object associated with a given handle.
*
* @param handle a handle, must be >= baseWireHandle
- *
* @return the object remembered for handle or null if none.
- *
+ * @throws StreamCorruptedException if the handle is invalid.
+ * @throws InvalidObjectException if the reference is not shared.
* @see #rememberHandle
*/
private Object lookupHandle(int handle)
+ throws ObjectStreamException
{
- Vector olt = this.objectLookupTable;
- handle = handle - baseWireHandle;
- Object result = handle < olt.size() ? olt.get(handle) : null;
- return result;
+ Pair<Boolean,Object> result = handles.get(handle);
+ if (result == null)
+ throw new StreamCorruptedException("The handle, " +
+ Integer.toHexString(handle) +
+ ", is invalid.");
+ if (!result.getLeft())
+ throw new InvalidObjectException("The handle, " +
+ Integer.toHexString(handle) +
+ ", is not shared.");
+ return result.getRight();
}
- private Object processResolution(ObjectStreamClass osc, Object obj, int handle)
+ private Object processResolution(ObjectStreamClass osc, Object obj, int handle,
+ boolean shared)
throws IOException
{
if (osc != null && obj instanceof Serializable)
@@ -1633,13 +1711,34 @@ public class ObjectInputStream extends InputStream
if (this.resolveEnabled)
obj = resolveObject(obj);
- rememberHandle(obj, handle);
+ rememberHandle(obj, shared, handle);
+ if (!shared)
+ {
+ if (obj instanceof byte[])
+ return ((byte[]) obj).clone();
+ if (obj instanceof short[])
+ return ((short[]) obj).clone();
+ if (obj instanceof int[])
+ return ((int[]) obj).clone();
+ if (obj instanceof long[])
+ return ((long[]) obj).clone();
+ if (obj instanceof char[])
+ return ((char[]) obj).clone();
+ if (obj instanceof boolean[])
+ return ((boolean[]) obj).clone();
+ if (obj instanceof float[])
+ return ((float[]) obj).clone();
+ if (obj instanceof double[])
+ return ((double[]) obj).clone();
+ if (obj instanceof Object[])
+ return ((Object[]) obj).clone();
+ }
return obj;
}
private void clearHandles()
{
- this.objectLookupTable.clear();
+ handles.clear();
this.nextOID = baseWireHandle;
}
@@ -1966,7 +2065,7 @@ public class ObjectInputStream extends InputStream
private boolean useSubclassMethod;
private int nextOID;
private boolean resolveEnabled;
- private Vector<Object> objectLookupTable;
+ private Map<Integer,Pair<Boolean,Object>> handles;
private Object currentObject;
private ObjectStreamClass currentObjectStreamClass;
private TreeSet<ValidatorAndPriority> currentObjectValidators;
diff --git a/libjava/classpath/java/io/ObjectOutputStream.java b/libjava/classpath/java/io/ObjectOutputStream.java
index 316b907..b1894b3 100644
--- a/libjava/classpath/java/io/ObjectOutputStream.java
+++ b/libjava/classpath/java/io/ObjectOutputStream.java
@@ -170,6 +170,7 @@ public class ObjectOutputStream extends OutputStream
* If an exception is thrown from this method, the stream is left in
* an undefined state.
*
+ * @param obj the object to serialize.
* @exception NotSerializableException An attempt was made to
* serialize an <code>Object</code> that is not serializable.
*
@@ -178,9 +179,71 @@ public class ObjectOutputStream extends OutputStream
*
* @exception IOException Exception from underlying
* <code>OutputStream</code>.
+ * @see #writeUnshared(Object)
*/
public final void writeObject(Object obj) throws IOException
{
+ writeObject(obj, true);
+ }
+
+ /**
+ * Writes an object to the stream in the same manner as
+ * {@link #writeObject(Object)}, but without the use of
+ * references. As a result, the object is always written
+ * to the stream in full. Likewise, if an object is written
+ * by this method and is then later written again by
+ * {@link #writeObject(Object)}, both calls will write out
+ * the object in full, as the later call to
+ * {@link #writeObject(Object)} will know nothing of the
+ * earlier use of {@link #writeUnshared(Object)}.
+ *
+ * @param obj the object to serialize.
+ * @throws NotSerializableException if the object being
+ * serialized does not implement
+ * {@link Serializable}.
+ * @throws InvalidClassException if a problem occurs with
+ * the class of the object being
+ * serialized.
+ * @throws IOException if an I/O error occurs on the underlying
+ * <code>OutputStream</code>.
+ * @since 1.4
+ * @see #writeObject(Object)
+ */
+ public void writeUnshared(Object obj)
+ throws IOException
+ {
+ writeObject(obj, false);
+ }
+
+ /**
+ * Writes a representation of <code>obj</code> to the underlying
+ * output stream by writing out information about its class, then
+ * writing out each of the objects non-transient, non-static
+ * fields. If any of these fields are other objects,
+ * they are written out in the same manner.
+ *
+ * This method can be overriden by a class by implementing
+ * <code>private void writeObject (ObjectOutputStream)</code>.
+ *
+ * If an exception is thrown from this method, the stream is left in
+ * an undefined state.
+ *
+ * @param obj the object to serialize.
+ * @param shared true if the serialized object should be
+ * shared with later calls.
+ * @exception NotSerializableException An attempt was made to
+ * serialize an <code>Object</code> that is not serializable.
+ *
+ * @exception InvalidClassException Somebody tried to serialize
+ * an object which is wrongly formatted.
+ *
+ * @exception IOException Exception from underlying
+ * <code>OutputStream</code>.
+ * @see #writeUnshared(Object)
+ */
+ private final void writeObject(Object obj, boolean shared)
+ throws IOException
+ {
if (useSubclassMethod)
{
if (dump)
@@ -212,7 +275,7 @@ public class ObjectOutputStream extends OutputStream
}
int handle = findHandle(obj);
- if (handle >= 0)
+ if (handle >= 0 && shared)
{
realOutput.writeByte(TC_REFERENCE);
realOutput.writeInt(handle);
@@ -243,7 +306,8 @@ public class ObjectOutputStream extends OutputStream
writeObject(osc.getSuper());
}
- assignNewHandle(obj);
+ if (shared)
+ assignNewHandle(obj);
break;
}
@@ -263,7 +327,8 @@ public class ObjectOutputStream extends OutputStream
/* TC_ENUM classDesc newHandle enumConstantName */
realOutput.writeByte(TC_ENUM);
writeObject(osc);
- assignNewHandle(obj);
+ if (shared)
+ assignNewHandle(obj);
writeObject(((Enum) obj).name());
break;
}
@@ -299,7 +364,8 @@ public class ObjectOutputStream extends OutputStream
if (obj instanceof String)
{
realOutput.writeByte(TC_STRING);
- assignNewHandle(obj);
+ if (shared)
+ assignNewHandle(obj);
realOutput.writeUTF((String)obj);
break;
}
@@ -308,7 +374,8 @@ public class ObjectOutputStream extends OutputStream
{
realOutput.writeByte(TC_ARRAY);
writeObject(osc);
- assignNewHandle(obj);
+ if (shared)
+ assignNewHandle(obj);
writeArraySizeAndElements(obj, clazz.getComponentType());
break;
}
@@ -316,11 +383,12 @@ public class ObjectOutputStream extends OutputStream
realOutput.writeByte(TC_OBJECT);
writeObject(osc);
- if (replaceDone)
- assignNewHandle(replacedObject);
- else
- assignNewHandle(obj);
-
+ if (shared)
+ if (replaceDone)
+ assignNewHandle(replacedObject);
+ else
+ assignNewHandle(obj);
+
if (obj instanceof Externalizable)
{
if (protocolVersion == PROTOCOL_VERSION_2)
diff --git a/libjava/classpath/java/io/StreamTokenizer.java b/libjava/classpath/java/io/StreamTokenizer.java
index b4695ab..759aa9a 100644
--- a/libjava/classpath/java/io/StreamTokenizer.java
+++ b/libjava/classpath/java/io/StreamTokenizer.java
@@ -330,6 +330,7 @@ public class StreamTokenizer
{
while ((ch = in.read()) != '\n' && ch != '\r' && ch != TT_EOF)
;
+
if (ch != TT_EOF)
in.unread(ch);
return nextToken(); // Recursive, but not too deep in normal cases
@@ -431,6 +432,7 @@ public class StreamTokenizer
{
while ((ch = in.read()) != '\n' && ch != '\r' && ch != TT_EOF)
;
+
if (ch != TT_EOF)
in.unread(ch);
return nextToken(); // Recursive, but not too deep in normal cases.
diff --git a/libjava/classpath/java/io/class-dependencies.conf b/libjava/classpath/java/io/class-dependencies.conf
deleted file mode 100644
index 633bb17..0000000
--- a/libjava/classpath/java/io/class-dependencies.conf
+++ /dev/null
@@ -1,100 +0,0 @@
-# This property file contains dependencies of classes, methods, and
-# field on other methods or classes.
-#
-# Syntax:
-#
-# <used>: <needed 1> [... <needed N>]
-#
-# means that when <used> is included, <needed 1> (... <needed N>) must
-# be included as well.
-#
-# <needed X> and <used> are of the form
-#
-# <class.methodOrField(signature)>
-#
-# or just
-#
-# <class>
-#
-# Within dependencies, variables can be used. A variable is defined as
-# follows:
-#
-# {variable}: value1 value2 ... value<n>
-#
-# variables can be used on the right side of dependencies as follows:
-#
-# <used>: com.bla.blu.{variable}.Class.m()V
-#
-# The use of the variable will expand to <n> dependencies of the form
-#
-# <used>: com.bla.blu.value1.Class.m()V
-# <used>: com.bla.blu.value2.Class.m()V
-# ...
-# <used>: com.bla.blu.value<n>.Class.m()V
-#
-# Variables can be redefined when building a system to select the
-# required support for features like encodings, protocols, etc.
-#
-# Hints:
-#
-# - For methods and fields, the signature is mandatory. For
-# specification, please see the Java Virtual Machine Specification by
-# SUN. Unlike in the spec, field signatures (types) are in brackets.
-#
-# - Package names must be separated by '/' (and not '.'). E.g.,
-# java/lang/Class (this is necessary, because the '.' is used to
-# separate method or field names from classes)
-#
-# - In case <needed> refers to a class, only the class itself will be
-# included in the resulting binary, NOT necessarily all its methods
-# and fields. If you want to refer to all methods and fields, you can
-# write class.* as an abbreviation.
-#
-# - Abbreviations for packages are also possible: my/package/* means all
-# methods and fields of all classes in my/package.
-#
-# - A line with a trailing '\' continues in the next line.
-
-java/io/File: \
- java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
- java/lang/InternalError.<init>(Ljava/lang/String;)V \
- java/io/IOException.<init>(Ljava/lang/String;)V \
- java/lang/IllegalArgumentException.<init>(Ljava/lang/String;)V
-
-java/io/FileDescriptor: \
- java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
- java/lang/InternalError.<init>(Ljava/lang/String;)V \
- java/lang/IllegalArgumentException.<init>(Ljava/lang/String;)V \
- java/io/IOException.<init>(Ljava/lang/String;)V
-
-java/io/FileInputStream: \
- java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
- java/lang/InternalError.<init>(Ljava/lang/String;)V \
- java/io/IOException.<init>(Ljava/lang/String;)V \
- java/io/FileNotFoundException.<init>(Ljava/lang/String;)V
-
-java/io/FileOutputStream: \
- java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
- java/lang/InternalError.<init>(Ljava/lang/String;)V \
- java/io/FileNotFoundException.<init>(Ljava/lang/String;)V \
- java/io/IOException.<init>(Ljava/lang/String;)V
-
-java/io/ObjectInputStream: \
- java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
- java/lang/InternalError.<init>(Ljava/lang/String;)V \
- java/lang/SecurityManager.currentClassLoader()Ljava/lang/ClassLoader; \
- java/lang/IllegalArgumentException.<init>(Ljava/lang/String;)V
-
-java/io/ObjectOutputStream: \
- java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
- java/lang/InternalError.<init>(Ljava/lang/String;)V \
- java/lang/SecurityManager.currentClassLoader()Ljava/lang/ClassLoader; \
- java/lang/IllegalArgumentException.<init>(Ljava/lang/String;)V
-
-java/io/RandomAccessFile: \
- java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
- java/lang/InternalError.<init>(Ljava/lang/String;)V \
- java/io/FileNotFoundException.<init>(Ljava/lang/String;)V \
- java/io/IOException.<init>(Ljava/lang/String;)V
-
-# end of file