Imported GNU Classpath 0.90
Imported GNU Classpath 0.90 * scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale. * sources.am: Regenerated. * gcj/javaprims.h: Regenerated. * Makefile.in: Regenerated. * gcj/Makefile.in: Regenerated. * include/Makefile.in: Regenerated. * testsuite/Makefile.in: Regenerated. * gnu/java/lang/VMInstrumentationImpl.java: New override. * gnu/java/net/local/LocalSocketImpl.java: Likewise. * gnu/classpath/jdwp/VMMethod.java: Likewise. * gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest interface. * java/lang/Thread.java: Add UncaughtExceptionHandler. * java/lang/reflect/Method.java: Implements GenericDeclaration and isSynthetic(), * java/lang/reflect/Field.java: Likewise. * java/lang/reflect/Constructor.java * java/lang/Class.java: Implements Type, GenericDeclaration, getSimpleName() and getEnclosing*() methods. * java/lang/Class.h: Add new public methods. * java/lang/Math.java: Add signum(), ulp() and log10(). * java/lang/natMath.cc (log10): New function. * java/security/VMSecureRandom.java: New override. * java/util/logging/Logger.java: Updated to latest classpath version. * java/util/logging/LogManager.java: New override. From-SVN: r113887
This commit is contained in:
parent
eaec4980e1
commit
4f9533c772
1640 changed files with 126485 additions and 104808 deletions
|
@ -62,6 +62,11 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
|
|||
*/
|
||||
protected int written;
|
||||
|
||||
/**
|
||||
* Utf8 byte buffer, used by writeUTF()
|
||||
*/
|
||||
private byte[] buf;
|
||||
|
||||
/**
|
||||
* This method initializes an instance of <code>DataOutputStream</code> to
|
||||
* write its data to the specified underlying <code>OutputStream</code>
|
||||
|
@ -372,6 +377,37 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
|
|||
writeChar (value.charAt(i));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the length, in bytes, of a <code>String</code> in Utf8 format.
|
||||
*
|
||||
* @param value The <code>String</code> 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
|
||||
{
|
||||
int len = value.length();
|
||||
|
||||
for (int i = start; i < len && sum <= 65535; ++i)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c >= '\u0001' && c <= '\u007f')
|
||||
sum += 1;
|
||||
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
|
||||
sum += 2;
|
||||
else
|
||||
sum += 3;
|
||||
}
|
||||
|
||||
if (sum > 65535)
|
||||
throw new UTFDataFormatException ();
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method writes a Java <code>String</code> to the stream in a modified
|
||||
* UTF-8 format. First, two bytes are written to the stream indicating the
|
||||
|
@ -407,48 +443,47 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
|
|||
public final synchronized void writeUTF(String value) throws IOException
|
||||
{
|
||||
int len = value.length();
|
||||
int sum = 0;
|
||||
|
||||
for (int i = 0; i < len && sum <= 65535; ++i)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c >= '\u0001' && c <= '\u007f')
|
||||
sum += 1;
|
||||
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
|
||||
sum += 2;
|
||||
else
|
||||
sum += 3;
|
||||
}
|
||||
|
||||
if (sum > 65535)
|
||||
throw new UTFDataFormatException ();
|
||||
|
||||
int i = 0;
|
||||
int pos = 0;
|
||||
byte[] buf = new byte[sum];
|
||||
boolean lengthWritten = false;
|
||||
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
char c = value.charAt(i);
|
||||
if (c >= '\u0001' && c <= '\u007f')
|
||||
buf[pos++] = (byte) c;
|
||||
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
|
||||
{
|
||||
buf[pos++] = (byte) (0xc0 | (0x1f & (c >> 6)));
|
||||
buf[pos++] = (byte) (0x80 | (0x3f & c));
|
||||
}
|
||||
else
|
||||
{
|
||||
// JSL says the first byte should be or'd with 0xc0, but
|
||||
// that is a typo. Unicode says 0xe0, and that is what is
|
||||
// consistent with DataInputStream.
|
||||
buf[pos++] = (byte) (0xe0 | (0x0f & (c >> 12)));
|
||||
buf[pos++] = (byte) (0x80 | (0x3f & (c >> 6)));
|
||||
buf[pos++] = (byte) (0x80 | (0x3f & c));
|
||||
}
|
||||
}
|
||||
if (buf == null)
|
||||
buf = new byte[512];
|
||||
|
||||
writeShort (sum);
|
||||
write(buf, 0, sum);
|
||||
do
|
||||
{
|
||||
while (i < len && pos < buf.length - 3)
|
||||
{
|
||||
char c = value.charAt(i++);
|
||||
if (c >= '\u0001' && c <= '\u007f')
|
||||
buf[pos++] = (byte) c;
|
||||
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
|
||||
{
|
||||
buf[pos++] = (byte) (0xc0 | (0x1f & (c >> 6)));
|
||||
buf[pos++] = (byte) (0x80 | (0x3f & c));
|
||||
}
|
||||
else
|
||||
{
|
||||
// JSL says the first byte should be or'd with 0xc0, but
|
||||
// that is a typo. Unicode says 0xe0, and that is what is
|
||||
// consistent with DataInputStream.
|
||||
buf[pos++] = (byte) (0xe0 | (0x0f & (c >> 12)));
|
||||
buf[pos++] = (byte) (0x80 | (0x3f & (c >> 6)));
|
||||
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;
|
||||
}
|
||||
while (i < len);
|
||||
}
|
||||
|
||||
} // class DataOutputStream
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue