You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/08/26 04:11:46 UTC
svn commit: r437055 -
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/
Author: ndbeyer
Date: Fri Aug 25 19:11:43 2006
New Revision: 437055
URL: http://svn.apache.org/viewvc?rev=437055&view=rev
Log:
Code cleanup, remove compiler warnings, add braces, etc
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/EmulatedFieldsForDumping.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/EmulatedFieldsForLoading.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileOutputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermission.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterOutputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterReader.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterWriter.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStreamReader.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InvalidClassException.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/LineNumberInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/LineNumberReader.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/EmulatedFieldsForDumping.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/EmulatedFieldsForDumping.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/EmulatedFieldsForDumping.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/EmulatedFieldsForDumping.java Fri Aug 25 19:11:43 2006
@@ -64,7 +64,8 @@
* New value for the field.
*
*/
- public void put(String name, byte value) {
+ @Override
+ public void put(String name, byte value) {
emulatedFields.put(name, value);
}
@@ -78,7 +79,8 @@
* New value for the field.
*
*/
- public void put(String name, char value) {
+ @Override
+ public void put(String name, char value) {
emulatedFields.put(name, value);
}
@@ -92,7 +94,8 @@
* New value for the field.
*
*/
- public void put(String name, double value) {
+ @Override
+ public void put(String name, double value) {
emulatedFields.put(name, value);
}
@@ -106,7 +109,8 @@
* New value for the field.
*
*/
- public void put(String name, float value) {
+ @Override
+ public void put(String name, float value) {
emulatedFields.put(name, value);
}
@@ -120,7 +124,8 @@
* New value for the field.
*
*/
- public void put(String name, int value) {
+ @Override
+ public void put(String name, int value) {
emulatedFields.put(name, value);
}
@@ -134,7 +139,8 @@
* New value for the field.
*
*/
- public void put(String name, long value) {
+ @Override
+ public void put(String name, long value) {
emulatedFields.put(name, value);
}
@@ -148,7 +154,8 @@
* New value for the field.
*
*/
- public void put(String name, Object value) {
+ @Override
+ public void put(String name, Object value) {
emulatedFields.put(name, value);
}
@@ -162,7 +169,8 @@
* New value for the field.
*
*/
- public void put(String name, short value) {
+ @Override
+ public void put(String name, short value) {
emulatedFields.put(name, value);
}
@@ -176,7 +184,8 @@
* New value for the field.
*
*/
- public void put(String name, boolean value) {
+ @Override
+ public void put(String name, boolean value) {
emulatedFields.put(name, value);
}
@@ -189,7 +198,8 @@
* @throws IOException
* If an IO exception happened when writing the field values.
*/
- public void write(ObjectOutput output) throws IOException {
+ @Override
+ public void write(ObjectOutput output) throws IOException {
EmulatedFields.ObjectSlot[] slots = emulatedFields.slots();
for (int i = 0; i < slots.length; i++) {
EmulatedFields.ObjectSlot slot = slots[i];
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/EmulatedFieldsForLoading.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/EmulatedFieldsForLoading.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/EmulatedFieldsForLoading.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/EmulatedFieldsForLoading.java Fri Aug 25 19:11:43 2006
@@ -48,7 +48,7 @@
/**
* Return a boolean indicating if the field named <code>name</code> has
- * been assigned a value explicitely (false) or if it still holds a default
+ * been assigned a value explicitly (false) or if it still holds a default
* value for the type (true) because it hasn't been assigned to yet.
*
* @param name
@@ -61,7 +61,8 @@
* @throws IllegalArgumentException
* If the corresponding field can not be found.
*/
- public boolean defaulted(String name) throws IOException,
+ @Override
+ public boolean defaulted(String name) throws IOException,
IllegalArgumentException {
return emulatedFields.defaulted(name);
}
@@ -94,7 +95,8 @@
* @throws IllegalArgumentException
* If the corresponding field can not be found.
*/
- public byte get(String name, byte defaultValue) throws IOException,
+ @Override
+ public byte get(String name, byte defaultValue) throws IOException,
IllegalArgumentException {
return emulatedFields.get(name, defaultValue);
}
@@ -116,7 +118,8 @@
* @throws IllegalArgumentException
* If the corresponding field can not be found.
*/
- public char get(String name, char defaultValue) throws IOException,
+ @Override
+ public char get(String name, char defaultValue) throws IOException,
IllegalArgumentException {
return emulatedFields.get(name, defaultValue);
}
@@ -138,7 +141,8 @@
* @throws IllegalArgumentException
* If the corresponding field can not be found.
*/
- public double get(String name, double defaultValue) throws IOException,
+ @Override
+ public double get(String name, double defaultValue) throws IOException,
IllegalArgumentException {
return emulatedFields.get(name, defaultValue);
}
@@ -160,7 +164,8 @@
* @throws IllegalArgumentException
* If the corresponding field can not be found.
*/
- public float get(String name, float defaultValue) throws IOException,
+ @Override
+ public float get(String name, float defaultValue) throws IOException,
IllegalArgumentException {
return emulatedFields.get(name, defaultValue);
}
@@ -182,7 +187,8 @@
* @throws IllegalArgumentException
* If the corresponding field can not be found.
*/
- public int get(String name, int defaultValue) throws IOException,
+ @Override
+ public int get(String name, int defaultValue) throws IOException,
IllegalArgumentException {
return emulatedFields.get(name, defaultValue);
}
@@ -204,7 +210,8 @@
* @throws IllegalArgumentException
* If the corresponding field can not be found.
*/
- public long get(String name, long defaultValue) throws IOException,
+ @Override
+ public long get(String name, long defaultValue) throws IOException,
IllegalArgumentException {
return emulatedFields.get(name, defaultValue);
}
@@ -226,7 +233,8 @@
* @throws IllegalArgumentException
* If the corresponding field can not be found.
*/
- public Object get(String name, Object defaultValue) throws IOException,
+ @Override
+ public Object get(String name, Object defaultValue) throws IOException,
IllegalArgumentException {
return emulatedFields.get(name, defaultValue);
}
@@ -248,7 +256,8 @@
* @throws IllegalArgumentException
* If the corresponding field can not be found.
*/
- public short get(String name, short defaultValue) throws IOException,
+ @Override
+ public short get(String name, short defaultValue) throws IOException,
IllegalArgumentException {
return emulatedFields.get(name, defaultValue);
}
@@ -271,7 +280,8 @@
* @throws IllegalArgumentException
* If the corresponding field can not be found.
*/
- public boolean get(String name, boolean defaultValue) throws IOException,
+ @Override
+ public boolean get(String name, boolean defaultValue) throws IOException,
IllegalArgumentException {
return emulatedFields.get(name, defaultValue);
}
@@ -282,7 +292,8 @@
* @return ObjectStreamClass The class descriptor for which the emulated
* fields are defined.
*/
- public ObjectStreamClass getObjectStreamClass() {
+ @Override
+ public ObjectStreamClass getObjectStreamClass() {
return streamClass;
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileOutputStream.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileOutputStream.java Fri Aug 25 19:11:43 2006
@@ -86,8 +86,9 @@
throws FileNotFoundException {
super();
SecurityManager security = System.getSecurityManager();
- if (security != null)
- security.checkWrite(file.getPath());
+ if (security != null) {
+ security.checkWrite(file.getPath());
+ }
fd = new FileDescriptor();
fd.descriptor = fileSystem.open(file.properPath(true), append?IFileSystem.O_APPEND:IFileSystem.O_WRONLY);
channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
@@ -111,8 +112,9 @@
.getString("K006c")); //$NON-NLS-1$
}
SecurityManager security = System.getSecurityManager();
- if (security != null)
+ if (security != null) {
security.checkWrite(fd);
+ }
this.fd = fd;
channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
IFileSystem.O_WRONLY);
@@ -162,6 +164,7 @@
* @throws IOException
* If an error occurs attempting to close this FileOutputStream.
*/
+ @Override
public void close() throws IOException {
if (fd == null) {
// if fd is null, then the underlying file is not opened, so nothing
@@ -181,7 +184,7 @@
}
} else {
/*
- * if the FileOutputStream is constructed sucessfully, then channel
+ * if the FileOutputStream is constructed successfully, then channel
* must be closed, which will close the underlying file
*/
synchronized (channel) {
@@ -205,7 +208,8 @@
* If an error occurs attempting to finalize this
* FileOutputStream.
*/
- protected void finalize() throws IOException {
+ @Override
+ protected void finalize() throws IOException {
close();
}
@@ -249,7 +253,8 @@
* If an error occurs attempting to write to this
* FileOutputStream.
*/
- public void write(byte[] buffer) throws IOException {
+ @Override
+ public void write(byte[] buffer) throws IOException {
write(buffer, 0, buffer.length);
}
@@ -273,7 +278,8 @@
* @throws NullPointerException
* If buffer is <code>null</code>.
*/
- public void write(byte[] buffer, int offset, int count) throws IOException {
+ @Override
+ public void write(byte[] buffer, int offset, int count) throws IOException {
if (buffer == null) {
throw new NullPointerException();
}
@@ -300,7 +306,8 @@
* @throws IOException If an error occurs attempting to write to this
* FileOutputStream.
*/
- public void write(int oneByte) throws IOException {
+ @Override
+ public void write(int oneByte) throws IOException {
openCheck();
byte[] byteArray = new byte[1];
byteArray[0] = (byte)oneByte;
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermission.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermission.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermission.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermission.java Fri Aug 25 19:11:43 2006
@@ -315,15 +315,14 @@
}
}
}
- // Must have matched upto this point or it's a valid file in an include
+ // Must have matched up to this point or it's a valid file in an include
// all directory
if (pLength == thisLength) {
if (allSubdir) {
// /- implies /- or /*
return fp.allSubdir || fp.allDir ? matchedMask : 0;
- } else {
- return allDir == fp.allDir ? matchedMask : 0;
}
+ return allDir == fp.allDir ? matchedMask : 0;
}
return includeDir ? matchedMask : 0;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java Fri Aug 25 19:11:43 2006
@@ -45,15 +45,17 @@
*
* @see java.security.PermissionCollection#add(java.security.Permission)
*/
- public void add(Permission permission) {
+ @Override
+ public void add(Permission permission) {
if (!isReadOnly()) {
if (permission instanceof FilePermission) {
permissions.addElement(permission);
} else {
throw new IllegalArgumentException(permission.toString());
}
- } else
+ } else {
throw new IllegalStateException();
+ }
}
/**
@@ -61,7 +63,8 @@
*
* @see java.security.PermissionCollection#elements()
*/
- public Enumeration<Permission> elements() {
+ @Override
+ public Enumeration<Permission> elements() {
return permissions.elements();
}
@@ -71,7 +74,8 @@
*
* @see java.security.PermissionCollection#implies(java.security.Permission)
*/
- public boolean implies(Permission permission) {
+ @Override
+ public boolean implies(Permission permission) {
if (permission instanceof FilePermission) {
FilePermission fp = (FilePermission) permission;
int matchedMask = 0;
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterInputStream.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterInputStream.java Fri Aug 25 19:11:43 2006
@@ -29,7 +29,7 @@
/**
* The target InputStream which is being filtered.
*/
- protected volatile InputStream in;
+ protected InputStream in;
/**
* Constructs a new FilterInputStream on the InputStream <code>in</code>.
@@ -53,7 +53,8 @@
* @throws IOException
* If an error occurs in this stream.
*/
- public int available() throws IOException {
+ @Override
+ public int available() throws IOException {
return in.available();
}
@@ -64,7 +65,8 @@
* @throws IOException
* If an error occurs attempting to close this stream.
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
in.close();
}
@@ -81,7 +83,8 @@
* the number of bytes to be able to read before invalidating the
* mark.
*/
- public synchronized void mark(int readlimit) {
+ @Override
+ public synchronized void mark(int readlimit) {
in.mark(readlimit);
}
@@ -93,7 +96,8 @@
* @return <code>true</code> if mark() and reset() are supported,
* <code>false</code> otherwise.
*/
- public boolean markSupported() {
+ @Override
+ public boolean markSupported() {
return in.markSupported();
}
@@ -108,7 +112,8 @@
* If the stream is already closed or another IOException
* occurs.
*/
- public int read() throws IOException {
+ @Override
+ public int read() throws IOException {
return in.read();
}
@@ -126,7 +131,8 @@
* If the stream is already closed or another IOException
* occurs.
*/
- public int read(byte[] buffer) throws IOException {
+ @Override
+ public int read(byte[] buffer) throws IOException {
return read(buffer, 0, buffer.length);
}
@@ -149,7 +155,8 @@
* If the stream is already closed or another IOException
* occurs.
*/
- public int read(byte[] buffer, int offset, int count) throws IOException {
+ @Override
+ public int read(byte[] buffer, int offset, int count) throws IOException {
return in.read(buffer, offset, count);
}
@@ -163,7 +170,8 @@
* If the stream is already closed or another IOException
* occurs.
*/
- public synchronized void reset() throws IOException {
+ @Override
+ public synchronized void reset() throws IOException {
in.reset();
}
@@ -181,7 +189,8 @@
* If the stream is already closed or another IOException
* occurs.
*/
- public long skip(long count) throws IOException {
+ @Override
+ public long skip(long count) throws IOException {
return in.skip(count);
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterOutputStream.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterOutputStream.java Fri Aug 25 19:11:43 2006
@@ -15,6 +15,8 @@
package java.io;
+import org.apache.harmony.luni.util.Msg;
+
/**
* FilteredOutputStream is a class which takes an output stream and
@@ -49,7 +51,8 @@
* @throws IOException
* If an error occurs attempting to close this stream.
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
try {
flush();
} catch (IOException e) {
@@ -67,7 +70,8 @@
* If an error occurs attempting to flush this
* FilterOutputStream.
*/
- public void flush() throws IOException {
+ @Override
+ public void flush() throws IOException {
out.flush();
}
@@ -83,7 +87,8 @@
* If an error occurs attempting to write to this
* FilterOutputStream.
*/
- public void write(byte buffer[]) throws IOException {
+ @Override
+ public void write(byte buffer[]) throws IOException {
write(buffer, 0, buffer.length);
}
@@ -106,17 +111,19 @@
* @throws IndexOutOfBoundsException
* If offset or count are outside of bounds.
*/
- public void write(byte buffer[], int offset, int count) throws IOException {
+ @Override
+ public void write(byte buffer[], int offset, int count) throws IOException {
// avoid int overflow, check null buffer
if (offset <= buffer.length && 0 <= offset && 0 <= count
&& count <= buffer.length - offset) {
- for (int i = 0; i < count; i++)
- // Call write() instead of out.write() since subclasses could
+ for (int i = 0; i < count; i++) {
+ // Call write() instead of out.write() since subclasses could
// override the write() method.
write(buffer[offset + i]);
- } else
- throw new ArrayIndexOutOfBoundsException(org.apache.harmony.luni.util.Msg
- .getString("K002f")); //$NON-NLS-1$
+ }
+ } else {
+ throw new ArrayIndexOutOfBoundsException(Msg.getString("K002f")); //$NON-NLS-1$
+ }
}
/**
@@ -131,7 +138,8 @@
* If an error occurs attempting to write to this
* FilterOutputStream.
*/
- public void write(int oneByte) throws IOException {
+ @Override
+ public void write(int oneByte) throws IOException {
out.write(oneByte);
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterReader.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterReader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterReader.java Fri Aug 25 19:11:43 2006
@@ -48,7 +48,8 @@
* @throws IOException
* If an error occurs attempting to close this Reader.
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
synchronized (lock) {
in.close();
}
@@ -70,7 +71,8 @@
* @throws IOException
* If an error occurs attempting mark this Reader.
*/
- public synchronized void mark(int readlimit) throws IOException {
+ @Override
+ public synchronized void mark(int readlimit) throws IOException {
synchronized (lock) {
in.mark(readlimit);
}
@@ -83,7 +85,8 @@
*
* @return indicates whether or not mark() and reset() are supported.
*/
- public boolean markSupported() {
+ @Override
+ public boolean markSupported() {
synchronized (lock) {
return in.markSupported();
}
@@ -99,7 +102,8 @@
* @throws IOException
* If an error occurs attempting to read from this Reader.
*/
- public int read() throws IOException {
+ @Override
+ public int read() throws IOException {
synchronized (lock) {
return in.read();
}
@@ -123,7 +127,8 @@
* @throws IOException
* If an error occurs attempting to read from this Reader.
*/
- public int read(char[] buffer, int offset, int count) throws IOException {
+ @Override
+ public int read(char[] buffer, int offset, int count) throws IOException {
synchronized (lock) {
return in.read(buffer, offset, count);
}
@@ -145,7 +150,8 @@
* occurs.
*/
- public boolean ready() throws IOException {
+ @Override
+ public boolean ready() throws IOException {
synchronized (lock) {
return in.ready();
}
@@ -160,10 +166,11 @@
* action is to throw <code>IOException</code>.
*
* @throws IOException
- * if a problem occured or the target Reader does not support
+ * if a problem occurred or the target Reader does not support
* <code>mark()/reset()</code>.
*/
- public void reset() throws IOException {
+ @Override
+ public void reset() throws IOException {
synchronized (lock) {
in.reset();
}
@@ -183,7 +190,8 @@
* If the Reader is already closed or some other IO error
* occurs.
*/
- public long skip(long count) throws IOException {
+ @Override
+ public long skip(long count) throws IOException {
synchronized (lock) {
return in.skip(count);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterWriter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterWriter.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterWriter.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterWriter.java Fri Aug 25 19:11:43 2006
@@ -51,7 +51,8 @@
* @throws java.io.IOException
* If an error occurs attempting to close this FilterWriter.
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
synchronized (lock) {
out.close();
}
@@ -64,7 +65,8 @@
* @throws java.io.IOException
* If an error occurs attempting to flush this FilterWriter.
*/
- public void flush() throws IOException {
+ @Override
+ public void flush() throws IOException {
synchronized (lock) {
out.flush();
}
@@ -86,7 +88,8 @@
* @throws java.io.IOException
* If an error occurs attempting to write to this FilterWriter.
*/
- public void write(char buffer[], int offset, int count) throws IOException {
+ @Override
+ public void write(char buffer[], int offset, int count) throws IOException {
synchronized (lock) {
out.write(buffer, offset, count);
}
@@ -103,7 +106,8 @@
* @throws java.io.IOException
* If an error occurs attempting to write to this FilterWriter.
*/
- public void write(int oneChar) throws IOException {
+ @Override
+ public void write(int oneChar) throws IOException {
synchronized (lock) {
out.write(oneChar);
}
@@ -125,7 +129,8 @@
* @throws java.io.IOException
* If an error occurs attempting to write to this FilterWriter.
*/
- public void write(String str, int offset, int count) throws IOException {
+ @Override
+ public void write(String str, int offset, int count) throws IOException {
synchronized (lock) {
out.write(str, offset, count);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStreamReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStreamReader.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStreamReader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStreamReader.java Fri Aug 25 19:11:43 2006
@@ -140,7 +140,8 @@
* If an error occurs attempting to close this
* InputStreamReader.
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
synchronized (lock) {
decoder = null;
if (in != null) {
@@ -313,9 +314,8 @@
}
public static String getHistoricalName(String name) {
- return (String) (historicalNames.get(name) == null ? name
- : historicalNames.get(name));
- }
+ return (!historicalNames.containsKey(name) ? name : historicalNames.get(name));
+ }
}
/**
@@ -331,7 +331,8 @@
* If the InputStreamReader is already closed or some other IO
* error occurs.
*/
- public int read() throws IOException {
+ @Override
+ public int read() throws IOException {
synchronized (lock) {
if (isOpen()) {
if (chars.limit() == chars.position()) {
@@ -342,7 +343,7 @@
}
return chars.get();
}
- throw new IOException("InputStreamReader is closed."); //$NON-NLS-1$
+ throw new IOException("InputStreamReader is closed.");
}
}
@@ -366,14 +367,16 @@
* If the InputStreamReader is already closed or some other IO
* error occurs.
*/
- public int read(char[] buf, int offset, int length) throws IOException {
+ @Override
+ public int read(char[] buf, int offset, int length) throws IOException {
synchronized (lock) {
if (isOpen()) {
if (offset < 0 || offset > buf.length - length || length < 0) {
throw new IndexOutOfBoundsException();
}
- if (length == 0)
- return 0;
+ if (length == 0) {
+ return 0;
+ }
// read at least once
if (chars.limit() == chars.position()) {
fillBuf();
@@ -403,7 +406,7 @@
chars.position(chars.position() + needChars);
return length;
}
- throw new IOException("InputStreamReader is closed."); //$NON-NLS-1$
+ throw new IOException("InputStreamReader is closed.");
}
}
@@ -458,17 +461,17 @@
* If the InputStreamReader is already closed or some other IO
* error occurs.
*/
- public boolean ready() throws IOException {
+ @Override
+ public boolean ready() throws IOException {
synchronized (lock) {
if (in == null) {
- throw new IOException("This reader has been closed!"); //$NON-NLS-1$
+ throw new IOException("This reader has been closed!");
}
try {
return chars.limit() > chars.position() || in.available() > 0;
} catch (IOException e) {
return false;
}
-
}
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InvalidClassException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InvalidClassException.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InvalidClassException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InvalidClassException.java Fri Aug 25 19:11:43 2006
@@ -74,10 +74,11 @@
* @return The receiver's message, possibly concatenated with the name of
* the class that caused the problem.
*/
- public String getMessage() {
+ @Override
+ public String getMessage() {
String msg = super.getMessage();
if (classname != null) {
- msg = classname + ';' + ' ' + msg;
+ msg = classname + "; " + msg;
}
return msg;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/LineNumberInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/LineNumberInputStream.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/LineNumberInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/LineNumberInputStream.java Fri Aug 25 19:11:43 2006
@@ -15,21 +15,23 @@
package java.io;
-
/**
* LineNumberInputStream is a filter class which counts the number of line
- * terminators from the data read from the target InputStream. A line delimeter
+ * terminators from the data read from the target InputStream. A line delimiter
* sequence is determined by '\r', '\n', or '\r\n'. When using <code>read</code>,
* the sequence is always translated into '\n'.
*
* @deprecated Use LineNumberReader
*/
+@Deprecated
public class LineNumberInputStream extends FilterInputStream {
- private int lineNumber = 0;
+ private int lineNumber;
private int markedLineNumber = -1;
- private int lastChar = -1, markedLastChar;
+ private int lastChar = -1;
+
+ private int markedLastChar;
/**
* Constructs a new LineNumberInputStream on the InputStream <code>in</code>.
@@ -55,7 +57,8 @@
*
* @throws IOException If an error occurs in this stream.
*/
- public int available() throws IOException {
+ @Override
+ public int available() throws IOException {
return in.available() / 2 + (lastChar == -1 ? 0 : 1);
}
@@ -83,7 +86,8 @@
* The number of bytes to be able to read before invalidating the
* mark.
*/
- public void mark(int readlimit) {
+ @Override
+ public void mark(int readlimit) {
in.mark(readlimit);
markedLineNumber = lineNumber;
markedLastChar = lastChar;
@@ -94,7 +98,7 @@
* result as an int. The low-order byte is returned or -1 of the end of
* stream was encountered. This implementation returns a byte from the
* target stream. The line number count is incremented if a line terminator
- * is encountered. A line delimeter sequence is determined by '\r', '\n', or
+ * is encountered. A line delimiter sequence is determined by '\r', '\n', or
* '\r\n'. In this method, the sequence is always translated into '\n'.
*
* @return int The byte read or -1 if end of stream.
@@ -103,18 +107,21 @@
* If the stream is already closed or another IOException
* occurs.
*/
- public int read() throws IOException {
+ @Override
+ public int read() throws IOException {
int currentChar = lastChar;
- if (currentChar == -1)
- currentChar = in.read();
- else
- lastChar = -1;
+ if (currentChar == -1) {
+ currentChar = in.read();
+ } else {
+ lastChar = -1;
+ }
switch (currentChar) {
case '\r':
currentChar = '\n';
lastChar = in.read();
- if (lastChar == '\n')
- lastChar = -1;
+ if (lastChar == '\n') {
+ lastChar = -1;
+ }
case '\n':
lineNumber++;
}
@@ -127,7 +134,7 @@
* <code>offset</code>. Answer the number of bytes actually read or -1 if
* no bytes were read and end of stream was encountered. This implementation
* reads bytes from the target stream. The line number count is incremented
- * if a line terminator is encountered. A line delimeter sequence is
+ * if a line terminator is encountered. A line delimiter sequence is
* determined by '\r', '\n', or '\r\n'. In this method, the sequence is
* always translated into '\n'.
*
@@ -148,7 +155,8 @@
* If <code>offset</code> or <code>count</code> are out of
* bounds.
*/
- public int read(byte[] buffer, int offset, int length) throws IOException {
+ @Override
+ public int read(byte[] buffer, int offset, int length) throws IOException {
if (buffer != null) {
// avoid int overflow
if (0 <= offset && offset <= buffer.length && 0 <= length
@@ -158,12 +166,14 @@
try {
currentChar = read();
} catch (IOException e) {
- if (i != 0)
- return i;
+ if (i != 0) {
+ return i;
+ }
throw e;
}
- if (currentChar == -1)
- return i == 0 ? -1 : i;
+ if (currentChar == -1) {
+ return i == 0 ? -1 : i;
+ }
buffer[offset + i] = (byte) currentChar;
}
return length;
@@ -184,7 +194,8 @@
* If the stream is already closed or another IOException
* occurs.
*/
- public void reset() throws IOException {
+ @Override
+ public void reset() throws IOException {
in.reset();
lineNumber = markedLineNumber;
lastChar = markedLastChar;
@@ -217,13 +228,16 @@
* If the stream is already closed or another IOException
* occurs.
*/
- public long skip(long count) throws IOException {
- if (count <= 0)
- return 0;
+ @Override
+ public long skip(long count) throws IOException {
+ if (count <= 0) {
+ return 0;
+ }
for (int i = 0; i < count; i++) {
int currentChar = read();
- if (currentChar == -1)
- return i;
+ if (currentChar == -1) {
+ return i;
+ }
}
return count;
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/LineNumberReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/LineNumberReader.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/LineNumberReader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/LineNumberReader.java Fri Aug 25 19:11:43 2006
@@ -24,11 +24,13 @@
* @see BufferedWriter
*/
public class LineNumberReader extends BufferedReader {
- private int lineNumber = 0;
+ private int lineNumber;
private int markedLineNumber = -1;
- private boolean lastWasCR = false, markedLastWasCR;
+ private boolean lastWasCR;
+
+ private boolean markedLastWasCR;
/**
* Constructs a new buffered LineNumberReader on the Reader <code>in</code>.
@@ -84,7 +86,8 @@
* @throws IOException
* If an error occurs attempting mark this LineNumberReader.
*/
- public void mark(int readlimit) throws IOException {
+ @Override
+ public void mark(int readlimit) throws IOException {
synchronized (lock) {
super.mark(readlimit);
markedLineNumber = lineNumber;
@@ -97,7 +100,7 @@
* an int. The low-order 2 bytes are returned or -1 of the end of reader was
* encountered. This implementation returns a char from the target reader.
* The line number count is incremented if a line terminator is encountered.
- * A line delimeter sequence is determined by '\r', '\n', or '\r\n'. In this
+ * A line delimiter sequence is determined by '\r', '\n', or '\r\n'. In this
* method, the sequence is always translated into '\n'.
*
* @return int The char read or -1 if end of reader.
@@ -106,11 +109,13 @@
* If the reader is already closed or another IOException
* occurs.
*/
- public int read() throws IOException {
+ @Override
+ public int read() throws IOException {
synchronized (lock) {
int ch = super.read();
- if (ch == '\n' && lastWasCR)
- ch = super.read();
+ if (ch == '\n' && lastWasCR) {
+ ch = super.read();
+ }
lastWasCR = false;
switch (ch) {
case '\r':
@@ -130,7 +135,7 @@
* <code>offset</code>. Answer the number of chars actually read or -1 if
* no chars were read and end of reader was encountered. This implementation
* reads chars from the target stream. The line number count is incremented
- * if a line terminator is encountered. A line delimeter sequence is
+ * if a line terminator is encountered. A line delimiter sequence is
* determined by '\r', '\n', or '\r\n'. In this method, the sequence is
* always translated into '\n'.
*
@@ -147,22 +152,26 @@
* occurs.
*/
- public int read(char[] buffer, int offset, int count) throws IOException {
+ @Override
+ public int read(char[] buffer, int offset, int count) throws IOException {
synchronized (lock) {
int read = super.read(buffer, offset, count);
- if (read == -1)
- return -1;
+ if (read == -1) {
+ return -1;
+ }
for (int i = 0; i < read; i++) {
char ch = buffer[offset + i];
if (ch == '\r') {
lineNumber++;
lastWasCR = true;
} else if (ch == '\n') {
- if (!lastWasCR)
- lineNumber++;
- lastWasCR = false;
- } else
+ if (!lastWasCR) {
+ lineNumber++;
+ }
lastWasCR = false;
+ } else {
+ lastWasCR = false;
+ }
}
return read;
}
@@ -182,16 +191,19 @@
* If the LineNumberReader is already closed or some other IO
* error occurs.
*/
- public String readLine() throws IOException {
+ @Override
+ public String readLine() throws IOException {
synchronized (lock) {
/* Typical Line Length */
StringBuilder result = new StringBuilder(80);
while (true) {
int character = read();
- if (character == -1)
- return result.length() != 0 ? result.toString() : null;
- if (character == '\n')
- return result.toString();
+ if (character == -1) {
+ return result.length() != 0 ? result.toString() : null;
+ }
+ if (character == '\n') {
+ return result.toString();
+ }
result.append((char) character);
}
}
@@ -208,7 +220,8 @@
* If the reader is already closed or another IOException
* occurs.
*/
- public void reset() throws IOException {
+ @Override
+ public void reset() throws IOException {
synchronized (lock) {
super.reset();
lineNumber = markedLineNumber;
@@ -245,12 +258,15 @@
* If the reader is already closed or another IOException
* occurs.
*/
- public long skip(long count) throws IOException {
+ @Override
+ public long skip(long count) throws IOException {
if (count >= 0) {
synchronized (lock) {
- for (int i = 0; i < count; i++)
- if (read() == -1)
- return i;
+ for (int i = 0; i < count; i++) {
+ if (read() == -1) {
+ return i;
+ }
+ }
return count;
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java Fri Aug 25 19:11:43 2006
@@ -838,7 +838,7 @@
/**
* Reads the next item from the stream assuming it is a cyclic reference to
- * an object previouly read. Return the actual object previously read.
+ * an object previously read. Return the actual object previously read.
*
* @return the object previously read from the stream
*
@@ -1616,7 +1616,7 @@
throw new StreamCorruptedException(Msg.getString("K00d2"));//$NON-NLS-1$
}
- Enum result = Enum.valueOf((Class) classDesc.forClass(), name);
+ Enum<?> result = Enum.valueOf((Class) classDesc.forClass(), name);
registerObjectRead(result, newHandle, unshared);
return result;
@@ -1761,7 +1761,7 @@
}
/**
- * Write a new handfle describing a cyclic reference from the stream.
+ * Write a new handle describing a cyclic reference from the stream.
*
* @return the handle read
*
@@ -2212,7 +2212,7 @@
*
* @param handle
* The handle that this object was assigned when it was read.
- * @return the object previusly read.
+ * @return the object previously read.
*
* @throws InvalidObjectException
* If there is no previously read object with this handle
@@ -2540,7 +2540,7 @@
* @param instance
* Object whose field to set
* @param declaringClass
- * Class which delares the field
+ * Class which declares the field
* @param fieldName
* Name of the field to set
* @param fieldTypeName
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java?rev=437055&r1=437054&r2=437055&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java Fri Aug 25 19:11:43 2006
@@ -35,133 +35,109 @@
* @see Externalizable
*/
public class ObjectOutputStream extends OutputStream implements ObjectOutput,
- ObjectStreamConstants {
+ ObjectStreamConstants {
- private int nestedLevels; // How many nested levels to writeObject. We may
-
- // not need this.
-
- private DataOutputStream output; // Where we write to
-
- private boolean enableReplace; // If object replacement is enabled or not
-
- private DataOutputStream primitiveTypes; // Where we write primitive
-
- // types to
-
- private ByteArrayOutputStream primitiveTypesBuffer; // Where the write
-
- // primitive types are
- // actually written to
-
- private IdentityHashMap<Object, Integer> objectsWritten; // Table mapping Object -> Integer
-
- // (handle)
-
- private int currentHandle; // All objects are assigned an ID (integer
-
- // handle)
-
- private Object currentObject; // Used by defaultWriteObject
-
- private ObjectStreamClass currentClass; // Used by defaultWriteObject
-
- private int protocolVersion; // Either
-
- // ObjectStreamConstants.PROTOCOL_VERSION_1
- // or
- // ObjectStreamConstants.PROTOCOL_VERSION_2
-
- private StreamCorruptedException nestedException; // Used to detect nested
-
- // exception when saving
- // an exception due to
- // an error
-
- private EmulatedFieldsForDumping currentPutField; // Used to keep track of
-
- // the PutField object
- // for the class/object
- // being written
-
- private boolean subclassOverridingImplementation; // Allows the receiver
-
- // to decide if it needs
- // to call
- // writeObjectOverride
-
- private IdentityHashMap<Class<?>, Object> writeReplaceCache; // cache for writeReplace
-
- // methods
-
- /**
- * Inner class to provide access to serializable fields
- */
- abstract static public class PutField {
- /**
- * @param name
- * @param value
- */
- public abstract void put(String name, boolean value);
-
- /**
- * @param name
- * @param value
- */
- public abstract void put(String name, char value);
-
- /**
- * @param name
- * @param value
- */
- public abstract void put(String name, byte value);
-
- /**
- * @param name
- * @param value
- */
- public abstract void put(String name, short value);
-
- /**
- * @param name
- * @param value
- */
- public abstract void put(String name, int value);
-
- /**
- * @param name
- * @param value
- */
- public abstract void put(String name, long value);
-
- /**
- * @param name
- * @param value
- */
- public abstract void put(String name, float value);
-
- /**
- * @param name
- * @param value
- */
- public abstract void put(String name, double value);
-
- /**
- * @param name
- * @param value
- */
- public abstract void put(String name, Object value);
-
- /**
- * @param out
- *
- * @throws IOException
- *
- * @deprecated This method is unsafe and may corrupt the output stream.
- * Use ObjectOutputStream#writeFields() instead.
- */
- public abstract void write(ObjectOutput out) throws IOException;
- }
+ /*
+ * How many nested levels to writeObject. We may not need this.
+ */
+ private int nestedLevels;
+
+ /*
+ * Where we write to
+ */
+ private DataOutputStream output;
+
+ /*
+ * If object replacement is enabled or not
+ */
+ private boolean enableReplace;
+
+ /*
+ * Where we write primitive types to
+ */
+ private DataOutputStream primitiveTypes;
+
+ /*
+ * Where the write primitive types are actually written to
+ */
+ private ByteArrayOutputStream primitiveTypesBuffer;
+
+ /*
+ * Table mapping Object -> Integer (handle)
+ */
+ private IdentityHashMap<Object, Integer> objectsWritten;
+
+ /*
+ * All objects are assigned an ID (integer handle)
+ */
+ private int currentHandle;
+
+ /*
+ * Used by defaultWriteObject
+ */
+ private Object currentObject;
+
+ /*
+ * Used by defaultWriteObject
+ */
+ private ObjectStreamClass currentClass;
+
+ /*
+ * Either ObjectStreamConstants.PROTOCOL_VERSION_1 or
+ * ObjectStreamConstants.PROTOCOL_VERSION_2
+ */
+ private int protocolVersion;
+
+ /*
+ * Used to detect nested exception when saving an exception due to an error
+ */
+ private StreamCorruptedException nestedException;
+
+ /*
+ * Used to keep track of the PutField object for the class/object being
+ * written
+ */
+ private EmulatedFieldsForDumping currentPutField;
+
+ /*
+ * Allows the receiver to decide if it needs to call writeObjectOverride
+ */
+ private boolean subclassOverridingImplementation;
+
+ /*
+ * cache for writeReplace methods
+ */
+ private IdentityHashMap<Class<?>, Object> writeReplaceCache;
+
+ /**
+ * Inner class to provide access to serializable fields
+ */
+ public static abstract class PutField {
+ public abstract void put(String name, boolean value);
+
+ public abstract void put(String name, char value);
+
+ public abstract void put(String name, byte value);
+
+ public abstract void put(String name, short value);
+
+ public abstract void put(String name, int value);
+
+ public abstract void put(String name, long value);
+
+ public abstract void put(String name, float value);
+
+ public abstract void put(String name, double value);
+
+ public abstract void put(String name, Object value);
+
+ /**
+ * @deprecated This method is unsafe and may corrupt the output stream.
+ * Use ObjectOutputStream#writeFields() instead.
+ */
+ @Deprecated
+ public abstract void write(ObjectOutput out) throws IOException;
+ }
/**
* Constructs a new <code>ObjectOutputStream</code>. The representation
@@ -174,14 +150,17 @@
* @see SecurityManager#checkPermission(java.security.Permission)
*/
protected ObjectOutputStream() throws IOException, SecurityException {
- super();
- SecurityManager currentManager = System.getSecurityManager();
- if (currentManager != null)
- currentManager.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
- // WARNING - we should throw IOException if not called from a subclass
- // according to the JavaDoc. Add the test.
- this.subclassOverridingImplementation = true;
- }
+ super();
+ SecurityManager currentManager = System.getSecurityManager();
+ if (currentManager != null) {
+ currentManager.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
+ }
+ /*
+ * WARNING - we should throw IOException if not called from a subclass
+ * according to the JavaDoc. Add the test.
+ */
+ this.subclassOverridingImplementation = true;
+ }
/**
* Constructs a new ObjectOutputStream on the OutputStream
@@ -294,7 +273,8 @@
* @throws IOException
* If an error occurs attempting to close this stream.
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
// First flush what is needed (primitive data, etc)
flush();
output.close();
@@ -323,10 +303,11 @@
*/
public void defaultWriteObject() throws IOException {
// We can't be called from just anywhere. There are rules.
- if (currentObject != null)
- writeFieldValues(currentObject, currentClass);
- else
- throw new NotActiveException();
+ if (currentObject != null) {
+ writeFieldValues(currentObject, currentClass);
+ } else {
+ throw new NotActiveException();
+ }
}
/**
@@ -336,8 +317,9 @@
* If an error occurs attempting to drain the data
*/
protected void drain() throws IOException {
- if (primitiveTypes == null)
- return;
+ if (primitiveTypes == null) {
+ return;
+ }
// If we got here we have a Stream previously created
int offset = 0;
@@ -412,8 +394,9 @@
// The Stream has to be trusted for this feature to be enabled.
// trusted means the stream's classloader has to be null
SecurityManager currentManager = System.getSecurityManager();
- if (currentManager != null)
- currentManager.checkPermission(SUBSTITUTION_PERMISSION);
+ if (currentManager != null) {
+ currentManager.checkPermission(SUBSTITUTION_PERMISSION);
+ }
}
boolean originalValue = enableReplace;
enableReplace = enable;
@@ -428,7 +411,8 @@
* If an error occurs attempting to flush this
* ObjectOutputStream.
*/
- public void flush() throws IOException {
+ @Override
+ public void flush() throws IOException {
drain();
output.flush();
}
@@ -652,8 +636,9 @@
public PutField putFields() throws IOException {
// We can't be called from just anywhere. There are rules.
if (currentObject != null) {
- if (currentPutField == null)
- computePutField();
+ if (currentPutField == null) {
+ computePutField();
+ }
return currentPutField;
}
throw new NotActiveException();
@@ -745,8 +730,8 @@
/**
* Reset the receiver. A marker is written to the stream, so that
* deserialization will also perform a rest at the same point. Objects
- * previouly written are no longer remembered, so they will be written again
- * (instead of a ciclyc reference) if found in the object graph.
+ * previously written are no longer remembered, so they will be written again
+ * (instead of a cyclical reference) if found in the object graph.
*
* @throws IOException
* If any IO problem occurred when trying to reset the receiver
@@ -754,9 +739,10 @@
public void reset() throws IOException {
// First we flush what we have
drain();
- // And dump a reset marker, so that the ObjectInputStream can reset
- // itself
- // at the same point
+ /*
+ * And dump a reset marker, so that the ObjectInputStream can reset
+ * itself at the same point
+ */
output.writeByte(TC_RESET);
// Now we reset ourselves
resetState();
@@ -813,7 +799,8 @@
* If an error occurs attempting to write to this
* ObjectOutputStream.
*/
- public void write(byte[] buffer) throws IOException {
+ @Override
+ public void write(byte[] buffer) throws IOException {
checkWritePrimitiveTypes();
primitiveTypes.write(buffer);
}
@@ -833,7 +820,8 @@
* @throws IOException
* If an error occurs attempting to write to this OutputStream.
*/
- public void write(byte[] buffer, int offset, int length) throws IOException {
+ @Override
+ public void write(byte[] buffer, int offset, int length) throws IOException {
checkWritePrimitiveTypes();
primitiveTypes.write(buffer, offset, length);
}
@@ -848,7 +836,8 @@
* @throws IOException
* If an IO exception happened when writing the byte.
*/
- public void write(int value) throws IOException {
+ @Override
+ public void write(int value) throws IOException {
checkWritePrimitiveTypes();
primitiveTypes.write(value);
}
@@ -965,8 +954,9 @@
output.writeByte(TC_PROXYCLASSDESC);
Class[] interfaces = classToWrite.getInterfaces();
output.writeInt(interfaces.length);
- for (int i = 0; i < interfaces.length; i++)
- output.writeUTF(interfaces[i].getName());
+ for (int i = 0; i < interfaces.length; i++) {
+ output.writeUTF(interfaces[i].getName());
+ }
annotateProxyClass(classToWrite);
output.writeByte(TC_ENDBLOCKDATA);
writeClassDescForClass(Proxy.class);
@@ -978,9 +968,9 @@
}
output.writeByte(TC_CLASSDESC);
- if (protocolVersion == PROTOCOL_VERSION_1)
- writeNewClassDesc(classDesc);
- else {
+ if (protocolVersion == PROTOCOL_VERSION_1) {
+ writeNewClassDesc(classDesc);
+ } else {
// So write...() methods can be used by
// subclasses during writeClassDescriptor()
primitiveTypes = output;
@@ -1105,10 +1095,11 @@
*/
public void writeFields() throws IOException {
// Has to have fields to write
- if (currentPutField != null)
- writeFieldValues(currentPutField);
- else
- throw new NotActiveException();
+ if (currentPutField != null) {
+ writeFieldValues(currentPutField);
+ } else {
+ throw new NotActiveException();
+ }
}
/**
@@ -1237,8 +1228,9 @@
.getName(), fieldDesc.getTypeString());
if (fieldDesc.isUnshared()) {
writeUnshared(field);
- } else
- writeObject(field);
+ } else {
+ writeObject(field);
+ }
}
} catch (NoSuchFieldError nsf) {
// The user defined serialPersistentFields but did not provide
@@ -1295,9 +1287,10 @@
if (object != null) {
// Fields are written from class closest to Object to leaf class
// (down the chain)
- if (classDesc.getSuperclass() != null) // Read superclass slots
- // first
+ if (classDesc.getSuperclass() != null) {
+ // first
writeHierarchy(object, classDesc.getSuperclass());
+ }
// Have to do this before calling defaultWriteObject or anything
// that calls defaultWriteObject
@@ -1319,10 +1312,11 @@
executed = true;
} catch (InvocationTargetException e) {
Throwable ex = e.getTargetException();
- if (ex instanceof RuntimeException)
- throw (RuntimeException) ex;
- else if (ex instanceof Error)
- throw (Error) ex;
+ if (ex instanceof RuntimeException) {
+ throw (RuntimeException) ex;
+ } else if (ex instanceof Error) {
+ throw (Error) ex;
+ }
throw (IOException) ex;
} catch (IllegalAccessException e) {
throw new RuntimeException(e.toString());
@@ -1344,8 +1338,9 @@
currentClass = null;
currentPutField = null;
}
- } else
- throw new NotActiveException();
+ } else {
+ throw new NotActiveException();
+ }
}
/**
@@ -1419,8 +1414,9 @@
if (componentType == Integer.TYPE) {
int[] intArray = (int[]) array;
output.writeInt(intArray.length);
- for (int i = 0; i < intArray.length; i++)
- output.writeInt(intArray[i]);
+ for (int i = 0; i < intArray.length; i++) {
+ output.writeInt(intArray[i]);
+ }
} else if (componentType == Byte.TYPE) {
byte[] byteArray = (byte[]) array;
output.writeInt(byteArray.length);
@@ -1428,33 +1424,39 @@
} else if (componentType == Character.TYPE) {
char[] charArray = (char[]) array;
output.writeInt(charArray.length);
- for (int i = 0; i < charArray.length; i++)
- output.writeChar(charArray[i]);
+ for (int i = 0; i < charArray.length; i++) {
+ output.writeChar(charArray[i]);
+ }
} else if (componentType == Short.TYPE) {
short[] shortArray = (short[]) array;
output.writeInt(shortArray.length);
- for (int i = 0; i < shortArray.length; i++)
- output.writeShort(shortArray[i]);
+ for (int i = 0; i < shortArray.length; i++) {
+ output.writeShort(shortArray[i]);
+ }
} else if (componentType == Boolean.TYPE) {
boolean[] booleanArray = (boolean[]) array;
output.writeInt(booleanArray.length);
- for (int i = 0; i < booleanArray.length; i++)
- output.writeBoolean(booleanArray[i]);
+ for (int i = 0; i < booleanArray.length; i++) {
+ output.writeBoolean(booleanArray[i]);
+ }
} else if (componentType == Long.TYPE) {
long[] longArray = (long[]) array;
output.writeInt(longArray.length);
- for (int i = 0; i < longArray.length; i++)
- output.writeLong(longArray[i]);
+ for (int i = 0; i < longArray.length; i++) {
+ output.writeLong(longArray[i]);
+ }
} else if (componentType == Float.TYPE) {
float[] floatArray = (float[]) array;
output.writeInt(floatArray.length);
- for (int i = 0; i < floatArray.length; i++)
- output.writeFloat(floatArray[i]);
+ for (int i = 0; i < floatArray.length; i++) {
+ output.writeFloat(floatArray[i]);
+ }
} else if (componentType == Double.TYPE) {
double[] doubleArray = (double[]) array;
output.writeInt(doubleArray.length);
- for (int i = 0; i < doubleArray.length; i++)
- output.writeDouble(doubleArray[i]);
+ for (int i = 0; i < doubleArray.length; i++) {
+ output.writeDouble(doubleArray[i]);
+ }
} else {
throw new InvalidClassException(org.apache.harmony.luni.util.Msg.getString(
"K00d7", arrayClass.getName())); //$NON-NLS-1$
@@ -1463,8 +1465,9 @@
// Array of Objects
Object[] objectArray = (Object[]) array;
output.writeInt(objectArray.length);
- for (int i = 0; i < objectArray.length; i++)
- writeObject(objectArray[i]);
+ for (int i = 0; i < objectArray.length; i++) {
+ writeObject(objectArray[i]);
+ }
}
return handle;
}
@@ -1540,11 +1543,12 @@
// or in the 1.2 format (PROTOCOL_VERSION_2)
// Nested "if" check to optimize checking. Second check is more
// expensive.
- if (externalizable)
- flags |= SC_BLOCK_DATA;
+ if (externalizable) {
+ flags |= SC_BLOCK_DATA;
+ }
}
output.writeByte(flags);
- if (((byte)SC_ENUM | SC_SERIALIZABLE) != classDesc.getFlags()){
+ if ((SC_ENUM | SC_SERIALIZABLE) != classDesc.getFlags()){
writeFieldDescriptors(classDesc, externalizable);
} else {
// enum write no fields
@@ -1628,9 +1632,10 @@
boolean externalizable = ObjectStreamClass.isExternalizable(theClass);
boolean serializable = ObjectStreamClass.isSerializable(theClass);
- if (!externalizable && !serializable)
- // Object is neither externalizable nor serializable. Error
+ if (!externalizable && !serializable) {
+ // Object is neither externalizable nor serializable. Error
throw new NotSerializableException(theClass.getName());
+ }
// Either serializable or externalizable, now we can save info
output.writeByte(TC_OBJECT);
@@ -1647,8 +1652,9 @@
try {
if (externalizable) {
boolean noBlockData = protocolVersion == PROTOCOL_VERSION_1;
- if (noBlockData)
- primitiveTypes = output;
+ if (noBlockData) {
+ primitiveTypes = output;
+ }
// Object is externalizable, just call its own method
((Externalizable) object).writeExternal(this);
if (noBlockData) {
@@ -1765,9 +1771,9 @@
}
// This is the spec'ed behavior in JDK 1.2. Very bizarre way to allow
// behavior overriding.
- if (subclassOverridingImplementation && !unshared)
- writeObjectOverride(object);
- else {
+ if (subclassOverridingImplementation && !unshared) {
+ writeObjectOverride(object);
+ } else {
try {
// First we need to flush primitive types if they were written
@@ -1775,8 +1781,9 @@
// Actual work, and class-based replacement should be computed
// if needed.
writeObjectInternal(object, unshared, true, true);
- if (setOutput)
- primitiveTypes = output;
+ if (setOutput) {
+ primitiveTypes = output;
+ }
} catch (IOException ioEx1) {
// This will make it pass through until the top caller. It also
// lets it pass
@@ -1827,8 +1834,9 @@
Integer handle = null;
if (!unshared) {
handle = dumpCycle(object);
- if (handle != null)
- return handle; // cyclic reference
+ if (handle != null) {
+ return handle; // cyclic reference
+ }
}
// Non-null object, first time seen...
@@ -1876,12 +1884,13 @@
// the method
} catch (InvocationTargetException ite) {
Throwable target = ite.getTargetException();
- if (target instanceof ObjectStreamException)
- throw (ObjectStreamException) target;
- else if (target instanceof Error)
- throw (Error) target;
- else
- throw (RuntimeException) target;
+ if (target instanceof ObjectStreamException) {
+ throw (ObjectStreamException) target;
+ } else if (target instanceof Error) {
+ throw (Error) target;
+ } else {
+ throw (RuntimeException) target;
+ }
}
if (classBasedReplacement != object) {
Integer replacementHandle = writeObjectInternal(
@@ -1893,8 +1902,9 @@
// (see 1F9RNT1)
// Make the original object also map to the same
// handle.
- if (replacementHandle != null)
- registerObjectWritten(object, replacementHandle);
+ if (replacementHandle != null) {
+ registerObjectWritten(object, replacementHandle);
+ }
return replacementHandle;
}
}
@@ -1917,8 +1927,9 @@
// time (see
// 1F9RNT1)
// Make the original object also map to the same handle.
- if (replacementHandle != null)
- registerObjectWritten(object, replacementHandle);
+ if (replacementHandle != null) {
+ registerObjectWritten(object, replacementHandle);
+ }
return replacementHandle;
}
}
@@ -1926,15 +1937,17 @@
// We get here if stream-based replacement produced the same object
// Is it a String ?
- if (objClass == ObjectStreamClass.STRINGCLASS) // we could also use
- // instanceof, but
+ if (objClass == ObjectStreamClass.STRINGCLASS) {
+ // instanceof, but
// == is faster
return writeNewString((String) object, unshared);
+ }
// Is it an Array ?
- if (objClass.isArray()) // We are dumping an array
- return writeNewArray(object, objClass, objClass
+ if (objClass.isArray()) {
+ return writeNewArray(object, objClass, objClass
.getComponentType(), unshared);
+ }
if (object instanceof Enum){
return writeNewEnum(object, objClass, unshared);
@@ -1948,7 +1961,7 @@
}
// write for Enum Class Desc only, which is different from other classes
- private ObjectStreamClass writeEnumDesc(Class theClass, boolean unshared)
+ private ObjectStreamClass writeEnumDesc(Class<?> theClass, boolean unshared)
throws IOException {
// write classDesc, classDesc for enum is different
ObjectStreamClass classDesc = ObjectStreamClass.lookup(theClass);
@@ -1962,15 +1975,15 @@
handle = dumpCycle(classDesc);
}
if (handle == null) {
- Class classToWrite = classDesc.forClass();
+ Class<?> classToWrite = classDesc.forClass();
// If we got here, it is a new (non-null) classDesc that will have
// to be registered as well
registerObjectWritten(classDesc);
output.writeByte(TC_CLASSDESC);
- if (protocolVersion == PROTOCOL_VERSION_1)
+ if (protocolVersion == PROTOCOL_VERSION_1) {
writeNewClassDesc(classDesc);
- else {
+ } else {
// So write...() methods can be used by
// subclasses during writeClassDescriptor()
primitiveTypes = output;
@@ -1999,7 +2012,7 @@
return classDesc;
}
- private Integer writeNewEnum(Object object, Class theClass, boolean unshared)
+ private Integer writeNewEnum(Object object, Class<?> theClass, boolean unshared)
throws IOException {
// write new Enum
EmulatedFieldsForDumping originalCurrentPutField = currentPutField; // save
@@ -2017,9 +2030,9 @@
Integer handle = registerObjectWritten(object);
ObjectStreamField[] fields = classDesc.getSuperclass().fields();
- Class declaringClass = classDesc.getSuperclass().forClass();
+ Class<?> declaringClass = classDesc.getSuperclass().forClass();
// Only write field "name" for enum class, which is the second field of
- // enum, that is fileds[1]. Ignore all non-fields and fields.length < 2
+ // enum, that is fields[1]. Ignore all non-fields and fields.length < 2
if (null != fields && fields.length > 1) {
String str = (String) getFieldObj(object, declaringClass, fields[1]
.getName(), fields[1].getTypeString());
@@ -2041,7 +2054,7 @@
}
/**
- * Method to be overriden by subclasses to write <code>object</code> into
+ * Method to be overridden by subclasses to write <code>object</code> into
* the receiver's underlying stream.
*
* @param object