From 1020ce5944edde4364baef4d371cd4f9b0dae721 Mon Sep 17 00:00:00 2001 From: doko Date: Sat, 28 Jun 2008 13:29:13 +0000 Subject: libjava/ 2008-06-28 Matthias Klose Import GNU Classpath (classpath-0_97_2-release). * Regenerate class and header files. * Regenerate auto* files. * gcj/javaprims.h: Define jobjectRefType. * jni.cc (_Jv_JNI_GetObjectRefType): New (stub only). (_Jv_JNIFunctions): Initialize GetObjectRefType. * gnu/classpath/jdwp/VMVirtualMachine.java, java/security/VMSecureRandom.java: Merge from classpath. * HACKING: Fix typo. * ChangeLog-2007: New file. * configure.ac: Set JAVAC, pass --disable-regen-headers to classpath. libjava/classpath/ 2008-06-28 Matthias Klose * m4/ac_prog_javac.m4: Disable check for JAVAC, when not configured with --enable-java-maintainer-mode. * aclocal.m4, configure: Regenerate. * native/jni/gstreamer-peer/Makefile.am: Do not link with libclasspathnative. * native/jni/gstreamer-peer/Makefile.in: Regenerate. * tools/Makefile.am, lib/Makefile.am: Use JAVAC for setting JCOMPILER, drop flags not understood by gcj. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@137223 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/classpath/java/io/BufferedReader.java | 10 +- libjava/classpath/java/io/CharArrayWriter.java | 4 +- libjava/classpath/java/io/DataInputStream.java | 54 +++++++++- libjava/classpath/java/io/DataOutputStream.java | 84 ++++++++++++---- libjava/classpath/java/io/File.java | 67 +++++++++++++ libjava/classpath/java/io/FileOutputStream.java | 2 +- libjava/classpath/java/io/ObjectInputStream.java | 15 ++- libjava/classpath/java/io/ObjectOutputStream.java | 22 ++++- libjava/classpath/java/io/ObjectStreamClass.java | 6 +- libjava/classpath/java/io/OutputStreamWriter.java | 114 +++++++++++++--------- libjava/classpath/java/io/PipedInputStream.java | 38 +++++++- libjava/classpath/java/io/PrintStream.java | 15 +-- 12 files changed, 334 insertions(+), 97 deletions(-) (limited to 'libjava/classpath/java/io') diff --git a/libjava/classpath/java/io/BufferedReader.java b/libjava/classpath/java/io/BufferedReader.java index 4849949c989..c52d15ec60c 100644 --- a/libjava/classpath/java/io/BufferedReader.java +++ b/libjava/classpath/java/io/BufferedReader.java @@ -88,11 +88,6 @@ public class BufferedReader extends Reader // This is package-private because it is used by LineNumberReader. static final int DEFAULT_BUFFER_SIZE = 8192; - /** - * The line buffer for readLine. - */ - private StringBuffer sbuf = null; - /** * Create a new BufferedReader that will read from the * specified subordinate stream with a default buffer size of 8192 chars. @@ -455,10 +450,7 @@ public class BufferedReader extends Reader pos++; return str; } - if (sbuf == null) - sbuf = new StringBuffer(200); - else - sbuf.setLength(0); + StringBuilder sbuf = new StringBuilder(200); sbuf.append(buffer, pos, i - pos); pos = i; // We only want to return null when no characters were read before diff --git a/libjava/classpath/java/io/CharArrayWriter.java b/libjava/classpath/java/io/CharArrayWriter.java index 0eead3ad35d..8cbc8aeac43 100644 --- a/libjava/classpath/java/io/CharArrayWriter.java +++ b/libjava/classpath/java/io/CharArrayWriter.java @@ -267,7 +267,7 @@ public class CharArrayWriter extends Writer * sequence is wrapped around an input buffer, the results will * depend on the current position and length of that buffer. * - * @param seq the character sequence to append. If seq is null, + * @param cs the character sequence to append. If seq is null, * then the string "null" (the string representation of null) * is appended. * @return a reference to this object. @@ -294,7 +294,7 @@ public class CharArrayWriter extends Writer * append(seq.subSequence(start,end)) when the sequence * is not null. * - * @param seq the character sequence to append. If seq is null, + * @param cs the character sequence to append. If seq is null, * then the string "null" (the string representation of null) * is appended. * @param start the index of the first Unicode character to use from diff --git a/libjava/classpath/java/io/DataInputStream.java b/libjava/classpath/java/io/DataInputStream.java index d2604b51ffa..ad43498c8d7 100644 --- a/libjava/classpath/java/io/DataInputStream.java +++ b/libjava/classpath/java/io/DataInputStream.java @@ -1,5 +1,6 @@ /* DataInputStream.java -- FilteredInputStream that implements DataInput - Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation + Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2008 + Free Software Foundation This file is part of GNU Classpath. @@ -349,7 +350,7 @@ public class DataInputStream extends FilterInputStream implements DataInput */ public final String readLine() throws IOException { - StringBuffer strb = new StringBuffer(); + StringBuilder strb = new StringBuilder(); while (true) { @@ -590,13 +591,56 @@ public class DataInputStream extends FilterInputStream implements DataInput public static final String readUTF(DataInput in) throws IOException { final int UTFlen = in.readUnsignedShort (); - byte[] buf = new byte [UTFlen]; + + return readUTF(in, UTFlen); + } + + /** + * This method is similar to readUTF, but the + * UTF-8 byte length is in 64 bits. + * This method is not public. It is used by ObjectInputStream. + * + * @return The String read + * + * @exception EOFException If end of file is reached before reading + * the String + * @exception UTFDataFormatException If the data is not in UTF-8 format + * @exception IOException If any other error occurs + * + * @see DataOutput#writeUTFLong + */ + final String readUTFLong () throws IOException + { + long l = readLong (); + if (l > Integer.MAX_VALUE) + throw new IOException("The string length > Integer.MAX_VALUE"); + final int UTFlen = (int)l; + return readUTF (this, UTFlen); + } + + /** + * This method performs the main task of readUTF and + * readUTFLong. + * + * @param in The DataInput source to read from + * + * @param len The UTF-8 byte length of the String to be read + * + * @return The String read from the source + * + * @exception IOException If an error occurs + * + * @see DataInput#readUTF + */ + private static final String readUTF(DataInput in, int len) throws IOException + { + byte[] buf = new byte [len]; // This blocks until the entire string is available rather than // doing partial processing on the bytes that are available and then // blocking. An advantage of the latter is that Exceptions // could be thrown earlier. The former is a bit cleaner. - in.readFully (buf, 0, UTFlen); + in.readFully (buf, 0, len); return convertFromUTF (buf); } @@ -703,7 +747,7 @@ public class DataInputStream extends FilterInputStream implements DataInput { // Give StringBuffer an initial estimated size to avoid // enlarge buffer frequently - StringBuffer strbuf = new StringBuffer (buf.length / 2 + 2); + StringBuilder strbuf = new StringBuilder (buf.length / 2 + 2); for (int i = 0; i < buf.length; ) { diff --git a/libjava/classpath/java/io/DataOutputStream.java b/libjava/classpath/java/io/DataOutputStream.java index 6670c2dba13..435ff76d13e 100644 --- a/libjava/classpath/java/io/DataOutputStream.java +++ b/libjava/classpath/java/io/DataOutputStream.java @@ -1,5 +1,5 @@ /* DataOutputStream.java -- Writes primitive Java datatypes to streams - Copyright (C) 1998, 2001, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 2001, 2003, 2005, 2008 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -379,19 +379,20 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput /** * Calculate the length, in bytes, of a String in Utf8 format. + * This method is package-private so that ObjectOutputStream + * may use it. The return type is long so that a long string whose + * Utf8 byte count is 64 bit long may be handled. * * @param value The String to measure * @param start String index at which to begin count * @param sum Starting Utf8 byte count * - * @throws UTFDataFormatException if result would exceed 65535 */ - private int getUTFlength(String value, int start, int sum) - throws IOException + long getUTFlength(String value, int start, long sum) { int len = value.length(); - for (int i = start; i < len && sum <= 65535; ++i) + for (int i = start; i < len; ++i) { char c = value.charAt(i); if (c >= '\u0001' && c <= '\u007f') @@ -402,9 +403,6 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput sum += 3; } - if (sum > 65535) - throw new UTFDataFormatException (); - return sum; } @@ -441,11 +439,71 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput * @see DataInput#readUTF */ public final synchronized void writeUTF(String value) throws IOException + { + long l = getUTFlength(value, 0, 0); + if (l > 65535) + throw new UTFDataFormatException (); + writeUTFShort(value, (int)l); + } + + /** + * This method performs the main task of writeUTF. + * This method is package-private because ObjectOutputStream uses it. + * + * @param value The String to write to the output in UTF format + * + * @param bytelen The UTF-8 byte length of the String. When + * this method is called, the expected byte length must have been calculated + * by getUTFlength. + * + * @exception IOException If an error occurs + * + * @see DataInput#readUTF + */ + final synchronized void writeUTFShort(String value, int bytelen) + throws IOException + { + writeShort(bytelen); + writeUTFBytes(value); + } + + /** + * This method is similar to writeUTF, but it writes the + * UTF-8 byte length in 64 bits. + * This method is not public but ObjectOutputStream uses it. + * + * @param value The String to write to the output in UTF format + * + * @param bytelen The UTF-8 byte length of the String. When + * this method is called, the expected byte length must have been calculated + * by getUTFlength. + * + * @exception IOException If an error occurs + * + */ + final synchronized void writeUTFLong(String value, long bytelen) + throws IOException + { + writeLong(bytelen); + writeUTFBytes(value); + } + + /** + * This method performes the main task of writeUTF and + * WriteUTFLong, which is to write the UTF-8 byte + * sequence to the output. + * + * @param value The String to write to the output in UTF format + * + * @exception IOException If an error occurs + * + */ + private final synchronized void writeUTFBytes(String value) + throws IOException { int len = value.length(); int i = 0; int pos = 0; - boolean lengthWritten = false; if (buf == null) buf = new byte[512]; @@ -472,14 +530,6 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput buf[pos++] = (byte) (0x80 | (0x3f & c)); } } - if (! lengthWritten) - { - if (i == len) - writeShort(pos); - else - writeShort(getUTFlength(value, i, pos)); - lengthWritten = true; - } write(buf, 0, pos); pos = 0; } diff --git a/libjava/classpath/java/io/File.java b/libjava/classpath/java/io/File.java index f34b4dd2b5c..cd11163509b 100644 --- a/libjava/classpath/java/io/File.java +++ b/libjava/classpath/java/io/File.java @@ -1292,6 +1292,73 @@ public class File implements Serializable, Comparable return VMFile.setExecutable(path, executable, ownerOnly); } + /** + * Get the total space for the partition pointed by this file path, in bytes. + * + * @return the total number of bytes in this partition. + * @since 1.6 + */ + public long getTotalSpace() + { + // check security manager. + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkPermission(new RuntimePermission("getFileSystemAttributes")); + checkRead(); + + return VMFile.getTotalSpace(path); + } + + /** + * Get the free space in the partition pointed by this file path, in bytes. + * + * @return the number of free bytes in this partition. + * @since 1.6 + */ + public long getFreeSpace() + { + // check security manager. + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkPermission(new RuntimePermission("getFileSystemAttributes")); + checkRead(); + + return VMFile.getFreeSpace(path); + } + + /** + * Get the usable space in the partition pointed by this file path, in bytes. + * This is not necessarily the same as the number returned by + * {@link #getFreeSpace()}. + * + * Implementation note: Unlike the RI, on Linux and UNIX + * like systems this methods take into account the reserved space for the + * "root" user. This means that the returned results will be a little + * different if a normal user or root perform the query. + * + * Also, the bytes returned should be interpreted as an hint, and may be + * different at each call of this method or even right after the method + * returns. + * + * @return the number of usable bytes in this partition. + * @since 1.6 + */ + public long getUsableSpace() + { + // check security manager. + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkPermission(new RuntimePermission("getFileSystemAttributes")); + checkRead(); + + // root users can use the reserved extra space + String user = System.getProperty("user.name"); + if (user != null && user.equals("root")) + return VMFile.getFreeSpace(path); + + return VMFile.getUsableSpace(path); + } + /** * 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 diff --git a/libjava/classpath/java/io/FileOutputStream.java b/libjava/classpath/java/io/FileOutputStream.java index d7561a9d79f..b012e604404 100644 --- a/libjava/classpath/java/io/FileOutputStream.java +++ b/libjava/classpath/java/io/FileOutputStream.java @@ -59,7 +59,7 @@ public class FileOutputStream extends OutputStream { private FileDescriptor fd; - private FileChannelImpl ch; + private final FileChannelImpl ch; /** * This method initializes a FileOutputStream object to write diff --git a/libjava/classpath/java/io/ObjectInputStream.java b/libjava/classpath/java/io/ObjectInputStream.java index 37b2b64489c..6b2a65133d8 100644 --- a/libjava/classpath/java/io/ObjectInputStream.java +++ b/libjava/classpath/java/io/ObjectInputStream.java @@ -1,5 +1,5 @@ /* ObjectInputStream.java -- Class used to read serialized objects - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -367,7 +367,6 @@ public class ObjectInputStream extends InputStream } case TC_STRING: - case TC_LONGSTRING: { if(dump) dumpElement("STRING="); String s = this.realInputStream.readUTF(); @@ -377,6 +376,16 @@ public class ObjectInputStream extends InputStream break; } + case TC_LONGSTRING: + { + if(dump) dumpElement("STRING="); + String s = this.realInputStream.readUTFLong(); + if(dump) dumpElementln(s); + ret_val = processResolution(null, s, assignNewHandle(s,shared), + shared); + break; + } + case TC_ARRAY: { if(dump) dumpElementln("ARRAY"); @@ -926,7 +935,7 @@ public class ObjectInputStream extends InputStream return null; ObjectStreamClass oclazz; - oclazz = (ObjectStreamClass)classLookupTable.get(clazz); + oclazz = classLookupTable.get(clazz); if (oclazz == null) return ObjectStreamClass.lookup(clazz); else diff --git a/libjava/classpath/java/io/ObjectOutputStream.java b/libjava/classpath/java/io/ObjectOutputStream.java index b1894b36882..303aed472d9 100644 --- a/libjava/classpath/java/io/ObjectOutputStream.java +++ b/libjava/classpath/java/io/ObjectOutputStream.java @@ -1,5 +1,5 @@ /* ObjectOutputStream.java -- Class used to write serialized objects - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -363,10 +363,22 @@ public class ObjectOutputStream extends OutputStream if (obj instanceof String) { - realOutput.writeByte(TC_STRING); - if (shared) - assignNewHandle(obj); - realOutput.writeUTF((String)obj); + String s = (String)obj; + long l = realOutput.getUTFlength(s, 0, 0); + if (l <= 65535) + { + realOutput.writeByte(TC_STRING); + if (shared) + assignNewHandle(obj); + realOutput.writeUTFShort(s, (int)l); + } + else + { + realOutput.writeByte(TC_LONGSTRING); + if (shared) + assignNewHandle(obj); + realOutput.writeUTFLong(s, l); + } break; } diff --git a/libjava/classpath/java/io/ObjectStreamClass.java b/libjava/classpath/java/io/ObjectStreamClass.java index 1f3ba73dc99..8ebf32c58a4 100644 --- a/libjava/classpath/java/io/ObjectStreamClass.java +++ b/libjava/classpath/java/io/ObjectStreamClass.java @@ -106,7 +106,7 @@ public class ObjectStreamClass implements Serializable if (cl == null) return null; - ObjectStreamClass osc = (ObjectStreamClass) classLookupTable.get(cl); + ObjectStreamClass osc = classLookupTable.get(cl); if (osc != null) return osc; @@ -830,7 +830,7 @@ outer: } if (loadedByBootOrApplicationClassLoader(cl)) - uidCache.put(cl,new Long(result)); + uidCache.put(cl,Long.valueOf(result)); } return result; } @@ -1074,7 +1074,7 @@ outer: try { - return (Externalizable)constructor.newInstance(null); + return (Externalizable)constructor.newInstance(); } catch(Exception x) { diff --git a/libjava/classpath/java/io/OutputStreamWriter.java b/libjava/classpath/java/io/OutputStreamWriter.java index 26363401f01..5ccceed70b0 100644 --- a/libjava/classpath/java/io/OutputStreamWriter.java +++ b/libjava/classpath/java/io/OutputStreamWriter.java @@ -91,17 +91,17 @@ public class OutputStreamWriter extends Writer /** * The charset encoder. */ - private CharsetEncoder encoder; + private final CharsetEncoder encoder; /** * java.io canonical name of the encoding. */ - private String encodingName; + private final String encodingName; /** * Buffer output before character conversion as it has costly overhead. */ - private CharBuffer outputBuffer; + private final CharBuffer outputBuffer; private final static int BUFFER_SIZE = 1024; /** @@ -120,7 +120,11 @@ public class OutputStreamWriter extends Writer public OutputStreamWriter (OutputStream out, String encoding_scheme) throws UnsupportedEncodingException { + CharsetEncoder encoder; + String encodingName; this.out = out; + outputBuffer = CharBuffer.allocate(BUFFER_SIZE); + try { // Don't use NIO if avoidable @@ -128,44 +132,44 @@ public class OutputStreamWriter extends Writer { encodingName = "ISO8859_1"; encoder = null; - return; - } - - /* - * Workraround for encodings with a byte-order-mark. - * We only want to write it once per stream. - */ - try - { - if(encoding_scheme.equalsIgnoreCase("UnicodeBig") || - encoding_scheme.equalsIgnoreCase("UTF-16") || - encoding_scheme.equalsIgnoreCase("UTF16")) - { - encoding_scheme = "UTF-16BE"; - out.write((byte)0xFE); - out.write((byte)0xFF); - } - else if(encoding_scheme.equalsIgnoreCase("UnicodeLittle")){ - encoding_scheme = "UTF-16LE"; - out.write((byte)0xFF); - out.write((byte)0xFE); - } - } - catch(IOException ioe) - { } - - outputBuffer = CharBuffer.allocate(BUFFER_SIZE); - - Charset cs = EncodingHelper.getCharset(encoding_scheme); - if(cs == null) - throw new UnsupportedEncodingException("Encoding "+encoding_scheme+ - " unknown"); - encoder = cs.newEncoder(); - encodingName = EncodingHelper.getOldCanonical(cs.name()); - - encoder.onMalformedInput(CodingErrorAction.REPLACE); - encoder.onUnmappableCharacter(CodingErrorAction.REPLACE); + else + { + /* + * Workaround for encodings with a byte-order-mark. + * We only want to write it once per stream. + */ + try + { + if(encoding_scheme.equalsIgnoreCase("UnicodeBig") || + encoding_scheme.equalsIgnoreCase("UTF-16") || + encoding_scheme.equalsIgnoreCase("UTF16")) + { + encoding_scheme = "UTF-16BE"; + out.write((byte)0xFE); + out.write((byte)0xFF); + } + else if(encoding_scheme.equalsIgnoreCase("UnicodeLittle")) + { + encoding_scheme = "UTF-16LE"; + out.write((byte)0xFF); + out.write((byte)0xFE); + } + } + catch(IOException ioe) + { + } + + Charset cs = EncodingHelper.getCharset(encoding_scheme); + if(cs == null) + throw new UnsupportedEncodingException("Encoding "+encoding_scheme+ + " unknown"); + encoder = cs.newEncoder(); + encodingName = EncodingHelper.getOldCanonical(cs.name()); + + encoder.onMalformedInput(CodingErrorAction.REPLACE); + encoder.onUnmappableCharacter(CodingErrorAction.REPLACE); + } } catch(RuntimeException e) { @@ -174,6 +178,8 @@ public class OutputStreamWriter extends Writer encoder = null; encodingName = "ISO8859_1"; } + this.encoder = encoder; + this.encodingName = encodingName; } /** @@ -184,8 +190,10 @@ public class OutputStreamWriter extends Writer */ public OutputStreamWriter (OutputStream out) { + CharsetEncoder encoder; + String encodingName; this.out = out; - outputBuffer = null; + outputBuffer = CharBuffer.allocate(BUFFER_SIZE); try { String encoding = System.getProperty("file.encoding"); @@ -203,8 +211,9 @@ public class OutputStreamWriter extends Writer { encoder.onMalformedInput(CodingErrorAction.REPLACE); encoder.onUnmappableCharacter(CodingErrorAction.REPLACE); - outputBuffer = CharBuffer.allocate(BUFFER_SIZE); } + this.encoder = encoder; + this.encodingName = encodingName; } /** @@ -345,7 +354,7 @@ public class OutputStreamWriter extends Writer { byte[] b = new byte[count]; for(int i=0;icount bytes from the specified * String starting at position offset into the @@ -398,7 +411,20 @@ public class OutputStreamWriter extends Writer */ public void write (int ch) throws IOException { - write(new char[]{ (char)ch }, 0, 1); + // No buffering, no encoding ... just pass through + if (encoder == null && outputBuffer == null) { + out.write(nullConversion((char)ch)); + } else { + if (outputBuffer != null) { + if (outputBuffer.remaining() == 0) { + writeConvert(outputBuffer.array(), 0, BUFFER_SIZE); + outputBuffer.clear(); + } + outputBuffer.put((char)ch); + } else { + writeConvert(new char[]{ (char)ch }, 0, 1); + } + } } } // class OutputStreamWriter diff --git a/libjava/classpath/java/io/PipedInputStream.java b/libjava/classpath/java/io/PipedInputStream.java index c0396d206c6..924cc6662f0 100644 --- a/libjava/classpath/java/io/PipedInputStream.java +++ b/libjava/classpath/java/io/PipedInputStream.java @@ -82,7 +82,7 @@ public class PipedInputStream extends InputStream * This is the internal circular buffer used for storing bytes written * to the pipe and from which bytes are read by this stream */ - protected byte[] buffer = new byte[PIPE_SIZE]; + protected byte[] buffer = null; /** * The index into buffer where the next byte from the connected @@ -107,8 +107,25 @@ public class PipedInputStream extends InputStream */ public PipedInputStream() { + this(PIPE_SIZE); } + /** + * Creates a new PipedInputStream of the given size that is not + * connected to a PipedOutputStream. + * It must be connected before bytes can be read from this stream. + * + * @since 1.6 + * @since IllegalArgumentException If pipeSize <= 0. + */ + public PipedInputStream(int pipeSize) throws IllegalArgumentException + { + if (pipeSize <= 0) + throw new IllegalArgumentException("pipeSize must be > 0"); + + this.buffer = new byte[pipeSize]; + } + /** * This constructor creates a new PipedInputStream and connects * it to the passed in PipedOutputStream. The stream is then @@ -121,9 +138,28 @@ public class PipedInputStream extends InputStream */ public PipedInputStream(PipedOutputStream source) throws IOException { + this(); connect(source); } + /** + * This constructor creates a new PipedInputStream of the given + * size and connects it to the passed in PipedOutputStream. + * The stream is then ready for reading. + * + * @param source The PipedOutputStream to connect this + * stream to + * + * @since 1.6 + * @exception IOException If source is already connected. + */ + public PipedInputStream(PipedOutputStream source, int pipeSize) + throws IOException + { + this(pipeSize); + connect(source); + } + /** * This method connects this stream to the passed in * PipedOutputStream. diff --git a/libjava/classpath/java/io/PrintStream.java b/libjava/classpath/java/io/PrintStream.java index 2d747c8c8f4..9347ac39795 100644 --- a/libjava/classpath/java/io/PrintStream.java +++ b/libjava/classpath/java/io/PrintStream.java @@ -76,7 +76,7 @@ public class PrintStream extends FilterOutputStream implements Appendable /** * Encoding name */ - private String encoding; + private final String encoding; /** * This boolean indicates whether or not an error has ever occurred @@ -88,7 +88,7 @@ public class PrintStream extends FilterOutputStream implements Appendable * This is true if auto-flush is enabled, * false otherwise */ - private boolean auto_flush; + private final boolean auto_flush; /** * This method initializes a new PrintStream object to write @@ -185,16 +185,17 @@ public class PrintStream extends FilterOutputStream implements Appendable public PrintStream (OutputStream out, boolean auto_flush) { super (out); - + String encoding; try { - this.encoding = SystemProperties.getProperty("file.encoding"); + encoding = SystemProperties.getProperty("file.encoding"); } catch (SecurityException e){ - this.encoding = "ISO8859_1"; + encoding = "ISO8859_1"; } catch (IllegalArgumentException e){ - this.encoding = "ISO8859_1"; + encoding = "ISO8859_1"; } catch (NullPointerException e){ - this.encoding = "ISO8859_1"; + encoding = "ISO8859_1"; } + this.encoding = encoding; this.auto_flush = auto_flush; } -- cgit v1.2.1