You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/12/09 00:13:41 UTC
svn commit: r484840 - in
/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io:
BufferedWriter.java File.java ObjectInputStream.java
ObjectOutputStream.java ObjectStreamClass.java
Author: tellison
Date: Fri Dec 8 15:13:40 2006
New Revision: 484840
URL: http://svn.apache.org/viewvc?view=rev&rev=484840
Log:
Minor compiler warnings fixed.
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/BufferedWriter.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamClass.java
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/BufferedWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/BufferedWriter.java?view=diff&rev=484840&r1=484839&r2=484840
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/BufferedWriter.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/BufferedWriter.java Fri Dec 8 15:13:40 2006
@@ -30,263 +30,260 @@
* @see BufferedReader
*/
public class BufferedWriter extends Writer {
- private Writer out;
+ private Writer out;
- private char buf[];
+ private char buf[];
- private int pos;
+ private int pos;
- private final String lineSeparator = AccessController
- .doPrivileged(new PriviAction<String>("line.separator")); //$NON-NLS-1$
+ private final String lineSeparator = AccessController
+ .doPrivileged(new PriviAction<String>("line.separator")); //$NON-NLS-1$
- /**
- * Constructs a new BufferedReader with <code>out</code> as the Writer on
- * which to buffer write operations. The buffer size is set to the default,
- * which is 8K.
- *
- * @param out
- * The Writer to buffer character writing on
- */
-
- public BufferedWriter(Writer out) {
- super(out);
- this.out = out;
- buf = new char[8192];
- }
-
- /**
- * Constructs a new BufferedReader with <code>out</code> as the Writer on
- * which buffer write operations. The buffer size is set to
- * <code>size</code>.
- *
- * @param out
- * The Writer to buffer character writing on.
- * @param size
- * The size of the buffer to use.
- */
-
- public BufferedWriter(Writer out, int size) {
- super(out);
- if (size > 0) {
- this.out = out;
- this.buf = new char[size];
- } else {
+ /**
+ * Constructs a new BufferedReader with <code>out</code> as the Writer on
+ * which to buffer write operations. The buffer size is set to the default,
+ * which is 8K.
+ *
+ * @param out
+ * The Writer to buffer character writing on
+ */
+ public BufferedWriter(Writer out) {
+ super(out);
+ this.out = out;
+ buf = new char[8192];
+ }
+
+ /**
+ * Constructs a new BufferedReader with <code>out</code> as the Writer on
+ * which buffer write operations. The buffer size is set to
+ * <code>size</code>.
+ *
+ * @param out
+ * The Writer to buffer character writing on.
+ * @param size
+ * The size of the buffer to use.
+ */
+ public BufferedWriter(Writer out, int size) {
+ super(out);
+ if (size > 0) {
+ this.out = out;
+ this.buf = new char[size];
+ } else {
throw new IllegalArgumentException(Msg.getString("K0058")); //$NON-NLS-1$
}
- }
+ }
- /**
- * Close this BufferedWriter. The contents of the buffer are flushed, the
- * target writer is closed, and the buffer is released. Only the first
- * invocation of close has any effect.
- *
- * @throws IOException
- * If an error occurs attempting to close this Writer.
- */
-
- @Override
+ /**
+ * Close this BufferedWriter. The contents of the buffer are flushed, the
+ * target writer is closed, and the buffer is released. Only the first
+ * invocation of close has any effect.
+ *
+ * @throws IOException
+ * If an error occurs attempting to close this Writer.
+ */
+ @Override
public void close() throws IOException {
- synchronized (lock) {
- if (isOpen()) {
- flush();
- out.close();
- buf = null;
- out = null;
- }
- }
- }
-
- /**
- * Flush this BufferedWriter. The contents of the buffer are committed to
- * the target writer and it is then flushed.
- *
- * @throws IOException
- * If an error occurs attempting to flush this Writer.
- */
+ synchronized (lock) {
+ if (isOpen()) {
+ flush();
+ out.close();
+ buf = null;
+ out = null;
+ }
+ }
+ }
- @Override
+ /**
+ * Flush this BufferedWriter. The contents of the buffer are committed to
+ * the target writer and it is then flushed.
+ *
+ * @throws IOException
+ * If an error occurs attempting to flush this Writer.
+ */
+ @Override
public void flush() throws IOException {
- synchronized (lock) {
- if (isOpen()) {
- if (pos > 0) {
+ synchronized (lock) {
+ if (isOpen()) {
+ if (pos > 0) {
out.write(buf, 0, pos);
}
- pos = 0;
- out.flush();
- } else {
+ pos = 0;
+ out.flush();
+ } else {
throw new IOException(Msg.getString("K005d")); //$NON-NLS-1$
}
- }
- }
-
- /**
- * Answer a boolean indicating whether or not this BufferedWriter is open.
- *
- * @return <code>true</code> if this reader is open, <code>false</code>
- * otherwise
- */
- private boolean isOpen() {
- return out != null;
- }
-
- /**
- * Write a newline to thie Writer. A newline is determined by the System
- * property "line.separator". The target writer may or may not be flushed
- * when a newline is written.
- *
- * @throws IOException
- * If an error occurs attempting to write to this Writer.
- */
-
- public void newLine() throws IOException {
- write(lineSeparator, 0, lineSeparator.length());
- }
-
- /**
- * Writes out <code>count</code> characters starting at
- * <code>offset</code> in <code>buf</code> to this BufferedWriter. If
- * <code>count</code> is greater than this Writers buffer then flush the
- * contents and also write the characters directly to the target Writer.
- *
- * @param cbuf
- * the non-null array containing characters to write.
- * @param offset
- * offset in buf to retrieve characters
- * @param count
- * maximum number of characters to write
- *
- * @throws IOException
- * If this Writer has already been closed or some other
- * IOException occurs.
- * @throws IndexOutOfBoundsException
- * If offset or count are outside of bounds.
- */
+ }
+ }
- @Override
+ /**
+ * Answer a boolean indicating whether or not this BufferedWriter is open.
+ *
+ * @return <code>true</code> if this reader is open, <code>false</code>
+ * otherwise
+ */
+ private boolean isOpen() {
+ return out != null;
+ }
+
+ /**
+ * Write a newline to thie Writer. A newline is determined by the System
+ * property "line.separator". The target writer may or may not be flushed
+ * when a newline is written.
+ *
+ * @throws IOException
+ * If an error occurs attempting to write to this Writer.
+ */
+ public void newLine() throws IOException {
+ write(lineSeparator, 0, lineSeparator.length());
+ }
+
+ /**
+ * Writes out <code>count</code> characters starting at
+ * <code>offset</code> in <code>buf</code> to this BufferedWriter. If
+ * <code>count</code> is greater than this Writers buffer then flush the
+ * contents and also write the characters directly to the target Writer.
+ *
+ * @param cbuf
+ * the non-null array containing characters to write.
+ * @param offset
+ * offset in buf to retrieve characters
+ * @param count
+ * maximum number of characters to write
+ *
+ * @throws IOException
+ * If this Writer has already been closed or some other
+ * IOException occurs.
+ * @throws IndexOutOfBoundsException
+ * If offset or count are outside of bounds.
+ */
+ @Override
public void write(char[] cbuf, int offset, int count) throws IOException {
synchronized (lock) {
if (!isOpen()) {
- throw new IOException(org.apache.harmony.luni.util.Msg
- .getString("K005d"));
- }
- if (offset < 0 || offset > cbuf.length - count || count < 0) {
- throw new IndexOutOfBoundsException();
- }
- if (pos == 0 && count >= this.buf.length) {
- out.write(cbuf, offset, count);
- return;
- }
- int available = this.buf.length - pos;
- if (count < available)
- available = count;
- if (available > 0) {
- System.arraycopy(cbuf, offset, this.buf, pos, available);
- pos += available;
- }
- if (pos == this.buf.length) {
- out.write(this.buf, 0, this.buf.length);
- pos = 0;
- if (count > available) {
- offset += available;
- available = count - available;
- if (available >= this.buf.length) {
- out.write(cbuf, offset, available);
- return;
- }
-
- System.arraycopy(cbuf, offset, this.buf, pos, available);
- pos += available;
- }
- }
+ throw new IOException(Msg.getString("K005d")); //$NON-NLS-1$
+ }
+ if (offset < 0 || offset > cbuf.length - count || count < 0) {
+ throw new IndexOutOfBoundsException();
+ }
+ if (pos == 0 && count >= this.buf.length) {
+ out.write(cbuf, offset, count);
+ return;
+ }
+ int available = this.buf.length - pos;
+ if (count < available) {
+ available = count;
+ }
+ if (available > 0) {
+ System.arraycopy(cbuf, offset, this.buf, pos, available);
+ pos += available;
+ }
+ if (pos == this.buf.length) {
+ out.write(this.buf, 0, this.buf.length);
+ pos = 0;
+ if (count > available) {
+ offset += available;
+ available = count - available;
+ if (available >= this.buf.length) {
+ out.write(cbuf, offset, available);
+ return;
+ }
+
+ System.arraycopy(cbuf, offset, this.buf, pos, available);
+ pos += available;
+ }
+ }
}
- }
+ }
- /**
- * Writes the character
- * <code>oneChar</code> BufferedWriter. If the buffer is filled by
- * writing this character, flush this Writer. Only the lower 2 bytes are written.
- *
- * @param oneChar The Character to write out.
- *
- * @throws IOException If this Writer has already been closed or some other IOException occurs.
- */
- @Override
+ /**
+ * Writes the character <code>oneChar</code> BufferedWriter. If the buffer
+ * is filled by writing this character, flush this Writer. Only the lower 2
+ * bytes are written.
+ *
+ * @param oneChar
+ * The Character to write out.
+ *
+ * @throws IOException
+ * If this Writer has already been closed or some other
+ * IOException occurs.
+ */
+ @Override
public void write(int oneChar) throws IOException {
- synchronized (lock) {
- if (isOpen()) {
- if (pos >= buf.length) {
- out.write(buf, 0, buf.length);
- pos = 0;
- }
- buf[pos++] = (char) oneChar;
- } else {
+ synchronized (lock) {
+ if (isOpen()) {
+ if (pos >= buf.length) {
+ out.write(buf, 0, buf.length);
+ pos = 0;
+ }
+ buf[pos++] = (char) oneChar;
+ } else {
throw new IOException(Msg.getString("K005d")); //$NON-NLS-1$
}
- }
- }
-
- /**
- * Writes out <code>count</code> characters starting at
- * <code>offset</code> in <code>str</code> to this BufferedWriter. If
- * <code>count</code> is greater than this Writers buffer then flush the
- * contents and also write the characters directly to the target Writer.
- *
- * @param str
- * the non-null String containing characters to write
- * @param offset
- * offset in str to retrieve characters
- * @param count
- * maximum number of characters to write
- *
- * @throws IOException
- * If this Writer has already been closed or some other
- * IOException occurs.
- * @throws ArrayIndexOutOfBoundsException
- * If offset or count are outside of bounds.
- */
+ }
+ }
- @Override
+ /**
+ * Writes out <code>count</code> characters starting at
+ * <code>offset</code> in <code>str</code> to this BufferedWriter. If
+ * <code>count</code> is greater than this Writers buffer then flush the
+ * contents and also write the characters directly to the target Writer.
+ *
+ * @param str
+ * the non-null String containing characters to write
+ * @param offset
+ * offset in str to retrieve characters
+ * @param count
+ * maximum number of characters to write
+ *
+ * @throws IOException
+ * If this Writer has already been closed or some other
+ * IOException occurs.
+ * @throws ArrayIndexOutOfBoundsException
+ * If offset or count are outside of bounds.
+ */
+ @Override
public void write(String str, int offset, int count) throws IOException {
synchronized (lock) {
if (!isOpen()) {
- throw new IOException(org.apache.harmony.luni.util.Msg
- .getString("K005d")); //$NON-NLS-1$
- }
+ throw new IOException(org.apache.harmony.luni.util.Msg
+ .getString("K005d")); //$NON-NLS-1$
+ }
if (count <= 0) {
- return;
+ return;
+ }
+ if (offset > str.length() - count || offset < 0) {
+ throw new StringIndexOutOfBoundsException();
+ }
+ if (pos == 0 && count >= buf.length) {
+ char[] chars = new char[count];
+ str.getChars(offset, offset + count, chars, 0);
+ out.write(chars, 0, count);
+ return;
+ }
+ int available = buf.length - pos;
+ if (count < available) {
+ available = count;
+ }
+ if (available > 0) {
+ str.getChars(offset, offset + available, buf, pos);
+ pos += available;
+ }
+ if (pos == buf.length) {
+ out.write(this.buf, 0, this.buf.length);
+ pos = 0;
+ if (count > available) {
+ offset += available;
+ available = count - available;
+ if (available >= buf.length) {
+ char[] chars = new char[count];
+ str.getChars(offset, offset + available, chars, 0);
+ out.write(chars, 0, available);
+ return;
+ }
+ str.getChars(offset, offset + available, buf, pos);
+ pos += available;
+ }
}
- if (offset > str.length() - count || offset < 0 ) {
- throw new StringIndexOutOfBoundsException();
- }
- if (pos == 0 && count >= buf.length) {
- char[] chars = new char[count];
- str.getChars(offset, offset + count, chars, 0);
- out.write(chars, 0, count);
- return;
- }
- int available = buf.length - pos;
- if (count < available)
- available = count;
- if (available > 0) {
- str.getChars(offset, offset + available, buf, pos);
- pos += available;
- }
- if (pos == buf.length) {
- out.write(this.buf, 0, this.buf.length);
- pos = 0;
- if (count > available) {
- offset += available;
- available = count - available;
- if (available >= buf.length) {
- char[] chars = new char[count];
- str.getChars(offset, offset + available, chars, 0);
- out.write(chars, 0, available);
- return;
- }
- str.getChars(offset, offset + available, buf, pos);
- pos += available;
- }
- }
}
- }
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java?view=diff&rev=484840&r1=484839&r2=484840
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java Fri Dec 8 15:13:40 2006
@@ -169,11 +169,8 @@
}
private String calculatePath(String dirPath, String name) {
-
dirPath = fixSlashes(dirPath);
-
- if (name != ""){
-
+ if (name != ""){ //$NON-NLS-1$
// Remove all the proceeding separator chars from name
name = fixSlashes(name);
while (name.length() > 0 && (name.charAt(0) == separatorChar)) {
@@ -183,10 +180,8 @@
// Ensure there is a separator char between dirPath and name
if (dirPath.length() > 0 && (dirPath.charAt(dirPath.length() - 1) == separatorChar)) {
return dirPath + name;
- } else {
- return dirPath + separatorChar + name;
}
-
+ return dirPath + separatorChar + name;
}
return dirPath;
@@ -1271,12 +1266,12 @@
public URI toURI() {
String name = getAbsoluteName();
try {
- if (!name.startsWith("/")) {
+ if (!name.startsWith("/")) { //$NON-NLS-1$
// start with sep.
return new URI("file", null, //$NON-NLS-1$
new StringBuilder(name.length() + 1).append('/').append(
name).toString(), null, null);
- } else if (name.startsWith("//")) {
+ } else if (name.startsWith("//")) { //$NON-NLS-1$
return new URI("file", name, null); // UNC path //$NON-NLS-1$
}
return new URI("file", null, name, null, null); //$NON-NLS-1$
@@ -1298,11 +1293,11 @@
*/
public URL toURL() throws java.net.MalformedURLException {
String name = getAbsoluteName();
- if (!name.startsWith("/")) {
+ if (!name.startsWith("/")) { //$NON-NLS-1$
// start with sep.
return new URL("file", "", -1, new StringBuilder(name.length() + 1) //$NON-NLS-1$ //$NON-NLS-2$
.append('/').append(name).toString(), null);
- } else if (name.startsWith("//")) {
+ } else if (name.startsWith("//")) { //$NON-NLS-1$
return new URL("file:" + name); // UNC path //$NON-NLS-1$
}
return new URL("file", "", -1, name, null); //$NON-NLS-1$ //$NON-NLS-2$
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java?view=diff&rev=484840&r1=484839&r2=484840
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java Fri Dec 8 15:13:40 2006
@@ -108,17 +108,17 @@
// cache for readResolve methods
private IdentityHashMap<Class<?>, Object> readResolveCache;
- private static final Hashtable<String, Class> PRIMITIVE_CLASSES = new Hashtable<String,Class>();
+ private static final Hashtable<String, Class<?>> PRIMITIVE_CLASSES = new Hashtable<String,Class<?>>();
static {
- PRIMITIVE_CLASSES.put("byte", byte.class);
- PRIMITIVE_CLASSES.put("short", short.class);
- PRIMITIVE_CLASSES.put("int", int.class);
- PRIMITIVE_CLASSES.put("long", long.class);
- PRIMITIVE_CLASSES.put("boolean", boolean.class);
- PRIMITIVE_CLASSES.put("char", char.class);
- PRIMITIVE_CLASSES.put("float", float.class);
- PRIMITIVE_CLASSES.put("double", double.class);
+ PRIMITIVE_CLASSES.put("byte", byte.class); //$NON-NLS-1$
+ PRIMITIVE_CLASSES.put("short", short.class); //$NON-NLS-1$
+ PRIMITIVE_CLASSES.put("int", int.class); //$NON-NLS-1$
+ PRIMITIVE_CLASSES.put("long", long.class); //$NON-NLS-1$
+ PRIMITIVE_CLASSES.put("boolean", boolean.class); //$NON-NLS-1$
+ PRIMITIVE_CLASSES.put("char", char.class); //$NON-NLS-1$
+ PRIMITIVE_CLASSES.put("float", float.class); //$NON-NLS-1$
+ PRIMITIVE_CLASSES.put("double", double.class); //$NON-NLS-1$
}
// Internal type used to keep track of validators & corresponding priority
@@ -1772,7 +1772,7 @@
protected Class<?> resolveProxyClass(String[] interfaceNames)
throws IOException, ClassNotFoundException {
ClassLoader loader = VM.getNonBootstrapClassLoader();
- Class[] interfaces = new Class[interfaceNames.length];
+ Class<?>[] interfaces = new Class<?>[interfaceNames.length];
for (int i = 0; i < interfaceNames.length; i++) {
interfaces[i] = Class.forName(interfaceNames[i], false, loader);
}
@@ -2371,7 +2371,7 @@
throws IOException, ClassNotFoundException {
String className = osClass.getName();
//if it is primitive class, for example, long.class
- Class cls = PRIMITIVE_CLASSES.get(className);
+ Class<?> cls = PRIMITIVE_CLASSES.get(className);
if (null == cls) {
//not primitive class
//Use the first non-null ClassLoader on the stack. If null, use the
@@ -2732,13 +2732,12 @@
}
private static String getBaseName(String fullName) {
- int k = fullName.lastIndexOf(".");
+ int k = fullName.lastIndexOf("."); //$NON-NLS-1$
if (k == -1 || k == (fullName.length() - 1)) {
return fullName;
- } else {
- return fullName.substring(k + 1);
- }
+ }
+ return fullName.substring(k + 1);
}
//Avoid recursive defining.
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java?view=diff&rev=484840&r1=484839&r2=484840
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java Fri Dec 8 15:13:40 2006
@@ -189,7 +189,7 @@
if (!mustCheck) {
try {
Method method = implementationClass.getMethod(
- "writeUnshared",
+ "writeUnshared", //$NON-NLS-1$
ObjectStreamClass.UNSHARED_PARAM_TYPES);
mustCheck = method.getDeclaringClass() != thisClass;
} catch (NoSuchMethodException e) {
@@ -954,7 +954,7 @@
if (Proxy.isProxyClass(classToWrite)) {
output.writeByte(TC_PROXYCLASSDESC);
- Class[] interfaces = classToWrite.getInterfaces();
+ Class<?>[] interfaces = classToWrite.getInterfaces();
output.writeInt(interfaces.length);
for (int i = 0; i < interfaces.length; i++) {
output.writeUTF(interfaces[i].getName());
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamClass.java?view=diff&rev=484840&r1=484839&r2=484840
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamClass.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamClass.java Fri Dec 8 15:13:40 2006
@@ -61,15 +61,15 @@
private static final int FIELD_MODIFIERS_MASK;
private static final int METHOD_MODIFIERS_MASK;
- private static final Class[] READ_PARAM_TYPES;
+ private static final Class<?>[] READ_PARAM_TYPES;
- private static final Class[] WRITE_PARAM_TYPES;
+ private static final Class<?>[] WRITE_PARAM_TYPES;
- static final Class[] EMPTY_CONSTRUCTOR_PARAM_TYPES;
+ static final Class<?>[] EMPTY_CONSTRUCTOR_PARAM_TYPES;
private static final Class<Void> VOID_CLASS;
- static final Class[] UNSHARED_PARAM_TYPES;
+ static final Class<?>[] UNSHARED_PARAM_TYPES;
private static native void oneTimeInitialization();