Reduce unnecessary usages of T-prefixed classes in classlib

This commit is contained in:
Alexey Andreev 2019-02-13 15:12:50 +03:00
parent 6790d724c7
commit 1214534671
102 changed files with 803 additions and 1235 deletions

View File

@ -15,7 +15,7 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import org.teavm.classlib.java.lang.TString; import java.io.IOException;
public class TBufferedInputStream extends TFilterInputStream { public class TBufferedInputStream extends TFilterInputStream {
protected volatile byte[] buf; protected volatile byte[] buf;
@ -38,16 +38,16 @@ public class TBufferedInputStream extends TFilterInputStream {
} }
@Override @Override
public int available() throws TIOException { public int available() throws IOException {
TInputStream localIn = in; TInputStream localIn = in;
if (buf == null || localIn == null) { if (buf == null || localIn == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
return count - pos + localIn.available(); return count - pos + localIn.available();
} }
@Override @Override
public void close() throws TIOException { public void close() throws IOException {
buf = null; buf = null;
TInputStream localIn = in; TInputStream localIn = in;
in = null; in = null;
@ -56,7 +56,7 @@ public class TBufferedInputStream extends TFilterInputStream {
} }
} }
private int fillbuf(TInputStream localIn, byte[] localBuf) throws TIOException { private int fillbuf(TInputStream localIn, byte[] localBuf) throws IOException {
if (markpos == -1 || (pos - markpos >= marklimit)) { if (markpos == -1 || (pos - markpos >= marklimit)) {
/* Mark position not set or exceeded readlimit */ /* Mark position not set or exceeded readlimit */
int result = localIn.read(localBuf); int result = localIn.read(localBuf);
@ -103,13 +103,13 @@ public class TBufferedInputStream extends TFilterInputStream {
} }
@Override @Override
public synchronized int read() throws TIOException { public synchronized int read() throws IOException {
// Use local refs since buf and in may be invalidated by an // Use local refs since buf and in may be invalidated by an
// unsynchronized close() // unsynchronized close()
byte[] localBuf = buf; byte[] localBuf = buf;
TInputStream localIn = in; TInputStream localIn = in;
if (localBuf == null || localIn == null) { if (localBuf == null || localIn == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
/* Are there buffered bytes available? */ /* Are there buffered bytes available? */
@ -120,7 +120,7 @@ public class TBufferedInputStream extends TFilterInputStream {
if (localBuf != buf) { if (localBuf != buf) {
localBuf = buf; localBuf = buf;
if (localBuf == null) { if (localBuf == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
} }
@ -132,10 +132,10 @@ public class TBufferedInputStream extends TFilterInputStream {
} }
@Override @Override
public synchronized int read(byte[] buffer, int offset, int length) throws TIOException { public synchronized int read(byte[] buffer, int offset, int length) throws IOException {
byte[] localBuf = buf; byte[] localBuf = buf;
if (localBuf == null) { if (localBuf == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
// avoid int overflow // avoid int overflow
if (offset > buffer.length - length || offset < 0 || length < 0) { if (offset > buffer.length - length || offset < 0 || length < 0) {
@ -146,7 +146,7 @@ public class TBufferedInputStream extends TFilterInputStream {
} }
TInputStream localIn = in; TInputStream localIn = in;
if (localIn == null) { if (localIn == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
int required; int required;
@ -183,7 +183,7 @@ public class TBufferedInputStream extends TFilterInputStream {
if (localBuf != buf) { if (localBuf != buf) {
localBuf = buf; localBuf = buf;
if (localBuf == null) { if (localBuf == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
} }
@ -203,30 +203,30 @@ public class TBufferedInputStream extends TFilterInputStream {
} }
@Override @Override
public synchronized void reset() throws TIOException { public synchronized void reset() throws IOException {
if (buf == null) { if (buf == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
if (-1 == markpos) { if (-1 == markpos) {
throw new TIOException(TString.wrap("Mark has been invalidated.")); throw new IOException("Mark has been invalidated.");
} }
pos = markpos; pos = markpos;
} }
@Override @Override
public synchronized long skip(long amount) throws TIOException { public synchronized long skip(long amount) throws IOException {
// Use local refs since buf and in may be invalidated by an // Use local refs since buf and in may be invalidated by an
// unsynchronized close() // unsynchronized close()
byte[] localBuf = buf; byte[] localBuf = buf;
TInputStream localIn = in; TInputStream localIn = in;
if (localBuf == null) { if (localBuf == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
if (amount < 1) { if (amount < 1) {
return 0; return 0;
} }
if (localIn == null) { if (localIn == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
if (count - pos >= amount) { if (count - pos >= amount) {

View File

@ -16,6 +16,8 @@
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
public class TBufferedOutputStream extends TFilterOutputStream { public class TBufferedOutputStream extends TFilterOutputStream {
protected byte[] buf; protected byte[] buf;
protected int count; protected int count;
@ -34,13 +36,13 @@ public class TBufferedOutputStream extends TFilterOutputStream {
} }
@Override @Override
public void flush() throws TIOException { public void flush() throws IOException {
flushInternal(); flushInternal();
out.flush(); out.flush();
} }
@Override @Override
public void write(byte[] buffer, int offset, int length) throws TIOException { public void write(byte[] buffer, int offset, int length) throws IOException {
byte[] internalBuffer = buf; byte[] internalBuffer = buf;
if (internalBuffer != null && length >= internalBuffer.length) { if (internalBuffer != null && length >= internalBuffer.length) {
@ -62,7 +64,7 @@ public class TBufferedOutputStream extends TFilterOutputStream {
} }
if (internalBuffer == null) { if (internalBuffer == null) {
throw new TIOException(); throw new IOException();
} }
// flush the internal buffer first if we have not enough space left // flush the internal buffer first if we have not enough space left
@ -76,7 +78,7 @@ public class TBufferedOutputStream extends TFilterOutputStream {
} }
@Override @Override
public void close() throws TIOException { public void close() throws IOException {
if (buf == null) { if (buf == null) {
return; return;
} }
@ -89,10 +91,10 @@ public class TBufferedOutputStream extends TFilterOutputStream {
} }
@Override @Override
public void write(int oneByte) throws TIOException { public void write(int oneByte) throws IOException {
byte[] internalBuffer = buf; byte[] internalBuffer = buf;
if (internalBuffer == null) { if (internalBuffer == null) {
throw new TIOException(); throw new IOException();
} }
if (count == internalBuffer.length) { if (count == internalBuffer.length) {
@ -102,7 +104,7 @@ public class TBufferedOutputStream extends TFilterOutputStream {
internalBuffer[count++] = (byte) oneByte; internalBuffer[count++] = (byte) oneByte;
} }
private void flushInternal() throws TIOException { private void flushInternal() throws IOException {
if (count > 0) { if (count > 0) {
out.write(buf, 0, count); out.write(buf, 0, count);
count = 0; count = 0;

View File

@ -15,9 +15,9 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TIllegalArgumentException; import org.teavm.classlib.java.lang.TIllegalArgumentException;
import org.teavm.classlib.java.lang.TMath; import org.teavm.classlib.java.lang.TMath;
import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.lang.TStringBuilder; import org.teavm.classlib.java.lang.TStringBuilder;
import org.teavm.classlib.java.util.TArrays; import org.teavm.classlib.java.util.TArrays;
@ -42,7 +42,7 @@ public class TBufferedReader extends TReader {
} }
@Override @Override
public int read() throws TIOException { public int read() throws IOException {
requireOpened(); requireOpened();
if (index >= count) { if (index >= count) {
if (!fillBuffer(0)) { if (!fillBuffer(0)) {
@ -53,14 +53,14 @@ public class TBufferedReader extends TReader {
} }
@Override @Override
public void close() throws TIOException { public void close() throws IOException {
requireOpened(); requireOpened();
innerReader.close(); innerReader.close();
innerReader = null; innerReader = null;
} }
@Override @Override
public int read(char[] cbuf, int off, int len) throws TIOException { public int read(char[] cbuf, int off, int len) throws IOException {
requireOpened(); requireOpened();
if (index == count && eof) { if (index == count && eof) {
return -1; return -1;
@ -79,7 +79,7 @@ public class TBufferedReader extends TReader {
return charsRead; return charsRead;
} }
public TString readLine() throws TIOException { public String readLine() throws IOException {
requireOpened(); requireOpened();
if (eof && index >= count) { if (eof && index >= count) {
return null; return null;
@ -108,11 +108,11 @@ public class TBufferedReader extends TReader {
line.append(ch); line.append(ch);
} }
} }
return TString.wrap(line.toString()); return line.toString();
} }
@Override @Override
public long skip(long n) throws TIOException { public long skip(long n) throws IOException {
requireOpened(); requireOpened();
if (n < count - index) { if (n < count - index) {
index += n; index += n;
@ -135,7 +135,7 @@ public class TBufferedReader extends TReader {
} }
@Override @Override
public void mark(int readAheadLimit) throws TIOException { public void mark(int readAheadLimit) throws IOException {
if (readAheadLimit > buffer.length) { if (readAheadLimit > buffer.length) {
buffer = TArrays.copyOf(buffer, readAheadLimit); buffer = TArrays.copyOf(buffer, readAheadLimit);
} }
@ -149,14 +149,14 @@ public class TBufferedReader extends TReader {
} }
@Override @Override
public void reset() throws TIOException { public void reset() throws IOException {
if (mark == -1) { if (mark == -1) {
throw new TIOException(); throw new IOException();
} }
index = mark; index = mark;
} }
private boolean fillBuffer(int offset) throws TIOException { private boolean fillBuffer(int offset) throws IOException {
if (eof) { if (eof) {
return false; return false;
} }
@ -177,9 +177,9 @@ public class TBufferedReader extends TReader {
return true; return true;
} }
private void requireOpened() { private void requireOpened() throws IOException {
if (innerReader == null) { if (innerReader == null) {
throw new TIOException(); throw new IOException();
} }
} }
} }

View File

@ -15,6 +15,7 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TMath; import org.teavm.classlib.java.lang.TMath;
import org.teavm.classlib.java.lang.TString; import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.util.TArrays; import org.teavm.classlib.java.util.TArrays;
@ -65,7 +66,7 @@ public class TByteArrayOutputStream extends TOutputStream {
return new TString(buf, 0, count, charsetName); return new TString(buf, 0, count, charsetName);
} }
public void writeTo(TOutputStream out) throws TIOException { public void writeTo(TOutputStream out) throws IOException {
out.write(buf, 0, count); out.write(buf, 0, count);
} }

View File

@ -15,9 +15,10 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TAutoCloseable; import org.teavm.classlib.java.lang.TAutoCloseable;
public interface TCloseable extends TAutoCloseable { public interface TCloseable extends TAutoCloseable {
@Override @Override
void close() throws TIOException; void close() throws IOException;
} }

View File

@ -15,36 +15,36 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import org.teavm.classlib.java.lang.TString; import java.io.IOException;
public interface TDataInput { public interface TDataInput {
void readFully(byte[] b) throws TIOException; void readFully(byte[] b) throws IOException;
void readFully(byte[] b, int off, int len) throws TIOException; void readFully(byte[] b, int off, int len) throws IOException;
int skipBytes(int n) throws TIOException; int skipBytes(int n) throws IOException;
boolean readBoolean() throws TIOException; boolean readBoolean() throws IOException;
byte readByte() throws TIOException; byte readByte() throws IOException;
int readUnsignedByte() throws TIOException; int readUnsignedByte() throws IOException;
short readShort() throws TIOException; short readShort() throws IOException;
int readUnsignedShort() throws TIOException; int readUnsignedShort() throws IOException;
char readChar() throws TIOException; char readChar() throws IOException;
int readInt() throws TIOException; int readInt() throws IOException;
long readLong() throws TIOException; long readLong() throws IOException;
float readFloat() throws TIOException; float readFloat() throws IOException;
double readDouble() throws TIOException; double readDouble() throws IOException;
TString readLine() throws TIOException; String readLine() throws IOException;
TString readUTF() throws TIOException; String readUTF() throws IOException;
} }

View File

@ -15,6 +15,7 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.*; import org.teavm.classlib.java.lang.*;
public class TDataInputStream extends TFilterInputStream implements TDataInput { public class TDataInputStream extends TFilterInputStream implements TDataInput {
@ -26,17 +27,17 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
@Override @Override
public final int read(byte[] buffer) throws TIOException { public final int read(byte[] buffer) throws IOException {
return in.read(buffer, 0, buffer.length); return in.read(buffer, 0, buffer.length);
} }
@Override @Override
public final int read(byte[] buffer, int offset, int length) throws TIOException { public final int read(byte[] buffer, int offset, int length) throws IOException {
return in.read(buffer, offset, length); return in.read(buffer, offset, length);
} }
@Override @Override
public final boolean readBoolean() throws TIOException { public final boolean readBoolean() throws IOException {
int temp = in.read(); int temp = in.read();
if (temp < 0) { if (temp < 0) {
throw new TEOFException(); throw new TEOFException();
@ -45,7 +46,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
@Override @Override
public final byte readByte() throws TIOException { public final byte readByte() throws IOException {
int temp = in.read(); int temp = in.read();
if (temp < 0) { if (temp < 0) {
throw new TEOFException(); throw new TEOFException();
@ -53,7 +54,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
return (byte) temp; return (byte) temp;
} }
private int readToBuff(int count) throws TIOException { private int readToBuff(int count) throws IOException {
int offset = 0; int offset = 0;
while (offset < count) { while (offset < count) {
int bytesRead = in.read(buff, offset, count - offset); int bytesRead = in.read(buff, offset, count - offset);
@ -66,7 +67,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
@Override @Override
public final char readChar() throws TIOException { public final char readChar() throws IOException {
if (readToBuff(2) < 0) { if (readToBuff(2) < 0) {
throw new TEOFException(); throw new TEOFException();
} }
@ -74,22 +75,22 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
@Override @Override
public final double readDouble() throws TIOException { public final double readDouble() throws IOException {
return TDouble.longBitsToDouble(readLong()); return TDouble.longBitsToDouble(readLong());
} }
@Override @Override
public final float readFloat() throws TIOException { public final float readFloat() throws IOException {
return TFloat.intBitsToFloat(readInt()); return TFloat.intBitsToFloat(readInt());
} }
@Override @Override
public final void readFully(byte[] buffer) throws TIOException { public final void readFully(byte[] buffer) throws IOException {
readFully(buffer, 0, buffer.length); readFully(buffer, 0, buffer.length);
} }
@Override @Override
public final void readFully(byte[] buffer, int offset, int length) throws TIOException { public final void readFully(byte[] buffer, int offset, int length) throws IOException {
if (length < 0) { if (length < 0) {
throw new TIndexOutOfBoundsException(); throw new TIndexOutOfBoundsException();
} }
@ -116,7 +117,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
@Override @Override
public final int readInt() throws TIOException { public final int readInt() throws IOException {
if (readToBuff(4) < 0) { if (readToBuff(4) < 0) {
throw new TEOFException(); throw new TEOFException();
} }
@ -125,7 +126,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
@Override @Override
@Deprecated @Deprecated
public final TString readLine() throws TIOException { public final String readLine() throws IOException {
TStringBuilder line = new TStringBuilder(80); TStringBuilder line = new TStringBuilder(80);
boolean foundTerminator = false; boolean foundTerminator = false;
while (true) { while (true) {
@ -135,11 +136,11 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
if (line.length() == 0 && !foundTerminator) { if (line.length() == 0 && !foundTerminator) {
return null; return null;
} }
return TString.wrap(line.toString()); return line.toString();
case (byte) '\r': case (byte) '\r':
if (foundTerminator) { if (foundTerminator) {
((TPushbackInputStream) in).unread(nextByte); ((TPushbackInputStream) in).unread(nextByte);
return TString.wrap(line.toString()); return line.toString();
} }
foundTerminator = true; foundTerminator = true;
/* Have to be able to peek ahead one byte */ /* Have to be able to peek ahead one byte */
@ -148,11 +149,11 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
break; break;
case (byte) '\n': case (byte) '\n':
return TString.wrap(line.toString()); return line.toString();
default: default:
if (foundTerminator) { if (foundTerminator) {
((TPushbackInputStream) in).unread(nextByte); ((TPushbackInputStream) in).unread(nextByte);
return TString.wrap(line.toString()); return line.toString();
} }
line.append((char) nextByte); line.append((char) nextByte);
} }
@ -160,7 +161,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
@Override @Override
public final long readLong() throws TIOException { public final long readLong() throws IOException {
if (readToBuff(8) < 0) { if (readToBuff(8) < 0) {
throw new TEOFException(); throw new TEOFException();
} }
@ -172,7 +173,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
@Override @Override
public final short readShort() throws TIOException { public final short readShort() throws IOException {
if (readToBuff(2) < 0) { if (readToBuff(2) < 0) {
throw new TEOFException(); throw new TEOFException();
} }
@ -180,7 +181,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
@Override @Override
public final int readUnsignedByte() throws TIOException { public final int readUnsignedByte() throws IOException {
int temp = in.read(); int temp = in.read();
if (temp < 0) { if (temp < 0) {
throw new TEOFException(); throw new TEOFException();
@ -189,7 +190,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
@Override @Override
public final int readUnsignedShort() throws TIOException { public final int readUnsignedShort() throws IOException {
if (readToBuff(2) < 0) { if (readToBuff(2) < 0) {
throw new TEOFException(); throw new TEOFException();
} }
@ -197,15 +198,15 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
} }
@Override @Override
public final TString readUTF() throws TIOException { public final String readUTF() throws IOException {
return decodeUTF(readUnsignedShort()); return decodeUTF(readUnsignedShort());
} }
TString decodeUTF(int utfSize) throws TIOException { String decodeUTF(int utfSize) throws IOException {
return decodeUTF(utfSize, this); return decodeUTF(utfSize, this);
} }
private static TString decodeUTF(int utfSize, TDataInput in) throws TIOException { private static String decodeUTF(int utfSize, TDataInput in) throws IOException {
byte[] buf = new byte[utfSize]; byte[] buf = new byte[utfSize];
char[] out = new char[utfSize]; char[] out = new char[utfSize];
in.readFully(buf, 0, utfSize); in.readFully(buf, 0, utfSize);
@ -213,12 +214,12 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
return convertUTF8WithBuf(buf, out, 0, utfSize); return convertUTF8WithBuf(buf, out, 0, utfSize);
} }
public static final TString readUTF(TDataInput in) throws TIOException { public static String readUTF(TDataInput in) throws IOException {
return decodeUTF(in.readUnsignedShort(), in); return decodeUTF(in.readUnsignedShort(), in);
} }
@Override @Override
public final int skipBytes(int count) throws TIOException { public final int skipBytes(int count) throws IOException {
int skipped = 0; int skipped = 0;
while (skipped < count) { while (skipped < count) {
@ -234,7 +235,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
return skipped; return skipped;
} }
private static TString convertUTF8WithBuf(byte[] buf, char[] out, int offset, int utfSize) private static String convertUTF8WithBuf(byte[] buf, char[] out, int offset, int utfSize)
throws TUTFDataFormatException { throws TUTFDataFormatException {
int count = 0; int count = 0;
int s = 0; int s = 0;
@ -247,27 +248,27 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput {
s++; s++;
} else if ((a & 0xe0) == 0xc0) { } else if ((a & 0xe0) == 0xc0) {
if (count >= utfSize) { if (count >= utfSize) {
throw new TUTFDataFormatException(TString.wrap("End of stream reached")); throw new TUTFDataFormatException("End of stream reached");
} }
int b = buf[offset + count++]; int b = buf[offset + count++];
if ((b & 0xC0) != 0x80) { if ((b & 0xC0) != 0x80) {
throw new TUTFDataFormatException(TString.wrap("Malformed UTF-8 sequence")); throw new TUTFDataFormatException("Malformed UTF-8 sequence");
} }
out[s++] = (char) (((a & 0x1F) << 6) | (b & 0x3F)); out[s++] = (char) (((a & 0x1F) << 6) | (b & 0x3F));
} else if ((a & 0xf0) == 0xe0) { } else if ((a & 0xf0) == 0xe0) {
if (count + 1 >= utfSize) { if (count + 1 >= utfSize) {
throw new TUTFDataFormatException(TString.wrap("Malformed UTF-8 sequence")); throw new TUTFDataFormatException("Malformed UTF-8 sequence");
} }
int b = buf[offset + count++]; int b = buf[offset + count++];
int c = buf[offset + count++]; int c = buf[offset + count++];
if (((b & 0xC0) != 0x80) || ((c & 0xC0) != 0x80)) { if (((b & 0xC0) != 0x80) || ((c & 0xC0) != 0x80)) {
throw new TUTFDataFormatException(TString.wrap("Malformed UTF-8 sequence")); throw new TUTFDataFormatException("Malformed UTF-8 sequence");
} }
out[s++] = (char) (((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F)); out[s++] = (char) (((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F));
} else { } else {
throw new TUTFDataFormatException(TString.wrap("Malformed UTF-8 sequence")); throw new TUTFDataFormatException("Malformed UTF-8 sequence");
} }
} }
return new TString(out, 0, s); return new String(out, 0, s);
} }
} }

View File

@ -15,34 +15,35 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TString; import org.teavm.classlib.java.lang.TString;
public interface TDataOutput { public interface TDataOutput {
void write(int b) throws TIOException; void write(int b) throws IOException;
void write(byte[] b) throws TIOException; void write(byte[] b) throws IOException;
void write(byte[] b, int off, int len) throws TIOException; void write(byte[] b, int off, int len) throws IOException;
void writeBoolean(boolean v) throws TIOException; void writeBoolean(boolean v) throws IOException;
void writeByte(int v) throws TIOException; void writeByte(int v) throws IOException;
void writeShort(int v) throws TIOException; void writeShort(int v) throws IOException;
void writeChar(int v) throws TIOException; void writeChar(int v) throws IOException;
void writeInt(int v) throws TIOException; void writeInt(int v) throws IOException;
void writeLong(long v) throws TIOException; void writeLong(long v) throws IOException;
void writeFloat(float v) throws TIOException; void writeFloat(float v) throws IOException;
void writeDouble(double v) throws TIOException; void writeDouble(double v) throws IOException;
void writeBytes(TString s) throws TIOException; void writeBytes(TString s) throws IOException;
void writeChars(TString s) throws TIOException; void writeChars(TString s) throws IOException;
void writeUTF(TString s) throws TIOException; void writeUTF(TString s) throws IOException;
} }

View File

@ -14,6 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.*; import org.teavm.classlib.java.lang.*;
public class TDataOutputStream extends TFilterOutputStream implements TDataOutput { public class TDataOutputStream extends TFilterOutputStream implements TDataOutput {
@ -29,7 +30,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu
} }
@Override @Override
public void flush() throws TIOException { public void flush() throws IOException {
super.flush(); super.flush();
} }
@ -41,7 +42,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu
} }
@Override @Override
public void write(byte[] buffer, int offset, int count) throws TIOException { public void write(byte[] buffer, int offset, int count) throws IOException {
if (buffer == null) { if (buffer == null) {
throw new TNullPointerException(); throw new TNullPointerException();
} }
@ -50,25 +51,25 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu
} }
@Override @Override
public void write(int oneByte) throws TIOException { public void write(int oneByte) throws IOException {
out.write(oneByte); out.write(oneByte);
written++; written++;
} }
@Override @Override
public final void writeBoolean(boolean val) throws TIOException { public final void writeBoolean(boolean val) throws IOException {
out.write(val ? 1 : 0); out.write(val ? 1 : 0);
written++; written++;
} }
@Override @Override
public final void writeByte(int val) throws TIOException { public final void writeByte(int val) throws IOException {
out.write(val); out.write(val);
written++; written++;
} }
@Override @Override
public final void writeBytes(TString str) throws TIOException { public final void writeBytes(TString str) throws IOException {
if (str.length() == 0) { if (str.length() == 0) {
return; return;
} }
@ -81,7 +82,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu
} }
@Override @Override
public final void writeChar(int val) throws TIOException { public final void writeChar(int val) throws IOException {
buff[0] = (byte) (val >> 8); buff[0] = (byte) (val >> 8);
buff[1] = (byte) val; buff[1] = (byte) val;
out.write(buff, 0, 2); out.write(buff, 0, 2);
@ -89,7 +90,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu
} }
@Override @Override
public final void writeChars(TString str) throws TIOException { public final void writeChars(TString str) throws IOException {
byte[] newBytes = new byte[str.length() * 2]; byte[] newBytes = new byte[str.length() * 2];
for (int index = 0; index < str.length(); index++) { for (int index = 0; index < str.length(); index++) {
int newIndex = index == 0 ? index : index * 2; int newIndex = index == 0 ? index : index * 2;
@ -101,17 +102,17 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu
} }
@Override @Override
public final void writeDouble(double val) throws TIOException { public final void writeDouble(double val) throws IOException {
writeLong(TDouble.doubleToLongBits(val)); writeLong(TDouble.doubleToLongBits(val));
} }
@Override @Override
public final void writeFloat(float val) throws TIOException { public final void writeFloat(float val) throws IOException {
writeInt(TFloat.floatToIntBits(val)); writeInt(TFloat.floatToIntBits(val));
} }
@Override @Override
public final void writeInt(int val) throws TIOException { public final void writeInt(int val) throws IOException {
buff[0] = (byte) (val >> 24); buff[0] = (byte) (val >> 24);
buff[1] = (byte) (val >> 16); buff[1] = (byte) (val >> 16);
buff[2] = (byte) (val >> 8); buff[2] = (byte) (val >> 8);
@ -121,7 +122,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu
} }
@Override @Override
public final void writeLong(long val) throws TIOException { public final void writeLong(long val) throws IOException {
buff[0] = (byte) (val >> 56); buff[0] = (byte) (val >> 56);
buff[1] = (byte) (val >> 48); buff[1] = (byte) (val >> 48);
buff[2] = (byte) (val >> 40); buff[2] = (byte) (val >> 40);
@ -134,7 +135,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu
written += 8; written += 8;
} }
int writeLongToBuffer(long val, byte[] buffer, int offset) throws TIOException { int writeLongToBuffer(long val, byte[] buffer, int offset) throws IOException {
buffer[offset++] = (byte) (val >> 56); buffer[offset++] = (byte) (val >> 56);
buffer[offset++] = (byte) (val >> 48); buffer[offset++] = (byte) (val >> 48);
buffer[offset++] = (byte) (val >> 40); buffer[offset++] = (byte) (val >> 40);
@ -147,24 +148,24 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu
} }
@Override @Override
public final void writeShort(int val) throws TIOException { public final void writeShort(int val) throws IOException {
buff[0] = (byte) (val >> 8); buff[0] = (byte) (val >> 8);
buff[1] = (byte) val; buff[1] = (byte) val;
out.write(buff, 0, 2); out.write(buff, 0, 2);
written += 2; written += 2;
} }
int writeShortToBuffer(int val, byte[] buffer, int offset) throws TIOException { int writeShortToBuffer(int val, byte[] buffer, int offset) throws IOException {
buffer[offset++] = (byte) (val >> 8); buffer[offset++] = (byte) (val >> 8);
buffer[offset++] = (byte) val; buffer[offset++] = (byte) val;
return offset; return offset;
} }
@Override @Override
public final void writeUTF(TString str) throws TIOException { public final void writeUTF(TString str) throws IOException {
long utfCount = countUTFBytes(str); long utfCount = countUTFBytes(str);
if (utfCount > 65535) { if (utfCount > 65535) {
throw new TIOException(TString.wrap("UTF Error")); throw new IOException("UTF Error");
} }
byte[] buffer = new byte[(int) utfCount + 2]; byte[] buffer = new byte[(int) utfCount + 2];
int offset = 0; int offset = 0;
@ -189,7 +190,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu
return utfCount; return utfCount;
} }
int writeUTFBytesToBuffer(TString str, byte[] buffer, int offset) throws TIOException { int writeUTFBytesToBuffer(TString str, byte[] buffer, int offset) throws IOException {
int length = str.length(); int length = str.length();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
int charValue = str.charAt(i); int charValue = str.charAt(i);

View File

@ -15,16 +15,16 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import org.teavm.classlib.java.lang.TString; import java.io.IOException;
public class TEOFException extends TIOException { public class TEOFException extends IOException {
private static final long serialVersionUID = 3045477060413545010L; private static final long serialVersionUID = 3045477060413545010L;
public TEOFException() { public TEOFException() {
super(); super();
} }
public TEOFException(TString message) { public TEOFException(String message) {
super(message); super(message);
} }
} }

View File

@ -15,6 +15,8 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
public class TFilterInputStream extends TInputStream { public class TFilterInputStream extends TInputStream {
protected volatile TInputStream in; protected volatile TInputStream in;
@ -23,12 +25,12 @@ public class TFilterInputStream extends TInputStream {
} }
@Override @Override
public int available() throws TIOException { public int available() throws IOException {
return in.available(); return in.available();
} }
@Override @Override
public void close() throws TIOException { public void close() throws IOException {
in.close(); in.close();
} }
@ -43,27 +45,27 @@ public class TFilterInputStream extends TInputStream {
} }
@Override @Override
public int read() throws TIOException { public int read() throws IOException {
return in.read(); return in.read();
} }
@Override @Override
public int read(byte[] buffer) throws TIOException { public int read(byte[] buffer) throws IOException {
return read(buffer, 0, buffer.length); return read(buffer, 0, buffer.length);
} }
@Override @Override
public int read(byte[] buffer, int offset, int count) throws TIOException { public int read(byte[] buffer, int offset, int count) throws IOException {
return in.read(buffer, offset, count); return in.read(buffer, offset, count);
} }
@Override @Override
public synchronized void reset() throws TIOException { public synchronized void reset() throws IOException {
in.reset(); in.reset();
} }
@Override @Override
public long skip(long count) throws TIOException { public long skip(long count) throws IOException {
return in.skip(count); return in.skip(count);
} }
} }

View File

@ -15,6 +15,8 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
public class TFilterOutputStream extends TOutputStream { public class TFilterOutputStream extends TOutputStream {
protected TOutputStream out; protected TOutputStream out;
@ -23,22 +25,22 @@ public class TFilterOutputStream extends TOutputStream {
} }
@Override @Override
public void write(int b) throws TIOException { public void write(int b) throws IOException {
out.write(b); out.write(b);
} }
@Override @Override
public void close() throws TIOException { public void close() throws IOException {
try { try {
out.flush(); out.flush();
} catch (TIOException e) { } catch (IOException e) {
// do nothing // do nothing
} }
out.close(); out.close();
} }
@Override @Override
public void flush() throws TIOException { public void flush() throws IOException {
out.flush(); out.flush();
} }
} }

View File

@ -15,6 +15,8 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
public interface TFlushable { public interface TFlushable {
void flush() throws TIOException; void flush() throws IOException;
} }

View File

@ -15,26 +15,22 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import org.teavm.classlib.java.lang.TException; public class TIOException extends Exception {
import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.lang.TThrowable;
public class TIOException extends TException {
private static final long serialVersionUID = 3626109154700059455L; private static final long serialVersionUID = 3626109154700059455L;
public TIOException() { public TIOException() {
super(); super();
} }
public TIOException(TString message, TThrowable cause) { public TIOException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }
public TIOException(TString message) { public TIOException(String message) {
super(message); super(message);
} }
public TIOException(TThrowable cause) { public TIOException(Throwable cause) {
super(cause); super(cause);
} }
} }

View File

@ -15,6 +15,7 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TInteger; import org.teavm.classlib.java.lang.TInteger;
import org.teavm.classlib.java.lang.TObject; import org.teavm.classlib.java.lang.TObject;
@ -22,13 +23,13 @@ public abstract class TInputStream extends TObject implements TCloseable {
public TInputStream() { public TInputStream() {
} }
public abstract int read() throws TIOException; public abstract int read() throws IOException;
public int read(byte[] b) throws TIOException { public int read(byte[] b) throws IOException {
return read(b, 0, b.length); return read(b, 0, b.length);
} }
public int read(byte[] b, int off, int len) throws TIOException { public int read(byte[] b, int off, int len) throws IOException {
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
int bt = read(); int bt = read();
if (bt < 0) { if (bt < 0) {
@ -39,7 +40,7 @@ public abstract class TInputStream extends TObject implements TCloseable {
return len > 0 ? len : -1; return len > 0 ? len : -1;
} }
public long skip(long n) throws TIOException { public long skip(long n) throws IOException {
if (n < TInteger.MAX_VALUE) { if (n < TInteger.MAX_VALUE) {
return skip((int) n); return skip((int) n);
} else { } else {
@ -52,7 +53,7 @@ public abstract class TInputStream extends TObject implements TCloseable {
} }
} }
private int skip(int n) throws TIOException { private int skip(int n) throws IOException {
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
if (read() < 0) { if (read() < 0) {
return i; return i;
@ -61,19 +62,19 @@ public abstract class TInputStream extends TObject implements TCloseable {
return n; return n;
} }
public int available() throws TIOException { public int available() throws IOException {
return 0; return 0;
} }
@Override @Override
public void close() throws TIOException { public void close() throws IOException {
} }
public void mark(@SuppressWarnings("unused") int readlimit) { public void mark(@SuppressWarnings("unused") int readlimit) {
} }
public void reset() throws TIOException { public void reset() throws IOException {
throw new TIOException(); throw new IOException();
} }
public boolean markSupported() { public boolean markSupported() {

View File

@ -15,7 +15,7 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import org.teavm.classlib.java.lang.TString; import java.io.IOException;
import org.teavm.classlib.java.nio.TByteBuffer; import org.teavm.classlib.java.nio.TByteBuffer;
import org.teavm.classlib.java.nio.TCharBuffer; import org.teavm.classlib.java.nio.TCharBuffer;
import org.teavm.classlib.java.nio.charset.TCharset; import org.teavm.classlib.java.nio.charset.TCharset;
@ -34,7 +34,7 @@ public class TInputStreamReader extends TReader {
private boolean streamEof; private boolean streamEof;
private boolean eof; private boolean eof;
public TInputStreamReader(TInputStream in, TString charsetName) throws TUnsupportedEncodingException { public TInputStreamReader(TInputStream in, String charsetName) throws TUnsupportedEncodingException {
this(in, getCharset(charsetName)); this(in, getCharset(charsetName));
} }
@ -55,7 +55,7 @@ public class TInputStreamReader extends TReader {
inBuffer.position(inBuffer.limit()); inBuffer.position(inBuffer.limit());
} }
private static TCharset getCharset(TString charsetName) throws TUnsupportedEncodingException { private static TCharset getCharset(String charsetName) throws TUnsupportedEncodingException {
try { try {
return TCharset.forName(charsetName.toString()); return TCharset.forName(charsetName.toString());
} catch (TUnsupportedCharsetException e) { } catch (TUnsupportedCharsetException e) {
@ -63,17 +63,17 @@ public class TInputStreamReader extends TReader {
} }
} }
public TString getEncoding() { public String getEncoding() {
return TString.wrap(decoder.charset().name()); return decoder.charset().name();
} }
@Override @Override
public void close() throws TIOException { public void close() throws IOException {
stream.close(); stream.close();
} }
@Override @Override
public int read() throws TIOException { public int read() throws IOException {
if (eof && !outBuffer.hasRemaining()) { if (eof && !outBuffer.hasRemaining()) {
return -1; return -1;
} }
@ -84,7 +84,7 @@ public class TInputStreamReader extends TReader {
} }
@Override @Override
public int read(char[] cbuf, int off, int len) throws TIOException { public int read(char[] cbuf, int off, int len) throws IOException {
if (eof && !outBuffer.hasRemaining()) { if (eof && !outBuffer.hasRemaining()) {
return -1; return -1;
} }
@ -101,7 +101,7 @@ public class TInputStreamReader extends TReader {
return bytesRead; return bytesRead;
} }
private boolean fillBuffer() throws TIOException { private boolean fillBuffer() throws IOException {
if (eof) { if (eof) {
return false; return false;
} }
@ -121,7 +121,7 @@ public class TInputStreamReader extends TReader {
return true; return true;
} }
private boolean fillReadBuffer() throws TIOException { private boolean fillReadBuffer() throws IOException {
if (streamEof) { if (streamEof) {
return false; return false;
} }
@ -143,7 +143,7 @@ public class TInputStreamReader extends TReader {
} }
@Override @Override
public boolean ready() throws TIOException { public boolean ready() throws IOException {
return outBuffer.hasRemaining() || inBuffer.hasRemaining(); return outBuffer.hasRemaining() || inBuffer.hasRemaining();
} }
} }

View File

@ -15,26 +15,27 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TObject; import org.teavm.classlib.java.lang.TObject;
public abstract class TOutputStream extends TObject implements TCloseable, TFlushable { public abstract class TOutputStream extends TObject implements TCloseable, TFlushable {
public abstract void write(int b) throws TIOException; public abstract void write(int b) throws IOException;
public void write(byte[] b) throws TIOException { public void write(byte[] b) throws IOException {
write(b, 0, b.length); write(b, 0, b.length);
} }
public void write(byte[] b, int off, int len) throws TIOException { public void write(byte[] b, int off, int len) throws IOException {
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
write(b[off++]); write(b[off++]);
} }
} }
@Override @Override
public void close() throws TIOException { public void close() throws IOException {
} }
@Override @Override
public void flush() throws TIOException { public void flush() throws IOException {
} }
} }

View File

@ -15,10 +15,14 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import org.teavm.classlib.java.lang.TString; import java.io.IOException;
import org.teavm.classlib.java.nio.TByteBuffer; import org.teavm.classlib.java.nio.TByteBuffer;
import org.teavm.classlib.java.nio.TCharBuffer; import org.teavm.classlib.java.nio.TCharBuffer;
import org.teavm.classlib.java.nio.charset.*; import org.teavm.classlib.java.nio.charset.TCharset;
import org.teavm.classlib.java.nio.charset.TCharsetEncoder;
import org.teavm.classlib.java.nio.charset.TCodingErrorAction;
import org.teavm.classlib.java.nio.charset.TIllegalCharsetNameException;
import org.teavm.classlib.java.nio.charset.TUnsupportedCharsetException;
import org.teavm.classlib.java.nio.charset.impl.TUTF8Charset; import org.teavm.classlib.java.nio.charset.impl.TUTF8Charset;
public class TOutputStreamWriter extends TWriter { public class TOutputStreamWriter extends TWriter {
@ -61,12 +65,12 @@ public class TOutputStreamWriter extends TWriter {
try { try {
return TCharset.forName(charsetName); return TCharset.forName(charsetName);
} catch (TUnsupportedCharsetException | TIllegalCharsetNameException e) { } catch (TUnsupportedCharsetException | TIllegalCharsetNameException e) {
throw new TUnsupportedEncodingException(TString.wrap(charsetName)); throw new TUnsupportedEncodingException(charsetName);
} }
} }
@Override @Override
public void close() throws TIOException { public void close() throws IOException {
if (!closed) { if (!closed) {
flush(); flush();
closed = true; closed = true;
@ -76,7 +80,7 @@ public class TOutputStreamWriter extends TWriter {
} }
@Override @Override
public void flush() throws TIOException { public void flush() throws IOException {
checkStatus(); checkStatus();
if (buffer.position() > 0) { if (buffer.position() > 0) {
out.write(bufferData, 0, buffer.position()); out.write(bufferData, 0, buffer.position());
@ -85,9 +89,9 @@ public class TOutputStreamWriter extends TWriter {
out.flush(); out.flush();
} }
private void checkStatus() throws TIOException { private void checkStatus() throws IOException {
if (closed) { if (closed) {
throw new TIOException(TString.wrap("Writer already closed")); throw new IOException("Writer already closed");
} }
} }
@ -96,7 +100,7 @@ public class TOutputStreamWriter extends TWriter {
} }
@Override @Override
public void write(char[] buf, int offset, int count) throws TIOException { public void write(char[] buf, int offset, int count) throws IOException {
synchronized (lock) { synchronized (lock) {
checkStatus(); checkStatus();
if (buf == null) { if (buf == null) {
@ -116,13 +120,13 @@ public class TOutputStreamWriter extends TWriter {
} }
@Override @Override
public void write(int oneChar) throws TIOException { public void write(int oneChar) throws IOException {
char[] array = { (char) oneChar }; char[] array = { (char) oneChar };
write(array, 0, array.length); write(array, 0, array.length);
} }
@Override @Override
public void write(String str, int offset, int count) throws TIOException { public void write(String str, int offset, int count) throws IOException {
if (str == null) { if (str == null) {
throw new NullPointerException(); throw new NullPointerException();
} }

View File

@ -15,13 +15,17 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TMath; import org.teavm.classlib.java.lang.TMath;
import org.teavm.classlib.java.lang.TObject; import org.teavm.classlib.java.lang.TObject;
import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.lang.TStringBuilder; import org.teavm.classlib.java.lang.TStringBuilder;
import org.teavm.classlib.java.nio.TByteBuffer; import org.teavm.classlib.java.nio.TByteBuffer;
import org.teavm.classlib.java.nio.TCharBuffer; import org.teavm.classlib.java.nio.TCharBuffer;
import org.teavm.classlib.java.nio.charset.*; import org.teavm.classlib.java.nio.charset.TCharset;
import org.teavm.classlib.java.nio.charset.TCharsetEncoder;
import org.teavm.classlib.java.nio.charset.TCodingErrorAction;
import org.teavm.classlib.java.nio.charset.TIllegalCharsetNameException;
import org.teavm.classlib.java.nio.charset.TUnsupportedCharsetException;
import org.teavm.classlib.java.nio.charset.impl.TUTF8Charset; import org.teavm.classlib.java.nio.charset.impl.TUTF8Charset;
public class TPrintStream extends TFilterOutputStream { public class TPrintStream extends TFilterOutputStream {
@ -31,7 +35,7 @@ public class TPrintStream extends TFilterOutputStream {
private char[] buffer = new char[32]; private char[] buffer = new char[32];
private TCharset charset; private TCharset charset;
public TPrintStream(TOutputStream out, boolean autoFlush, TString encoding) throws TUnsupportedEncodingException { public TPrintStream(TOutputStream out, boolean autoFlush, String encoding) throws TUnsupportedEncodingException {
super(out); super(out);
this.autoFlush = autoFlush; this.autoFlush = autoFlush;
try { try {
@ -71,7 +75,7 @@ public class TPrintStream extends TFilterOutputStream {
} }
try { try {
out.write(b); out.write(b);
} catch (TIOException e) { } catch (IOException e) {
errorState = true; errorState = true;
} }
if (autoFlush && !errorState) { if (autoFlush && !errorState) {
@ -86,19 +90,19 @@ public class TPrintStream extends TFilterOutputStream {
} }
try { try {
out.write(b, off, len); out.write(b, off, len);
} catch (TIOException e) { } catch (IOException e) {
errorState = true; errorState = true;
} }
} }
@Override @Override
public void close() throws TIOException { public void close() {
if (!checkError()) { if (!checkError()) {
return; return;
} }
try { try {
out.close(); out.close();
} catch (TIOException e) { } catch (IOException e) {
errorState = true; errorState = true;
} finally { } finally {
out = null; out = null;
@ -106,13 +110,13 @@ public class TPrintStream extends TFilterOutputStream {
} }
@Override @Override
public void flush() throws TIOException { public void flush() {
if (!check()) { if (!check()) {
return; return;
} }
try { try {
out.flush(); out.flush();
} catch (TIOException e) { } catch (IOException e) {
errorState = true; errorState = true;
} }
} }
@ -173,7 +177,7 @@ public class TPrintStream extends TFilterOutputStream {
printSB(); printSB();
} }
public void print(TString s) { public void print(String s) {
sb.append(s); sb.append(s);
printSB(); printSB();
} }
@ -198,7 +202,7 @@ public class TPrintStream extends TFilterOutputStream {
printSB(); printSB();
} }
public void println(TString s) { public void println(String s) {
sb.append(s).append('\n'); sb.append(s).append('\n');
printSB(); printSB();
} }

View File

@ -15,8 +15,8 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TArrayIndexOutOfBoundsException; import org.teavm.classlib.java.lang.TArrayIndexOutOfBoundsException;
import org.teavm.classlib.java.lang.TString;
public class TPushbackInputStream extends TFilterInputStream { public class TPushbackInputStream extends TFilterInputStream {
protected byte[] buf; protected byte[] buf;
@ -38,15 +38,15 @@ public class TPushbackInputStream extends TFilterInputStream {
} }
@Override @Override
public int available() throws TIOException { public int available() throws IOException {
if (buf == null) { if (buf == null) {
throw new TIOException(); throw new IOException();
} }
return buf.length - pos + in.available(); return buf.length - pos + in.available();
} }
@Override @Override
public void close() throws TIOException { public void close() throws IOException {
if (in != null) { if (in != null) {
in.close(); in.close();
in = null; in = null;
@ -60,9 +60,9 @@ public class TPushbackInputStream extends TFilterInputStream {
} }
@Override @Override
public int read() throws TIOException { public int read() throws IOException {
if (buf == null) { if (buf == null) {
throw new TIOException(); throw new IOException();
} }
// Is there a pushback byte available? // Is there a pushback byte available?
if (pos < buf.length) { if (pos < buf.length) {
@ -74,16 +74,16 @@ public class TPushbackInputStream extends TFilterInputStream {
} }
@Override @Override
public int read(byte[] buffer, int offset, int length) throws TIOException { public int read(byte[] buffer, int offset, int length) throws IOException {
if (buf == null) { if (buf == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
// Force buffer null check first! // Force buffer null check first!
if (offset > buffer.length || offset < 0) { if (offset > buffer.length || offset < 0) {
throw new TArrayIndexOutOfBoundsException(TString.wrap("Offset out of bounds: " + offset)); throw new TArrayIndexOutOfBoundsException("Offset out of bounds: " + offset);
} }
if (length < 0 || length > buffer.length - offset) { if (length < 0 || length > buffer.length - offset) {
throw new TArrayIndexOutOfBoundsException(TString.wrap("Length out of bounds: " + length)); throw new TArrayIndexOutOfBoundsException("Length out of bounds: " + length);
} }
int copiedBytes = 0; int copiedBytes = 0;
@ -113,9 +113,9 @@ public class TPushbackInputStream extends TFilterInputStream {
} }
@Override @Override
public long skip(long count) throws TIOException { public long skip(long count) throws IOException {
if (in == null) { if (in == null) {
throw new TIOException(); throw new IOException();
} }
if (count <= 0) { if (count <= 0) {
return 0; return 0;
@ -131,44 +131,43 @@ public class TPushbackInputStream extends TFilterInputStream {
return numSkipped; return numSkipped;
} }
public void unread(byte[] buffer) throws TIOException { public void unread(byte[] buffer) throws IOException {
unread(buffer, 0, buffer.length); unread(buffer, 0, buffer.length);
} }
public void unread(byte[] buffer, int offset, int length) throws TIOException { public void unread(byte[] buffer, int offset, int length) throws IOException {
if (length > pos) { if (length > pos) {
throw new TIOException(TString.wrap("Pushback buffer full")); throw new IOException("Pushback buffer full");
} }
if (offset > buffer.length || offset < 0) { if (offset > buffer.length || offset < 0) {
throw new TArrayIndexOutOfBoundsException(TString.wrap("Offset out of bounds: " + offset)); throw new TArrayIndexOutOfBoundsException("Offset out of bounds: " + offset);
} }
if (length < 0 || length > buffer.length - offset) { if (length < 0 || length > buffer.length - offset) {
throw new TArrayIndexOutOfBoundsException(TString.wrap("Length out of bounds: " + length)); throw new TArrayIndexOutOfBoundsException("Length out of bounds: " + length);
} }
if (buf == null) { if (buf == null) {
throw new TIOException(TString.wrap("Stream is closed")); throw new IOException("Stream is closed");
} }
System.arraycopy(buffer, offset, buf, pos - length, length); System.arraycopy(buffer, offset, buf, pos - length, length);
pos = pos - length; pos = pos - length;
} }
public void unread(int oneByte) throws TIOException { public void unread(int oneByte) throws IOException {
if (buf == null) { if (buf == null) {
throw new TIOException(); throw new IOException();
} }
if (pos == 0) { if (pos == 0) {
throw new TIOException(); throw new IOException();
} }
buf[--pos] = (byte) oneByte; buf[--pos] = (byte) oneByte;
} }
@Override @Override
public void mark(int readlimit) { public void mark(int readlimit) {
return;
} }
@Override @Override
public void reset() throws TIOException { public void reset() throws IOException {
throw new TIOException(); throw new IOException();
} }
} }

View File

@ -456,7 +456,7 @@ public class TRandomAccessFile implements DataInput, DataOutput, Closeable {
return new String(out, 0, s); return new String(out, 0, s);
} }
static int writeShortToBuffer(int val, byte[] buffer, int offset) throws TIOException { static int writeShortToBuffer(int val, byte[] buffer, int offset) throws IOException {
buffer[offset++] = (byte) (val >> 8); buffer[offset++] = (byte) (val >> 8);
buffer[offset++] = (byte) val; buffer[offset++] = (byte) val;
return offset; return offset;

View File

@ -15,6 +15,7 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TMath; import org.teavm.classlib.java.lang.TMath;
import org.teavm.classlib.java.lang.TObject; import org.teavm.classlib.java.lang.TObject;
@ -29,18 +30,18 @@ public abstract class TReader implements TCloseable {
this.lock = lock; this.lock = lock;
} }
public int read() throws TIOException { public int read() throws IOException {
char[] buf = new char[1]; char[] buf = new char[1];
return read(buf) >= 0 ? buf[0] : -1; return read(buf) >= 0 ? buf[0] : -1;
} }
public int read(char[] cbuf) throws TIOException { public int read(char[] cbuf) throws IOException {
return read(cbuf, 0, cbuf.length); return read(cbuf, 0, cbuf.length);
} }
public abstract int read(char[] cbuf, int off, int len) throws TIOException; public abstract int read(char[] cbuf, int off, int len) throws IOException;
public long skip(long n) throws TIOException { public long skip(long n) throws IOException {
char[] buffer = new char[1024]; char[] buffer = new char[1024];
long skipped = 0; long skipped = 0;
while (skipped < n) { while (skipped < n) {
@ -53,7 +54,7 @@ public abstract class TReader implements TCloseable {
return skipped; return skipped;
} }
public boolean ready() throws TIOException { public boolean ready() throws IOException {
return true; return true;
} }
@ -61,11 +62,11 @@ public abstract class TReader implements TCloseable {
return false; return false;
} }
public void mark(@SuppressWarnings("unused") int readAheadLimit) throws TIOException { public void mark(@SuppressWarnings("unused") int readAheadLimit) throws IOException {
throw new TIOException(); throw new IOException();
} }
public void reset() throws TIOException { public void reset() throws IOException {
throw new TIOException(); throw new IOException();
} }
} }

View File

@ -15,6 +15,7 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TIllegalArgumentException; import org.teavm.classlib.java.lang.TIllegalArgumentException;
import org.teavm.classlib.java.lang.TMath; import org.teavm.classlib.java.lang.TMath;
import org.teavm.classlib.java.lang.TNullPointerException; import org.teavm.classlib.java.lang.TNullPointerException;
@ -33,7 +34,7 @@ public class TStringReader extends TReader {
} }
@Override @Override
public int read() throws TIOException { public int read() throws IOException {
checkOpened(); checkOpened();
if (index >= string.length()) { if (index >= string.length()) {
return -1; return -1;
@ -42,7 +43,7 @@ public class TStringReader extends TReader {
} }
@Override @Override
public int read(char[] cbuf, int off, int len) throws TIOException { public int read(char[] cbuf, int off, int len) throws IOException {
checkOpened(); checkOpened();
if (index >= string.length()) { if (index >= string.length()) {
return -1; return -1;
@ -55,7 +56,7 @@ public class TStringReader extends TReader {
} }
@Override @Override
public long skip(long n) throws TIOException { public long skip(long n) throws IOException {
checkOpened(); checkOpened();
if (n < 0) { if (n < 0) {
n = TMath.max(n, -index); n = TMath.max(n, -index);
@ -67,7 +68,7 @@ public class TStringReader extends TReader {
} }
@Override @Override
public boolean ready() throws TIOException { public boolean ready() throws IOException {
checkOpened(); checkOpened();
return true; return true;
} }
@ -78,7 +79,7 @@ public class TStringReader extends TReader {
} }
@Override @Override
public void mark(int readAheadLimit) throws TIOException { public void mark(int readAheadLimit) throws IOException {
checkOpened(); checkOpened();
if (readAheadLimit < 0) { if (readAheadLimit < 0) {
throw new TIllegalArgumentException(); throw new TIllegalArgumentException();
@ -87,7 +88,7 @@ public class TStringReader extends TReader {
} }
@Override @Override
public void reset() throws TIOException { public void reset() throws IOException {
checkOpened(); checkOpened();
index = mark; index = mark;
} }
@ -97,9 +98,9 @@ public class TStringReader extends TReader {
string = null; string = null;
} }
private void checkOpened() throws TIOException { private void checkOpened() throws IOException {
if (string == null) { if (string == null) {
throw new TIOException(); throw new IOException();
} }
} }
} }

View File

@ -15,16 +15,16 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import org.teavm.classlib.java.lang.TString; import java.io.IOException;
public class TUTFDataFormatException extends TIOException { public class TUTFDataFormatException extends IOException {
private static final long serialVersionUID = -6383472574962319733L; private static final long serialVersionUID = -6383472574962319733L;
public TUTFDataFormatException() { public TUTFDataFormatException() {
super(); super();
} }
public TUTFDataFormatException(TString message) { public TUTFDataFormatException(String message) {
super(message); super(message);
} }
} }

View File

@ -15,8 +15,6 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import org.teavm.classlib.java.lang.TString;
public class TUnsupportedEncodingException extends TIOException { public class TUnsupportedEncodingException extends TIOException {
private static final long serialVersionUID = 2403781130729330252L; private static final long serialVersionUID = 2403781130729330252L;
@ -24,7 +22,7 @@ public class TUnsupportedEncodingException extends TIOException {
super(); super();
} }
public TUnsupportedEncodingException(TString message) { public TUnsupportedEncodingException(String message) {
super(message); super(message);
} }
} }

View File

@ -15,6 +15,7 @@
*/ */
package org.teavm.classlib.java.io; package org.teavm.classlib.java.io;
import java.io.IOException;
import org.teavm.classlib.java.lang.TAppendable; import org.teavm.classlib.java.lang.TAppendable;
import org.teavm.classlib.java.lang.TCharSequence; import org.teavm.classlib.java.lang.TCharSequence;
@ -33,13 +34,13 @@ public abstract class TWriter implements TAppendable, TCloseable, TFlushable {
this.lock = lock; this.lock = lock;
} }
public void write(char[] buf) throws TIOException { public void write(char[] buf) throws IOException {
write(buf, 0, buf.length); write(buf, 0, buf.length);
} }
public abstract void write(char[] buf, int offset, int count) throws TIOException; public abstract void write(char[] buf, int offset, int count) throws IOException;
public void write(int oneChar) throws TIOException { public void write(int oneChar) throws IOException {
synchronized (lock) { synchronized (lock) {
char[] oneCharArray = new char[1]; char[] oneCharArray = new char[1];
oneCharArray[0] = (char) oneChar; oneCharArray[0] = (char) oneChar;
@ -47,11 +48,11 @@ public abstract class TWriter implements TAppendable, TCloseable, TFlushable {
} }
} }
public void write(String str) throws TIOException { public void write(String str) throws IOException {
write(str, 0, str.length()); write(str, 0, str.length());
} }
public void write(String str, int offset, int count) throws TIOException { public void write(String str, int offset, int count) throws IOException {
if (count < 0) { if (count < 0) {
throw new StringIndexOutOfBoundsException(); throw new StringIndexOutOfBoundsException();
} }
@ -63,19 +64,19 @@ public abstract class TWriter implements TAppendable, TCloseable, TFlushable {
} }
@Override @Override
public TWriter append(char c) throws TIOException { public TWriter append(char c) throws IOException {
write(c); write(c);
return this; return this;
} }
@Override @Override
public TWriter append(TCharSequence csq) throws TIOException { public TWriter append(TCharSequence csq) throws IOException {
write(csq != null ? csq.toString() : "null"); write(csq != null ? csq.toString() : "null");
return this; return this;
} }
@Override @Override
public TWriter append(TCharSequence csq, int start, int end) throws TIOException { public TWriter append(TCharSequence csq, int start, int end) throws IOException {
write(csq != null ? csq.subSequence(start, end).toString() : "null"); write(csq != null ? csq.subSequence(start, end).toString() : "null");
return this; return this;
} }

View File

@ -56,16 +56,16 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ
length = value.length(); length = value.length();
} }
protected TAbstractStringBuilder append(TString string) { protected TAbstractStringBuilder append(String string) {
return insert(length, string); return insert(length, string);
} }
protected TAbstractStringBuilder insert(int index, TString string) { protected TAbstractStringBuilder insert(int index, String string) {
if (index < 0 || index > length) { if (index < 0 || index > length) {
throw new TStringIndexOutOfBoundsException(); throw new TStringIndexOutOfBoundsException();
} }
if (string == null) { if (string == null) {
string = TString.wrap("null"); string = "null";
} else if (string.isEmpty()) { } else if (string.isEmpty()) {
return this; return this;
} }
@ -502,7 +502,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ
} }
protected TAbstractStringBuilder insert(int index, TObject obj) { protected TAbstractStringBuilder insert(int index, TObject obj) {
return insert(index, TString.wrap(obj != null ? obj.toString() : "null")); return insert(index, obj != null ? obj.toString() : "null");
} }
protected TAbstractStringBuilder append(boolean b) { protected TAbstractStringBuilder append(boolean b) {
@ -510,7 +510,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ
} }
protected TAbstractStringBuilder insert(int index, boolean b) { protected TAbstractStringBuilder insert(int index, boolean b) {
return insert(index, b ? TString.wrap("true") : TString.wrap("false")); return insert(index, b ? "true" : "false");
} }
public void ensureCapacity(int capacity) { public void ensureCapacity(int capacity) {
@ -606,7 +606,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) {
if (srcBegin > srcEnd) { if (srcBegin > srcEnd) {
throw new TIndexOutOfBoundsException(TString.wrap("Index out of bounds")); throw new IndexOutOfBoundsException("Index out of bounds");
} }
while (srcBegin < srcEnd) { while (srcBegin < srcEnd) {
dst[dstBegin++] = buffer[srcBegin++]; dst[dstBegin++] = buffer[srcBegin++];

View File

@ -15,12 +15,12 @@
*/ */
package org.teavm.classlib.java.lang; package org.teavm.classlib.java.lang;
import org.teavm.classlib.java.io.TIOException; import java.io.IOException;
public interface TAppendable { public interface TAppendable {
TAppendable append(TCharSequence csq) throws TIOException; TAppendable append(TCharSequence csq) throws IOException;
TAppendable append(TCharSequence csq, int start, int end) throws TIOException; TAppendable append(TCharSequence csq, int start, int end) throws IOException;
TAppendable append(char c) throws TIOException; TAppendable append(char c) throws IOException;
} }

View File

@ -22,7 +22,7 @@ public class TArithmeticException extends TRuntimeException {
super(); super();
} }
public TArithmeticException(TString message) { public TArithmeticException(String message) {
super(message); super(message);
} }
} }

View File

@ -22,11 +22,11 @@ public class TArrayIndexOutOfBoundsException extends TIndexOutOfBoundsException
super(); super();
} }
public TArrayIndexOutOfBoundsException(TString message) { public TArrayIndexOutOfBoundsException(String message) {
super(message); super(message);
} }
public TArrayIndexOutOfBoundsException(int index) { public TArrayIndexOutOfBoundsException(int index) {
super(TString.wrap(Integer.toString(index))); super(Integer.toString(index));
} }
} }

View File

@ -22,7 +22,7 @@ public class TArrayStoreException extends TRuntimeException {
super(); super();
} }
public TArrayStoreException(TString message) { public TArrayStoreException(String message) {
super(message); super(message);
} }
} }

View File

@ -22,11 +22,11 @@ public class TAssertionError extends TError {
super(); super();
} }
public TAssertionError(TString message, TThrowable cause) { public TAssertionError(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TAssertionError(TObject message) { public TAssertionError(Object message) {
super(TString.valueOf(message)); super(TString.valueOf(message));
} }

View File

@ -16,5 +16,5 @@
package org.teavm.classlib.java.lang; package org.teavm.classlib.java.lang;
public interface TAutoCloseable { public interface TAutoCloseable {
void close() throws TException; void close() throws Exception;
} }

View File

@ -27,7 +27,7 @@ public class TBoolean extends TObject implements TSerializable, TComparable<TBoo
this.value = value; this.value = value;
} }
public TBoolean(TString value) { public TBoolean(String value) {
this.value = parseBoolean(value); this.value = parseBoolean(value);
} }
@ -49,8 +49,8 @@ public class TBoolean extends TObject implements TSerializable, TComparable<TBoo
return 0; return 0;
} }
public static boolean parseBoolean(TString s) { public static boolean parseBoolean(String s) {
return s != null && s.toLowerCase().equals(TString.wrap("true")); return s != null && s.toLowerCase().equals("true");
} }
public boolean booleanValue() { public boolean booleanValue() {
@ -61,7 +61,7 @@ public class TBoolean extends TObject implements TSerializable, TComparable<TBoo
return value ? TRUE : FALSE; return value ? TRUE : FALSE;
} }
public static TBoolean valueOf(TString value) { public static TBoolean valueOf(String value) {
return valueOf(parseBoolean(value)); return valueOf(parseBoolean(value));
} }
@ -87,8 +87,8 @@ public class TBoolean extends TObject implements TSerializable, TComparable<TBoo
return obj instanceof TBoolean && ((TBoolean) obj).value == value; return obj instanceof TBoolean && ((TBoolean) obj).value == value;
} }
public static boolean getBoolean(TString key) { public static boolean getBoolean(String key) {
String stringValue = key != null ? TSystem.getProperty((String) (Object) key) : null; String stringValue = key != null ? TSystem.getProperty(key) : null;
return stringValue != null && valueOf(TString.wrap(stringValue)).booleanValue(); return stringValue != null && valueOf(stringValue).booleanValue();
} }
} }

View File

@ -26,7 +26,7 @@ public class TByte extends TNumber implements TComparable<TByte> {
this.value = value; this.value = value;
} }
public TByte(TString value) { public TByte(String value) {
this.value = parseByte(value, 10); this.value = parseByte(value, 10);
} }
@ -88,11 +88,11 @@ public class TByte extends TNumber implements TComparable<TByte> {
return compare(value, other.value); return compare(value, other.value);
} }
public static byte parseByte(TString s) throws TNumberFormatException { public static byte parseByte(String s) throws TNumberFormatException {
return parseByte(s, 10); return parseByte(s, 10);
} }
public static byte parseByte(TString s, int radix) throws TNumberFormatException { public static byte parseByte(String s, int radix) throws TNumberFormatException {
int value = TInteger.parseInt(s, radix); int value = TInteger.parseInt(s, radix);
if (value < MIN_VALUE || value >= MAX_VALUE) { if (value < MIN_VALUE || value >= MAX_VALUE) {
throw new TNumberFormatException(); throw new TNumberFormatException();
@ -100,15 +100,15 @@ public class TByte extends TNumber implements TComparable<TByte> {
return (byte) value; return (byte) value;
} }
public static TByte valueOf(TString s, int radix) throws TNumberFormatException { public static TByte valueOf(String s, int radix) throws TNumberFormatException {
return valueOf(parseByte(s, radix)); return valueOf(parseByte(s, radix));
} }
public static TByte valueOf(TString s) throws TNumberFormatException { public static TByte valueOf(String s) throws TNumberFormatException {
return valueOf(parseByte(s)); return valueOf(parseByte(s));
} }
public static TByte decode(TString nm) throws TNumberFormatException { public static TByte decode(String nm) throws TNumberFormatException {
TInteger value = TInteger.decode(nm); TInteger value = TInteger.decode(nm);
if (value.intValue() < MIN_VALUE || value.intValue() >= MAX_VALUE) { if (value.intValue() < MIN_VALUE || value.intValue() >= MAX_VALUE) {
throw new TNumberFormatException(); throw new TNumberFormatException();

View File

@ -53,8 +53,8 @@ import org.teavm.runtime.RuntimeClass;
import org.teavm.runtime.RuntimeObject; import org.teavm.runtime.RuntimeObject;
public class TClass<T> extends TObject implements TAnnotatedElement { public class TClass<T> extends TObject implements TAnnotatedElement {
TString name; String name;
TString simpleName; String simpleName;
private PlatformClass platformClass; private PlatformClass platformClass;
private TAnnotation[] annotationsCache; private TAnnotation[] annotationsCache;
private Map<TClass<?>, TAnnotation> annotationsByType; private Map<TClass<?>, TAnnotation> annotationsByType;
@ -105,22 +105,22 @@ public class TClass<T> extends TObject implements TAnnotatedElement {
} }
@Unmanaged @Unmanaged
public TString getName() { public String getName() {
if (PlatformDetector.isLowLevel()) { if (PlatformDetector.isLowLevel()) {
return TString.wrap(Platform.getName(platformClass)); return Platform.getName(platformClass);
} else { } else {
if (name == null) { if (name == null) {
name = TString.wrap(Platform.getName(platformClass)); name = Platform.getName(platformClass);
} }
return name; return name;
} }
} }
public TString getSimpleName() { public String getSimpleName() {
TString simpleName = getSimpleNameCache(); String simpleName = getSimpleNameCache();
if (simpleName == null) { if (simpleName == null) {
if (isArray()) { if (isArray()) {
simpleName = getComponentType().getSimpleName().concat(TString.wrap("[]")); simpleName = getComponentType().getSimpleName() + "[]";
setSimpleNameCache(simpleName); setSimpleNameCache(simpleName);
return simpleName; return simpleName;
} }
@ -137,14 +137,14 @@ public class TClass<T> extends TObject implements TAnnotatedElement {
name = name.substring(lastDot + 1); name = name.substring(lastDot + 1);
} }
} }
simpleName = TString.wrap(name); simpleName = name;
setSimpleNameCache(simpleName); setSimpleNameCache(simpleName);
} }
return simpleName; return simpleName;
} }
@DelegateTo("getSimpleNameCacheLowLevel") @DelegateTo("getSimpleNameCacheLowLevel")
private TString getSimpleNameCache() { private String getSimpleNameCache() {
return simpleName; return simpleName;
} }
@ -154,7 +154,7 @@ public class TClass<T> extends TObject implements TAnnotatedElement {
return Address.ofObject(this).<RuntimeClass>toStructure().simpleName; return Address.ofObject(this).<RuntimeClass>toStructure().simpleName;
} }
private void setSimpleNameCache(TString value) { private void setSimpleNameCache(String value) {
simpleName = value; simpleName = value;
} }
@ -559,8 +559,7 @@ public class TClass<T> extends TObject implements TAnnotatedElement {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public T cast(TObject obj) { public T cast(TObject obj) {
if (obj != null && !isAssignableFrom((TClass<?>) (Object) obj.getClass())) { if (obj != null && !isAssignableFrom((TClass<?>) (Object) obj.getClass())) {
throw new TClassCastException(TString.wrap(obj.getClass().getName() throw new TClassCastException(obj.getClass().getName() + " is not subtype of " + name);
+ " is not subtype of " + name));
} }
return (T) obj; return (T) obj;
} }

View File

@ -22,7 +22,7 @@ public class TClassCastException extends TRuntimeException {
super(); super();
} }
public TClassCastException(TString message) { public TClassCastException(String message) {
super(message); super(message);
} }
} }

View File

@ -22,11 +22,11 @@ public class TClassNotFoundException extends TReflectiveOperationException {
super(); super();
} }
public TClassNotFoundException(TString message, TThrowable cause) { public TClassNotFoundException(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TClassNotFoundException(TString message) { public TClassNotFoundException(String message) {
super(message); super(message);
} }

View File

@ -22,7 +22,7 @@ public class TCloneNotSupportedException extends TException {
super(); super();
} }
public TCloneNotSupportedException(TString message) { public TCloneNotSupportedException(String message) {
super(message); super(message);
} }
} }

View File

@ -15,18 +15,18 @@
*/ */
package org.teavm.classlib.java.lang; package org.teavm.classlib.java.lang;
import java.io.IOException;
import org.teavm.classlib.java.io.TEOFException; import org.teavm.classlib.java.io.TEOFException;
import org.teavm.classlib.java.io.TIOException;
import org.teavm.classlib.java.io.TInputStream; import org.teavm.classlib.java.io.TInputStream;
class TConsoleInputStream extends TInputStream { class TConsoleInputStream extends TInputStream {
@Override @Override
public int read(byte[] b) throws TIOException { public int read(byte[] b) throws IOException {
throw new TEOFException(); throw new TEOFException();
} }
@Override @Override
public int read() throws TIOException { public int read() throws IOException {
throw new TEOFException(); throw new TEOFException();
} }
} }

View File

@ -15,7 +15,7 @@
*/ */
package org.teavm.classlib.java.lang; package org.teavm.classlib.java.lang;
import org.teavm.classlib.java.io.TIOException; import java.io.IOException;
import org.teavm.classlib.java.io.TOutputStream; import org.teavm.classlib.java.io.TOutputStream;
import org.teavm.interop.DelegateTo; import org.teavm.interop.DelegateTo;
import org.teavm.interop.Import; import org.teavm.interop.Import;
@ -24,7 +24,7 @@ import org.teavm.jso.JSBody;
class TConsoleOutputStreamStderr extends TOutputStream { class TConsoleOutputStreamStderr extends TOutputStream {
@Override @Override
@DelegateTo("writeLowLevel") @DelegateTo("writeLowLevel")
public void write(int b) throws TIOException { public void write(int b) throws IOException {
writeJs(b); writeJs(b);
} }

View File

@ -15,7 +15,7 @@
*/ */
package org.teavm.classlib.java.lang; package org.teavm.classlib.java.lang;
import org.teavm.classlib.java.io.TIOException; import java.io.IOException;
import org.teavm.classlib.java.io.TOutputStream; import org.teavm.classlib.java.io.TOutputStream;
import org.teavm.interop.DelegateTo; import org.teavm.interop.DelegateTo;
import org.teavm.jso.JSBody; import org.teavm.jso.JSBody;
@ -23,7 +23,7 @@ import org.teavm.jso.JSBody;
class TConsoleOutputStreamStdout extends TOutputStream { class TConsoleOutputStreamStdout extends TOutputStream {
@Override @Override
@DelegateTo("writeLowLevel") @DelegateTo("writeLowLevel")
public void write(int b) throws TIOException { public void write(int b) throws IOException {
writeJs(b); writeJs(b);
} }

View File

@ -251,11 +251,11 @@ public class TDouble extends TNumber implements TComparable<TDouble> {
@Import(name = "teavm_reinterpretLongToDouble") @Import(name = "teavm_reinterpretLongToDouble")
public static native double longBitsToDouble(long bits); public static native double longBitsToDouble(long bits);
public static TString toHexString(double d) { public static String toHexString(double d) {
if (isNaN(d)) { if (isNaN(d)) {
return TString.wrap("NaN"); return "NaN";
} else if (isInfinite(d)) { } else if (isInfinite(d)) {
return d > 0 ? TString.wrap("Infinity") : TString.wrap("-Infinity"); return d > 0 ? "Infinity" : "-Infinity";
} }
char[] buffer = new char[30]; char[] buffer = new char[30];
int sz = 0; int sz = 0;
@ -312,6 +312,6 @@ public class TDouble extends TNumber implements TComparable<TDouble> {
buffer[sz++] = '0'; buffer[sz++] = '0';
} }
return new TString(buffer, 0, sz); return new String(buffer, 0, sz);
} }
} }

View File

@ -64,8 +64,8 @@ public abstract class TEnum<E extends TEnum<E>> extends TObject implements TComp
@Override @Override
public final int compareTo(E o) { public final int compareTo(E o) {
if (o.getDeclaringClass() != getDeclaringClass()) { if (o.getDeclaringClass() != getDeclaringClass()) {
throw new TIllegalArgumentException(TString.wrap("Can't compare " throw new TIllegalArgumentException("Can't compare "
+ getDeclaringClass().getName().toString() + " to " + o.getDeclaringClass().getName().toString())); + getDeclaringClass().getName() + " to " + o.getDeclaringClass().getName());
} }
return TInteger.compare(ordinal, o.ordinal()); return TInteger.compare(ordinal, o.ordinal());
} }
@ -74,14 +74,13 @@ public abstract class TEnum<E extends TEnum<E>> extends TObject implements TComp
// TODO: speed-up this method, use caching // TODO: speed-up this method, use caching
T[] constants = enumType.getEnumConstants(); T[] constants = enumType.getEnumConstants();
if (constants == null) { if (constants == null) {
throw new TIllegalArgumentException(TString.wrap("Class does not represent enum: " + enumType.getName())); throw new TIllegalArgumentException("Class does not represent enum: " + enumType.getName());
} }
for (T constant : constants) { for (T constant : constants) {
if (constant.name().equals(name)) { if (constant.name().equals(name)) {
return constant; return constant;
} }
} }
throw new TIllegalArgumentException(TString.wrap("Enum " + enumType.getName() + " does not have the " + name throw new TIllegalArgumentException("Enum " + enumType.getName() + " does not have the " + name + "constant");
+ "constant"));
} }
} }

View File

@ -21,11 +21,11 @@ public class TError extends TThrowable {
public TError() { public TError() {
} }
public TError(TString message, TThrowable cause) { public TError(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TError(TString message) { public TError(String message) {
super(message); super(message);
} }

View File

@ -22,11 +22,11 @@ public class TException extends TThrowable {
super(); super();
} }
public TException(TString message, TThrowable cause) { public TException(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TException(TString message) { public TException(String message) {
super(message); super(message);
} }

View File

@ -256,11 +256,11 @@ public class TFloat extends TNumber implements TComparable<TFloat> {
@Import(name = "teavm_reinterpretIntToFloat") @Import(name = "teavm_reinterpretIntToFloat")
public static native float intBitsToFloat(int bits); public static native float intBitsToFloat(int bits);
public static TString toHexString(float f) { public static String toHexString(float f) {
if (isNaN(f)) { if (isNaN(f)) {
return TString.wrap("NaN"); return "NaN";
} else if (isInfinite(f)) { } else if (isInfinite(f)) {
return f > 0 ? TString.wrap("Infinity") : TString.wrap("-Infinity"); return f > 0 ? "Infinity" : "-Infinity";
} }
char[] buffer = new char[18]; char[] buffer = new char[18];
int sz = 0; int sz = 0;
@ -317,6 +317,6 @@ public class TFloat extends TNumber implements TComparable<TFloat> {
buffer[sz++] = '0'; buffer[sz++] = '0';
} }
return new TString(buffer, 0, sz); return new String(buffer, 0, sz);
} }
} }

View File

@ -22,11 +22,11 @@ public class TIllegalArgumentException extends TRuntimeException {
super(); super();
} }
public TIllegalArgumentException(TString message, TThrowable cause) { public TIllegalArgumentException(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TIllegalArgumentException(TString message) { public TIllegalArgumentException(String message) {
super(message); super(message);
} }

View File

@ -22,7 +22,7 @@ public class TIllegalMonitorStateException extends TRuntimeException {
super(); super();
} }
public TIllegalMonitorStateException(TString message) { public TIllegalMonitorStateException(String message) {
super(message); super(message);
} }
} }

View File

@ -22,11 +22,11 @@ public class TIllegalStateException extends TException {
super(); super();
} }
public TIllegalStateException(TString message, TThrowable cause) { public TIllegalStateException(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TIllegalStateException(TString message) { public TIllegalStateException(String message) {
super(message); super(message);
} }

View File

@ -22,7 +22,7 @@ public class TIncompatibleClassChangeError extends TLinkageError {
super(); super();
} }
public TIncompatibleClassChangeError(TString message) { public TIncompatibleClassChangeError(String message) {
super(message); super(message);
} }
} }

View File

@ -22,7 +22,7 @@ public class TIndexOutOfBoundsException extends TRuntimeException {
super(); super();
} }
public TIndexOutOfBoundsException(TString message) { public TIndexOutOfBoundsException(String message) {
super(message); super(message);
} }
} }

View File

@ -30,7 +30,7 @@ public class TInteger extends TNumber implements TComparable<TInteger> {
this.value = value; this.value = value;
} }
public TInteger(TString s) throws NumberFormatException { public TInteger(String s) throws NumberFormatException {
this(parseInt(s)); this(parseInt(s));
} }
@ -57,12 +57,12 @@ public class TInteger extends TNumber implements TComparable<TInteger> {
return toString(i, 10); return toString(i, 10);
} }
public static int parseInt(TString s, int radix) throws TNumberFormatException { public static int parseInt(String s, int radix) throws TNumberFormatException {
if (radix < TCharacter.MIN_RADIX || radix > TCharacter.MAX_RADIX) { if (radix < TCharacter.MIN_RADIX || radix > TCharacter.MAX_RADIX) {
throw new TNumberFormatException(TString.wrap("Illegal radix: " + radix)); throw new TNumberFormatException("Illegal radix: " + radix);
} }
if (s == null || s.isEmpty()) { if (s == null || s.isEmpty()) {
throw new TNumberFormatException(TString.wrap("String is null or empty")); throw new TNumberFormatException("String is null or empty");
} }
boolean negative = false; boolean negative = false;
int index = 0; int index = 0;
@ -82,32 +82,32 @@ public class TInteger extends TNumber implements TComparable<TInteger> {
while (index < s.length()) { while (index < s.length()) {
int digit = TCharacter.getNumericValue(s.charAt(index++)); int digit = TCharacter.getNumericValue(s.charAt(index++));
if (digit < 0) { if (digit < 0) {
throw new TNumberFormatException(TString.wrap("String contains invalid digits: " + s)); throw new TNumberFormatException("String contains invalid digits: " + s);
} }
if (digit >= radix) { if (digit >= radix) {
throw new TNumberFormatException(TString.wrap("String contains digits out of radix " + radix throw new TNumberFormatException("String contains digits out of radix " + radix
+ ": " + s)); + ": " + s);
} }
value = radix * value + digit; value = radix * value + digit;
if (value < 0) { if (value < 0) {
if (index == s.length() && value == MIN_VALUE && negative) { if (index == s.length() && value == MIN_VALUE && negative) {
return MIN_VALUE; return MIN_VALUE;
} }
throw new TNumberFormatException(TString.wrap("The value is too big for int type: " + s)); throw new TNumberFormatException("The value is too big for int type: " + s);
} }
} }
return negative ? -value : value; return negative ? -value : value;
} }
public static int parseInt(TString s) throws TNumberFormatException { public static int parseInt(String s) throws TNumberFormatException {
return parseInt(s, 10); return parseInt(s, 10);
} }
public static TInteger valueOf(TString s, int radix) throws TNumberFormatException { public static TInteger valueOf(String s, int radix) throws TNumberFormatException {
return valueOf(parseInt(s, radix)); return valueOf(parseInt(s, radix));
} }
public static TInteger valueOf(TString s) throws TNumberFormatException { public static TInteger valueOf(String s) throws TNumberFormatException {
return valueOf(s, 10); return valueOf(s, 10);
} }
@ -175,7 +175,7 @@ public class TInteger extends TNumber implements TComparable<TInteger> {
} }
public static TInteger getInteger(TString nm, TInteger val) { public static TInteger getInteger(TString nm, TInteger val) {
TString result = nm != null ? TString.wrap(TSystem.getProperty(nm.toString())) : null; String result = nm != null ? TSystem.getProperty(nm.toString()) : null;
try { try {
return result != null ? TInteger.valueOf(result) : val; return result != null ? TInteger.valueOf(result) : val;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
@ -183,9 +183,9 @@ public class TInteger extends TNumber implements TComparable<TInteger> {
} }
} }
public static TInteger decode(TString nm) throws TNumberFormatException { public static TInteger decode(String nm) throws TNumberFormatException {
if (nm == null || nm.isEmpty()) { if (nm == null || nm.isEmpty()) {
throw new TNumberFormatException(TString.wrap("Can't parse empty or null string")); throw new TNumberFormatException("Can't parse empty or null string");
} }
int index = 0; int index = 0;
boolean negaive = false; boolean negaive = false;
@ -196,7 +196,7 @@ public class TInteger extends TNumber implements TComparable<TInteger> {
negaive = true; negaive = true;
} }
if (index >= nm.length()) { if (index >= nm.length()) {
throw new TNumberFormatException(TString.wrap("The string does not represent a number")); throw new TNumberFormatException("The string does not represent a number");
} }
int radix = 10; int radix = 10;
if (nm.charAt(index) == '#') { if (nm.charAt(index) == '#') {
@ -215,20 +215,20 @@ public class TInteger extends TNumber implements TComparable<TInteger> {
} }
} }
if (index >= nm.length()) { if (index >= nm.length()) {
throw new TNumberFormatException(TString.wrap("The string does not represent a number")); throw new TNumberFormatException("The string does not represent a number");
} }
int value = 0; int value = 0;
while (index < nm.length()) { while (index < nm.length()) {
int digit = decodeDigit(nm.charAt(index++)); int digit = decodeDigit(nm.charAt(index++));
if (digit >= radix) { if (digit >= radix) {
throw new TNumberFormatException(TString.wrap("The string does not represent a number")); throw new TNumberFormatException("The string does not represent a number");
} }
value = value * radix + digit; value = value * radix + digit;
if (value < 0) { if (value < 0) {
if (negaive && value == MIN_VALUE && index == nm.length()) { if (negaive && value == MIN_VALUE && index == nm.length()) {
return TInteger.valueOf(MIN_VALUE); return TInteger.valueOf(MIN_VALUE);
} }
throw new TNumberFormatException(TString.wrap("The string represents a too big number")); throw new TNumberFormatException("The string represents a too big number");
} }
} }
return TInteger.valueOf(negaive ? -value : value); return TInteger.valueOf(negaive ? -value : value);

View File

@ -20,11 +20,11 @@ public class TInternalError extends TVirtualMachineError {
public TInternalError() { public TInternalError() {
} }
public TInternalError(TString message) { public TInternalError(String message) {
super(message); super(message);
} }
public TInternalError(TString message, TThrowable cause) { public TInternalError(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }

View File

@ -22,11 +22,11 @@ public class TLinkageError extends TError {
super(); super();
} }
public TLinkageError(TString message, TThrowable cause) { public TLinkageError(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TLinkageError(TString message) { public TLinkageError(String message) {
super(message); super(message);
} }
} }

View File

@ -29,7 +29,7 @@ public class TLong extends TNumber implements TComparable<TLong> {
this.value = value; this.value = value;
} }
public TLong(TString value) throws TNumberFormatException { public TLong(String value) throws TNumberFormatException {
this(parseLong(value)); this(parseLong(value));
} }
@ -37,12 +37,12 @@ public class TLong extends TNumber implements TComparable<TLong> {
return new TLong(value); return new TLong(value);
} }
public static long parseLong(TString s, int radix) throws TNumberFormatException { public static long parseLong(String s, int radix) throws TNumberFormatException {
if (radix < TCharacter.MIN_RADIX || radix > TCharacter.MAX_RADIX) { if (radix < TCharacter.MIN_RADIX || radix > TCharacter.MAX_RADIX) {
throw new TNumberFormatException(TString.wrap("Illegal radix: " + radix)); throw new TNumberFormatException("Illegal radix: " + radix);
} }
if (s == null || s.isEmpty()) { if (s == null || s.isEmpty()) {
throw new TNumberFormatException(TString.wrap("String is null or empty")); throw new TNumberFormatException("String is null or empty");
} }
boolean negative = false; boolean negative = false;
int index = 0; int index = 0;
@ -59,38 +59,38 @@ public class TLong extends TNumber implements TComparable<TLong> {
while (index < s.length()) { while (index < s.length()) {
int digit = TCharacter.getNumericValue(s.charAt(index++)); int digit = TCharacter.getNumericValue(s.charAt(index++));
if (digit < 0) { if (digit < 0) {
throw new TNumberFormatException(TString.wrap("String contains invalid digits: " + s)); throw new TNumberFormatException("String contains invalid digits: " + s);
} }
if (digit >= radix) { if (digit >= radix) {
throw new TNumberFormatException(TString.wrap("String contains digits out of radix " + radix throw new TNumberFormatException("String contains digits out of radix " + radix
+ ": " + s)); + ": " + s);
} }
value = radix * value + digit; value = radix * value + digit;
if (value < 0) { if (value < 0) {
if (index == s.length() && value == MIN_VALUE && negative) { if (index == s.length() && value == MIN_VALUE && negative) {
return MIN_VALUE; return MIN_VALUE;
} }
throw new TNumberFormatException(TString.wrap("The value is too big for int type: " + s)); throw new TNumberFormatException("The value is too big for int type: " + s);
} }
} }
return negative ? -value : value; return negative ? -value : value;
} }
public static long parseLong(TString s) throws TNumberFormatException { public static long parseLong(String s) throws TNumberFormatException {
return parseLong(s, 10); return parseLong(s, 10);
} }
public static TLong valueOf(TString s, int radix) throws TNumberFormatException { public static TLong valueOf(String s, int radix) throws TNumberFormatException {
return valueOf(parseLong(s, radix)); return valueOf(parseLong(s, radix));
} }
public static TLong valueOf(TString s) throws TNumberFormatException { public static TLong valueOf(String s) throws TNumberFormatException {
return valueOf(parseLong(s)); return valueOf(parseLong(s));
} }
public static TLong decode(TString nm) throws TNumberFormatException { public static TLong decode(TString nm) throws TNumberFormatException {
if (nm == null || nm.isEmpty()) { if (nm == null || nm.isEmpty()) {
throw new TNumberFormatException(TString.wrap("Can't parse empty or null string")); throw new TNumberFormatException("Can't parse empty or null string");
} }
int index = 0; int index = 0;
boolean negaive = false; boolean negaive = false;
@ -101,7 +101,7 @@ public class TLong extends TNumber implements TComparable<TLong> {
negaive = true; negaive = true;
} }
if (index >= nm.length()) { if (index >= nm.length()) {
throw new TNumberFormatException(TString.wrap("The string does not represent a number")); throw new TNumberFormatException("The string does not represent a number");
} }
int radix = 10; int radix = 10;
if (nm.charAt(index) == '#') { if (nm.charAt(index) == '#') {
@ -120,20 +120,20 @@ public class TLong extends TNumber implements TComparable<TLong> {
} }
} }
if (index >= nm.length()) { if (index >= nm.length()) {
throw new TNumberFormatException(TString.wrap("The string does not represent a number")); throw new TNumberFormatException("The string does not represent a number");
} }
long value = 0; long value = 0;
while (index < nm.length()) { while (index < nm.length()) {
int digit = decodeDigit(nm.charAt(index++)); int digit = decodeDigit(nm.charAt(index++));
if (digit >= radix) { if (digit >= radix) {
throw new TNumberFormatException(TString.wrap("The string does not represent a number")); throw new TNumberFormatException("The string does not represent a number");
} }
value = value * radix + digit; value = value * radix + digit;
if (value < 0) { if (value < 0) {
if (negaive && value == MIN_VALUE && index == nm.length()) { if (negaive && value == MIN_VALUE && index == nm.length()) {
return TLong.valueOf(MIN_VALUE); return TLong.valueOf(MIN_VALUE);
} }
throw new TNumberFormatException(TString.wrap("The string represents a too big number")); throw new TNumberFormatException("The string represents a too big number");
} }
} }
return TLong.valueOf(negaive ? -value : value); return TLong.valueOf(negaive ? -value : value);
@ -219,16 +219,16 @@ public class TLong extends TNumber implements TComparable<TLong> {
return compare(value, other.value); return compare(value, other.value);
} }
public static TLong getLong(TString nm) { public static TLong getLong(String nm) {
return getLong(nm, null); return getLong(nm, null);
} }
public static TLong getLong(TString nm, long val) { public static TLong getLong(String nm, long val) {
return getLong(nm, TLong.valueOf(val)); return getLong(nm, TLong.valueOf(val));
} }
public static TLong getLong(TString nm, TLong val) { public static TLong getLong(String nm, TLong val) {
TString result = nm != null ? TString.wrap(TSystem.getProperty(nm.toString())) : null; String result = nm != null ? TSystem.getProperty(nm) : null;
try { try {
return result != null ? TLong.valueOf(result) : val; return result != null ? TLong.valueOf(result) : val;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {

View File

@ -22,7 +22,7 @@ public class TNegativeArraySizeException extends TRuntimeException {
super(); super();
} }
public TNegativeArraySizeException(TString message) { public TNegativeArraySizeException(String message) {
super(message); super(message);
} }
} }

View File

@ -22,7 +22,7 @@ public class TNoClassDefFoundError extends TLinkageError {
super(); super();
} }
public TNoClassDefFoundError(TString message) { public TNoClassDefFoundError(String message) {
super(message); super(message);
} }
} }

View File

@ -22,7 +22,7 @@ public class TNoSuchFieldError extends TIncompatibleClassChangeError {
super(); super();
} }
public TNoSuchFieldError(TString message) { public TNoSuchFieldError(String message) {
super(message); super(message);
} }
} }

View File

@ -22,7 +22,7 @@ public class TNoSuchMethodError extends TIncompatibleClassChangeError {
super(); super();
} }
public TNoSuchMethodError(TString message) { public TNoSuchMethodError(String message) {
super(message); super(message);
} }
} }

View File

@ -19,7 +19,7 @@ public class TNoSuchMethodException extends TReflectiveOperationException {
public TNoSuchMethodException() { public TNoSuchMethodException() {
} }
public TNoSuchMethodException(TString message) { public TNoSuchMethodException(String message) {
super(message); super(message);
} }
} }

View File

@ -18,7 +18,7 @@ package org.teavm.classlib.java.lang;
public class TNullPointerException extends TRuntimeException { public class TNullPointerException extends TRuntimeException {
private static final long serialVersionUID = 2639861320773057190L; private static final long serialVersionUID = 2639861320773057190L;
public TNullPointerException(TString message) { public TNullPointerException(String message) {
super(message); super(message);
} }

View File

@ -22,7 +22,7 @@ public class TNumberFormatException extends TIllegalArgumentException {
super(); super();
} }
public TNumberFormatException(TString message) { public TNumberFormatException(String message) {
super(message); super(message);
} }
} }

View File

@ -23,7 +23,6 @@ import org.teavm.interop.Rename;
import org.teavm.interop.Structure; import org.teavm.interop.Structure;
import org.teavm.interop.Superclass; import org.teavm.interop.Superclass;
import org.teavm.interop.Sync; import org.teavm.interop.Sync;
import org.teavm.interop.Unmanaged;
import org.teavm.jso.browser.TimerHandler; import org.teavm.jso.browser.TimerHandler;
import org.teavm.platform.Platform; import org.teavm.platform.Platform;
import org.teavm.platform.PlatformObject; import org.teavm.platform.PlatformObject;
@ -392,9 +391,4 @@ public class TObject {
@Override @Override
protected void finalize() throws TThrowable { protected void finalize() throws TThrowable {
} }
@Unmanaged
public static TObject wrap(Object obj) {
return (TObject) obj;
}
} }

View File

@ -22,7 +22,7 @@ public class TOutOfMemoryError extends TVirtualMachineError {
super(); super();
} }
public TOutOfMemoryError(TString message) { public TOutOfMemoryError(String message) {
super(message); super(message);
} }
} }

View File

@ -22,11 +22,11 @@ public class TReflectiveOperationException extends TException {
super(); super();
} }
public TReflectiveOperationException(TString message, TThrowable cause) { public TReflectiveOperationException(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TReflectiveOperationException(TString message) { public TReflectiveOperationException(String message) {
super(message); super(message);
} }

View File

@ -25,11 +25,11 @@ public class TRuntimeException extends TException {
super(); super();
} }
public TRuntimeException(TString message, TThrowable cause) { public TRuntimeException(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TRuntimeException(TString message) { public TRuntimeException(String message) {
super(message); super(message);
} }

View File

@ -22,11 +22,11 @@ public class TSecurityException extends TRuntimeException {
super(); super();
} }
public TSecurityException(TString message, TThrowable cause) { public TSecurityException(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TSecurityException(TString message) { public TSecurityException(String message) {
super(message); super(message);
} }

View File

@ -26,7 +26,7 @@ public class TShort extends TNumber implements TComparable<TShort> {
this.value = value; this.value = value;
} }
public TShort(TString s) throws TNumberFormatException { public TShort(String s) throws TNumberFormatException {
this(parseShort(s)); this(parseShort(s));
} }
@ -87,7 +87,7 @@ public class TShort extends TNumber implements TComparable<TShort> {
return compare(value, other.value); return compare(value, other.value);
} }
public static short parseShort(TString s, int radix) throws TNumberFormatException { public static short parseShort(String s, int radix) throws TNumberFormatException {
int value = TInteger.parseInt(s, radix); int value = TInteger.parseInt(s, radix);
if (value < MIN_VALUE || value > MAX_VALUE) { if (value < MIN_VALUE || value > MAX_VALUE) {
throw new TNumberFormatException(); throw new TNumberFormatException();
@ -95,19 +95,19 @@ public class TShort extends TNumber implements TComparable<TShort> {
return (short) value; return (short) value;
} }
public static short parseShort(TString s) throws TNumberFormatException { public static short parseShort(String s) throws TNumberFormatException {
return parseShort(s, 10); return parseShort(s, 10);
} }
public static TShort valueOf(TString s, int radix) throws TNumberFormatException { public static TShort valueOf(String s, int radix) throws TNumberFormatException {
return valueOf(parseShort(s, radix)); return valueOf(parseShort(s, radix));
} }
public static TShort valueOf(TString s) throws TNumberFormatException { public static TShort valueOf(String s) throws TNumberFormatException {
return valueOf(parseShort(s)); return valueOf(parseShort(s));
} }
public static TShort decode(TString s) throws TNumberFormatException { public static TShort decode(String s) throws TNumberFormatException {
int value = TInteger.decode(s).intValue(); int value = TInteger.decode(s).intValue();
if (value < MIN_VALUE || value > MAX_VALUE) { if (value < MIN_VALUE || value > MAX_VALUE) {
throw new TNumberFormatException(); throw new TNumberFormatException();

View File

@ -31,17 +31,13 @@
*/ */
package org.teavm.classlib.java.lang; package org.teavm.classlib.java.lang;
/**
*
* @author Sergey Kapralov
*/
public class TStackOverflowError extends TVirtualMachineError { public class TStackOverflowError extends TVirtualMachineError {
public TStackOverflowError() { public TStackOverflowError() {
super(); super();
} }
public TStackOverflowError(TString string) { public TStackOverflowError(String string) {
super(string); super(string);
} }
} }

View File

@ -20,12 +20,12 @@ import org.teavm.classlib.java.io.TSerializable;
import org.teavm.classlib.java.util.TObjects; import org.teavm.classlib.java.util.TObjects;
public final class TStackTraceElement extends TObject implements TSerializable { public final class TStackTraceElement extends TObject implements TSerializable {
private TString declaringClass; private String declaringClass;
private TString methodName; private String methodName;
private TString fileName; private String fileName;
private int lineNumber; private int lineNumber;
public TStackTraceElement(TString declaringClass, TString methodName, TString fileName, int lineNumber) { public TStackTraceElement(String declaringClass, String methodName, String fileName, int lineNumber) {
if (declaringClass == null || methodName == null) { if (declaringClass == null || methodName == null) {
throw new TNullPointerException(); throw new TNullPointerException();
} }
@ -35,15 +35,15 @@ public final class TStackTraceElement extends TObject implements TSerializable {
this.lineNumber = lineNumber; this.lineNumber = lineNumber;
} }
public TString getClassName() { public String getClassName() {
return declaringClass; return declaringClass;
} }
public TString getMethodName() { public String getMethodName() {
return methodName; return methodName;
} }
public TString getFileName() { public String getFileName() {
return fileName; return fileName;
} }
@ -77,15 +77,15 @@ public final class TStackTraceElement extends TObject implements TSerializable {
@Override @Override
public String toString() { public String toString() {
TStringBuilder sb = new TStringBuilder(); StringBuilder sb = new StringBuilder();
int index = declaringClass.lastIndexOf('.'); int index = declaringClass.lastIndexOf('.');
sb.append(declaringClass.substring(index + 1)).append('.').append(methodName).append('('); sb.append(declaringClass.substring(index + 1)).append('.').append(methodName).append('(');
if (fileName != null) { if (fileName != null) {
sb.append(fileName).append(':').append(lineNumber); sb.append(fileName).append(':').append(lineNumber);
} else { } else {
sb.append(TString.wrap("Unknown Source")); sb.append("Unknown Source");
} }
sb.append(TString.wrap(")")); sb.append(")");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -30,7 +30,6 @@ import org.teavm.classlib.java.util.THashMap;
import org.teavm.classlib.java.util.TLocale; import org.teavm.classlib.java.util.TLocale;
import org.teavm.classlib.java.util.TMap; import org.teavm.classlib.java.util.TMap;
import org.teavm.classlib.java.util.regex.TPattern; import org.teavm.classlib.java.util.regex.TPattern;
import org.teavm.interop.Unmanaged;
public class TString extends TObject implements TSerializable, TComparable<TString>, TCharSequence { public class TString extends TObject implements TSerializable, TComparable<TString>, TCharSequence {
public static final TComparator<TString> CASE_INSENSITIVE_ORDER = (o1, o2) -> o1.compareToIgnoreCase(o2); public static final TComparator<TString> CASE_INSENSITIVE_ORDER = (o1, o2) -> o1.compareToIgnoreCase(o2);
@ -425,8 +424,8 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
return false; return false;
} }
public TString replace(TCharSequence target, TCharSequence replacement) { public String replace(TCharSequence target, TCharSequence replacement) {
TStringBuilder sb = new TStringBuilder(); StringBuilder sb = new StringBuilder();
int sz = length() - target.length(); int sz = length() - target.length();
int i = 0; int i = 0;
outer: outer:
@ -441,7 +440,7 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
i += target.length() - 1; i += target.length() - 1;
} }
sb.append(substring(i)); sb.append(substring(i));
return TString.wrap(sb.toString()); return sb.toString();
} }
public TString trim() { public TString trim() {
@ -469,8 +468,8 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
return array; return array;
} }
public static TString valueOf(TObject obj) { public static String valueOf(Object obj) {
return obj != null ? TString.wrap(obj.toString()) : TString.wrap("null"); return obj != null ? obj.toString() : "null";
} }
public static TString valueOf(char[] data) { public static TString valueOf(char[] data) {
@ -489,28 +488,28 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
return valueOf(data, offset, count); return valueOf(data, offset, count);
} }
public static TString valueOf(boolean b) { public static String valueOf(boolean b) {
return b ? TString.wrap("true") : TString.wrap("false"); return b ? "true" : "false";
} }
public static TString valueOf(char c) { public static String valueOf(char c) {
return new TString(new char[] { c }); return new String(new char[] { c });
} }
public static TString valueOf(int i) { public static String valueOf(int i) {
return TString.wrap(new TStringBuilder().append(i).toString()); return new TStringBuilder().append(i).toString();
} }
public static TString valueOf(long l) { public static String valueOf(long l) {
return TString.wrap(new TStringBuilder().append(l).toString()); return new TStringBuilder().append(l).toString();
} }
public static TString valueOf(float f) { public static String valueOf(float f) {
return TString.wrap(new TStringBuilder().append(f).toString()); return new TStringBuilder().append(f).toString();
} }
public static TString valueOf(double d) { public static String valueOf(double d) {
return TString.wrap(new TStringBuilder().append(d).toString()); return new TStringBuilder().append(d).toString();
} }
@Override @Override
@ -580,11 +579,6 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
return hashCode; return hashCode;
} }
@Unmanaged
public static TString wrap(String str) {
return (TString) (Object) str;
}
public TString toLowerCase() { public TString toLowerCase() {
if (isEmpty()) { if (isEmpty()) {
return this; return this;

View File

@ -33,7 +33,7 @@ public class TStringBuffer extends TAbstractStringBuilder implements TAppendable
} }
@Override @Override
public TStringBuffer append(TString string) { public TStringBuffer append(String string) {
super.append(string); super.append(string);
return this; return this;
} }
@ -201,7 +201,7 @@ public class TStringBuffer extends TAbstractStringBuilder implements TAppendable
} }
@Override @Override
public TStringBuffer insert(int index, TString string) { public TStringBuffer insert(int index, String string) {
super.insert(index, string); super.insert(index, string);
return this; return this;
} }

View File

@ -33,7 +33,7 @@ public class TStringBuilder extends TAbstractStringBuilder implements TAppendabl
} }
@Override @Override
public TStringBuilder append(TString string) { public TStringBuilder append(String string) {
super.append(string); super.append(string);
return this; return this;
} }
@ -201,7 +201,7 @@ public class TStringBuilder extends TAbstractStringBuilder implements TAppendabl
} }
@Override @Override
public TStringBuilder insert(int index, TString string) { public TStringBuilder insert(int index, String string) {
super.insert(index, string); super.insert(index, string);
return this; return this;
} }

View File

@ -22,12 +22,11 @@ public class TStringIndexOutOfBoundsException extends TIndexOutOfBoundsException
super(); super();
} }
public TStringIndexOutOfBoundsException(TString message) { public TStringIndexOutOfBoundsException(String message) {
super(message); super(message);
} }
public TStringIndexOutOfBoundsException(int index) { public TStringIndexOutOfBoundsException(int index) {
super(TString.wrap(new TStringBuilder().append(TString.wrap("String index out of bounds: ")) super(new TStringBuilder().append("String index out of bounds: ").append(index).toString());
.append(index).toString()));
} }
} }

View File

@ -68,7 +68,7 @@ public final class TSystem extends TObject {
public static void arraycopy(TObject src, int srcPos, TObject dest, int destPos, int length) { public static void arraycopy(TObject src, int srcPos, TObject dest, int destPos, int length) {
if (src == null || dest == null) { if (src == null || dest == null) {
throw new TNullPointerException(TString.wrap("Either src or dest is null")); throw new TNullPointerException("Either src or dest is null");
} }
if (srcPos < 0 || destPos < 0 || length < 0 || srcPos + length > TArray.getLength(src) if (srcPos < 0 || destPos < 0 || length < 0 || srcPos + length > TArray.getLength(src)
|| destPos + length > TArray.getLength(dest)) { || destPos + length > TArray.getLength(dest)) {

View File

@ -21,7 +21,7 @@ import org.teavm.platform.PlatformRunnable;
import org.teavm.platform.async.AsyncCallback; import org.teavm.platform.async.AsyncCallback;
public class TThread extends TObject implements TRunnable { public class TThread extends TObject implements TRunnable {
private static TThread mainThread = new TThread(TString.wrap("main")); private static TThread mainThread = new TThread("main");
private static TThread currentThread = mainThread; private static TThread currentThread = mainThread;
private static long nextId = 1; private static long nextId = 1;
private static int activeCount = 1; private static int activeCount = 1;
@ -33,7 +33,7 @@ public class TThread extends TObject implements TRunnable {
private boolean interruptedFlag; private boolean interruptedFlag;
public TThreadInterruptHandler interruptHandler; public TThreadInterruptHandler interruptHandler;
private TString name; private String name;
private boolean alive = true; private boolean alive = true;
TRunnable target; TRunnable target;
@ -41,7 +41,7 @@ public class TThread extends TObject implements TRunnable {
this(null, null); this(null, null);
} }
public TThread(TString name) { public TThread(String name) {
this(null, name); this(null, name);
} }
@ -49,7 +49,7 @@ public class TThread extends TObject implements TRunnable {
this(target, null); this(target, null);
} }
public TThread(TRunnable target, TString name) { public TThread(TRunnable target, String name) {
this.name = name; this.name = name;
this.target = target; this.target = target;
id = nextId++; id = nextId++;
@ -94,7 +94,7 @@ public class TThread extends TObject implements TRunnable {
return currentThread; return currentThread;
} }
public TString getName() { public String getName() {
return name; return name;
} }

View File

@ -15,8 +15,8 @@
*/ */
package org.teavm.classlib.java.lang; package org.teavm.classlib.java.lang;
import org.teavm.classlib.java.io.TPrintStream; import java.io.PrintStream;
import org.teavm.classlib.java.io.TPrintWriter; import java.io.PrintWriter;
import org.teavm.classlib.java.util.TArrays; import org.teavm.classlib.java.util.TArrays;
import org.teavm.interop.DelegateTo; import org.teavm.interop.DelegateTo;
import org.teavm.interop.Remove; import org.teavm.interop.Remove;
@ -27,7 +27,7 @@ import org.teavm.runtime.ExceptionHandling;
@Superclass("java.lang.Object") @Superclass("java.lang.Object")
public class TThrowable extends RuntimeException { public class TThrowable extends RuntimeException {
private static final long serialVersionUID = 2026791432677149320L; private static final long serialVersionUID = 2026791432677149320L;
private TString message; private String message;
private TThrowable cause; private TThrowable cause;
private boolean suppressionEnabled; private boolean suppressionEnabled;
private boolean writableStackTrace; private boolean writableStackTrace;
@ -36,11 +36,11 @@ public class TThrowable extends RuntimeException {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Rename("fakeInit") @Rename("fakeInit")
protected TThrowable(TString message, TThrowable cause, boolean enableSuppression, boolean writableStackTrace) { protected TThrowable(String message, TThrowable cause, boolean enableSuppression, boolean writableStackTrace) {
} }
@Rename("<init>") @Rename("<init>")
public void init(TString message, TThrowable cause, boolean enableSuppression, boolean writableStackTrace) { public void init(String message, TThrowable cause, boolean enableSuppression, boolean writableStackTrace) {
if (writableStackTrace) { if (writableStackTrace) {
fillInStackTrace(); fillInStackTrace();
} }
@ -62,11 +62,11 @@ public class TThrowable extends RuntimeException {
} }
@Rename("fakeInit") @Rename("fakeInit")
public TThrowable(@SuppressWarnings("unused") TString message) { public TThrowable(@SuppressWarnings("unused") String message) {
} }
@Rename("<init>") @Rename("<init>")
private void init(TString message) { private void init(String message) {
this.suppressionEnabled = true; this.suppressionEnabled = true;
this.writableStackTrace = true; this.writableStackTrace = true;
fillInStackTrace(); fillInStackTrace();
@ -75,11 +75,11 @@ public class TThrowable extends RuntimeException {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Rename("fakeInit") @Rename("fakeInit")
public TThrowable(TString message, TThrowable cause) { public TThrowable(String message, TThrowable cause) {
} }
@Rename("<init>") @Rename("<init>")
private void init(TString message, TThrowable cause) { private void init(String message, TThrowable cause) {
this.suppressionEnabled = true; this.suppressionEnabled = true;
this.writableStackTrace = true; this.writableStackTrace = true;
fillInStackTrace(); fillInStackTrace();
@ -114,13 +114,13 @@ public class TThrowable extends RuntimeException {
} }
@Rename("getMessage") @Rename("getMessage")
public TString getMessage0() { public String getMessage0() {
return message; return message;
} }
@Rename("getLocalizedMessage") @Rename("getLocalizedMessage")
public TString getLocalizedMessage0() { public String getLocalizedMessage0() {
return TString.wrap(getMessage()); return getMessage();
} }
@Remove @Remove
@ -132,17 +132,17 @@ public class TThrowable extends RuntimeException {
} }
@Remove @Remove
public native TClass<?> getClass0(); public native Class<?> getClass0();
@Remove @Remove
public native TString toString0(); public native String toString0();
public TThrowable initCause(TThrowable cause) { public TThrowable initCause(TThrowable cause) {
if (this.cause != this && this.cause != null) { if (this.cause != this && this.cause != null) {
throw new TIllegalStateException(TString.wrap("Cause already set")); throw new IllegalStateException("Cause already set");
} }
if (cause == this) { if (cause == this) {
throw new TIllegalArgumentException(TString.wrap("Circular causation relation")); throw new IllegalArgumentException("Circular causation relation");
} }
this.cause = cause; this.cause = cause;
return this; return this;
@ -150,38 +150,38 @@ public class TThrowable extends RuntimeException {
@Override @Override
public void printStackTrace() { public void printStackTrace() {
printStackTrace(TSystem.err()); printStackTrace(System.err);
} }
public void printStackTrace(TPrintStream stream) { public void printStackTrace(PrintStream stream) {
stream.print(TString.wrap(getClass().getName())); stream.print(getClass().getName());
String message = getMessage(); String message = getMessage();
if (message != null) { if (message != null) {
stream.print(TString.wrap(": " + getMessage())); stream.print(": " + getMessage());
} }
stream.println(); stream.println();
if (stackTrace != null) { if (stackTrace != null) {
for (TStackTraceElement element : stackTrace) { for (TStackTraceElement element : stackTrace) {
stream.print(TString.wrap(" at ")); stream.print(" at ");
stream.println(element); stream.println(element);
} }
} }
if (cause != null && cause != this) { if (cause != null && cause != this) {
stream.print(TString.wrap("Caused by: ")); stream.print("Caused by: ");
cause.printStackTrace(stream); cause.printStackTrace(stream);
} }
} }
public void printStackTrace(TPrintWriter stream) { public void printStackTrace(PrintWriter stream) {
stream.println(TString.wrap(getClass().getName() + ": " + getMessage())); stream.println(getClass().getName() + ": " + getMessage());
if (stackTrace != null) { if (stackTrace != null) {
for (TStackTraceElement element : stackTrace) { for (TStackTraceElement element : stackTrace) {
stream.print(TString.wrap(" at ")); stream.print(" at ");
stream.println(element); stream.println(element);
} }
} }
if (cause != null && cause != this) { if (cause != null && cause != this) {
stream.print(TString.wrap("Caused by: ")); stream.print("Caused by: ");
cause.printStackTrace(stream); cause.printStackTrace(stream);
} }
} }

View File

@ -22,11 +22,11 @@ public class TUnsupportedOperationException extends TRuntimeException {
super(); super();
} }
public TUnsupportedOperationException(TString message, TThrowable cause) { public TUnsupportedOperationException(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TUnsupportedOperationException(TString message) { public TUnsupportedOperationException(String message) {
super(message); super(message);
} }

View File

@ -22,7 +22,7 @@ public class TVirtualMachineError extends TError {
super(); super();
} }
public TVirtualMachineError(TString message) { public TVirtualMachineError(String message) {
super(message); super(message);
} }
@ -30,7 +30,7 @@ public class TVirtualMachineError extends TError {
super(cause); super(cause);
} }
public TVirtualMachineError(TString message, TThrowable cause) { public TVirtualMachineError(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
} }

View File

@ -32,7 +32,7 @@ public interface TAnnotatedElement {
TAnnotation[] getDeclaredAnnotations(); TAnnotation[] getDeclaredAnnotations();
default <T extends TAnnotation> T[] getAnnotationsByType(TClass<T> annotationClass) { default <T extends TAnnotation> T[] getAnnotationsByType(Class<T> annotationClass) {
List<T> result = new ArrayList<>(); List<T> result = new ArrayList<>();
Object classAsObject = annotationClass; Object classAsObject = annotationClass;
for (TAnnotation annot : getAnnotations()) { for (TAnnotation annot : getAnnotations()) {
@ -55,7 +55,7 @@ public interface TAnnotatedElement {
return null; return null;
} }
default <T extends TAnnotation> T[] getDeclaredAnnotationsByType(TClass<T> annotationClass) { default <T extends TAnnotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
List<T> result = new ArrayList<>(); List<T> result = new ArrayList<>();
Object classAsObject = annotationClass; Object classAsObject = annotationClass;
for (TAnnotation annot : getDeclaredAnnotations()) { for (TAnnotation annot : getDeclaredAnnotations()) {

View File

@ -48,17 +48,17 @@ public final class TArray extends TObject {
} }
@PluggableDependency(ArrayNativeGenerator.class) @PluggableDependency(ArrayNativeGenerator.class)
public static TObject newInstance(TClass<?> componentType, int length) throws TNegativeArraySizeException { public static TObject newInstance(Class<?> componentType, int length) throws TNegativeArraySizeException {
if (componentType == null) { if (componentType == null) {
throw new TNullPointerException(); throw new TNullPointerException();
} }
if (componentType == TClass.wrap(void.class)) { if (componentType == void.class) {
throw new TIllegalArgumentException(); throw new TIllegalArgumentException();
} }
if (length < 0) { if (length < 0) {
throw new TNegativeArraySizeException(); throw new TNegativeArraySizeException();
} }
return newInstanceImpl(componentType.getPlatformClass(), length); return newInstanceImpl(((TClass<?>) (Object) componentType).getPlatformClass(), length);
} }
@GeneratedBy(ArrayNativeGenerator.class) @GeneratedBy(ArrayNativeGenerator.class)

View File

@ -16,7 +16,6 @@
package org.teavm.classlib.java.lang.reflect; package org.teavm.classlib.java.lang.reflect;
import org.teavm.classlib.java.lang.TReflectiveOperationException; import org.teavm.classlib.java.lang.TReflectiveOperationException;
import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.lang.TThrowable; import org.teavm.classlib.java.lang.TThrowable;
public class TInvocationTargetException extends TReflectiveOperationException { public class TInvocationTargetException extends TReflectiveOperationException {
@ -27,7 +26,7 @@ public class TInvocationTargetException extends TReflectiveOperationException {
super(null, target); super(null, target);
} }
public TInvocationTargetException(TThrowable target, TString s) { public TInvocationTargetException(TThrowable target, String s) {
super(s, target); super(s, target);
} }

File diff suppressed because it is too large Load Diff

View File

@ -21,44 +21,24 @@ import org.teavm.classlib.java.lang.TIllegalArgumentException;
import org.teavm.classlib.java.lang.TString; import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.lang.TStringBuilder; import org.teavm.classlib.java.lang.TStringBuilder;
/**
* This class is used to encode a string using the format required by {@code
* application/x-www-form-urlencoded} MIME content type. It contains helper
* methods used by the URI class, and performs encoding and decoding in a
* slightly different way than {@code URLEncoder} and {@code URLDecoder}.
*/
class TURIEncoderDecoder { class TURIEncoderDecoder {
static final TString digits = TString.wrap("0123456789ABCDEF"); static final String digits = "0123456789ABCDEF";
private TURIEncoderDecoder() { private TURIEncoderDecoder() {
} }
/** static void validate(String s, String legal) throws TURISyntaxException {
* Validate a string by checking if it contains any characters other than:
* 1. letters ('a'..'z', 'A'..'Z') 2. numbers ('0'..'9') 3. characters in
* the legalset parameter 4. others (unicode characters that are not in
* US-ASCII set, and are not ISO Control or are not ISO Space characters)
* <p>
* called from {@code URI.Helper.parseURI()} to validate each component
*
* @param s
* {@code java.lang.String} the string to be validated
* @param legal
* {@code java.lang.String} the characters allowed in the String
* s
*/
static void validate(TString s, TString legal) throws TURISyntaxException {
for (int i = 0; i < s.length();) { for (int i = 0; i < s.length();) {
char ch = s.charAt(i); char ch = s.charAt(i);
if (ch == '%') { if (ch == '%') {
do { do {
if (i + 2 >= s.length()) { if (i + 2 >= s.length()) {
throw new TURISyntaxException(s, TString.wrap(""), i); throw new TURISyntaxException(s, "", i);
} }
int d1 = TCharacter.digit(s.charAt(i + 1), 16); int d1 = TCharacter.digit(s.charAt(i + 1), 16);
int d2 = TCharacter.digit(s.charAt(i + 2), 16); int d2 = TCharacter.digit(s.charAt(i + 2), 16);
if (d1 == -1 || d2 == -1) { if (d1 == -1 || d2 == -1) {
throw new TURISyntaxException(s, TString.wrap(""), i); throw new TURISyntaxException(s, "", i);
} }
i += 3; i += 3;
@ -69,7 +49,7 @@ class TURIEncoderDecoder {
if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')
|| (ch >= '0' && ch <= '9') || legal.indexOf(ch) > -1 || (ch > 127 || (ch >= '0' && ch <= '9') || legal.indexOf(ch) > -1 || (ch > 127
&& !isSpaceChar(ch) && !TCharacter.isISOControl(ch)))) { && !isSpaceChar(ch) && !TCharacter.isISOControl(ch)))) {
throw new TURISyntaxException(s, TString.wrap(""), i); //$NON-NLS-1$ throw new TURISyntaxException(s, "", i);
} }
i++; i++;
} }
@ -85,38 +65,19 @@ class TURIEncoderDecoder {
} }
} }
static void validateSimple(TString s, TString legal) static void validateSimple(String s, String legal)
throws TURISyntaxException { throws TURISyntaxException {
for (int i = 0; i < s.length();) { for (int i = 0; i < s.length();) {
char ch = s.charAt(i); char ch = s.charAt(i);
if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')
|| (ch >= '0' && ch <= '9') || legal.indexOf(ch) > -1)) { || (ch >= '0' && ch <= '9') || legal.indexOf(ch) > -1)) {
throw new TURISyntaxException(s, TString.wrap(""), i); //$NON-NLS-1$ throw new TURISyntaxException(s, "", i);
} }
i++; i++;
} }
} }
/** static String quoteIllegal(String s, String legal) {
* All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9')
* and legal characters are converted into their hexidecimal value prepended
* by '%'.
* <p>
* For example: '#' -> %23
* Other characters, which are unicode chars that are not US-ASCII, and are
* not ISO Control or are not ISO Space chars, are preserved.
* <p>
* Called from {@code URI.quoteComponent()} (for multiple argument
* constructors)
*
* @param s
* java.lang.String the string to be converted
* @param legal
* java.lang.String the characters allowed to be preserved in the
* string s
* @return java.lang.String the converted string
*/
static TString quoteIllegal(TString s, TString legal) {
TStringBuilder buf = new TStringBuilder(); TStringBuilder buf = new TStringBuilder();
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i); char ch = s.charAt(i);
@ -135,23 +96,10 @@ class TURIEncoderDecoder {
} }
} }
} }
return TString.wrap(buf.toString()); return buf.toString();
} }
/** static String encodeOthers(String s) {
* Other characters, which are Unicode chars that are not US-ASCII, and are
* not ISO Control or are not ISO Space chars are not preserved. They are
* converted into their hexidecimal value prepended by '%'.
* <p>
* For example: Euro currency symbol -> "%E2%82%AC".
* <p>
* Called from URI.toASCIIString()
*
* @param s
* java.lang.String the string to be converted
* @return java.lang.String the converted string
*/
static TString encodeOthers(TString s) {
TStringBuilder buf = new TStringBuilder(); TStringBuilder buf = new TStringBuilder();
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i); char ch = s.charAt(i);
@ -166,27 +114,10 @@ class TURIEncoderDecoder {
} }
} }
} }
return TString.wrap(buf.toString()); return buf.toString();
} }
/** static String decode(String s) {
* Decodes the string argument which is assumed to be encoded in the {@code
* x-www-form-urlencoded} MIME content type using the UTF-8 encoding scheme.
* <p>
*'%' and two following hex digit characters are converted to the
* equivalent byte value. All other characters are passed through
* unmodified.
* <p>
* e.g. "A%20B%20C %24%25" -> "A B C $%"
* <p>
* Called from URI.getXYZ() methods
*
* @param s
* java.lang.String The encoded string.
* @return java.lang.String The decoded version.
*/
static TString decode(TString s) {
TStringBuilder result = new TStringBuilder(); TStringBuilder result = new TStringBuilder();
TByteArrayOutputStream out = new TByteArrayOutputStream(); TByteArrayOutputStream out = new TByteArrayOutputStream();
for (int i = 0; i < s.length();) { for (int i = 0; i < s.length();) {
@ -205,13 +136,13 @@ class TURIEncoderDecoder {
out.write((byte) ((d1 << 4) + d2)); out.write((byte) ((d1 << 4) + d2));
i += 3; i += 3;
} while (i < s.length() && s.charAt(i) == '%'); } while (i < s.length() && s.charAt(i) == '%');
result.append(TString.wrap(out.toString())); result.append(out.toString());
continue; continue;
} }
result.append(c); result.append(c);
i++; i++;
} }
return TString.wrap(result.toString()); return result.toString();
} }
} }

View File

@ -18,39 +18,13 @@ package org.teavm.classlib.java.net;
import org.teavm.classlib.java.lang.TException; import org.teavm.classlib.java.lang.TException;
import org.teavm.classlib.java.lang.TIllegalArgumentException; import org.teavm.classlib.java.lang.TIllegalArgumentException;
import org.teavm.classlib.java.lang.TNullPointerException; import org.teavm.classlib.java.lang.TNullPointerException;
import org.teavm.classlib.java.lang.TString;
import org.teavm.interop.Rename; import org.teavm.interop.Rename;
/**
* A {@code URISyntaxException} will be thrown if some information could not be parsed
* while creating a URI.
*/
public class TURISyntaxException extends TException { public class TURISyntaxException extends TException {
private String input;
private static final long serialVersionUID = 2137979680897488891L;
private TString input;
private int index; private int index;
/** public TURISyntaxException(String input, String reason, int index) {
* Constructs a new {@code URISyntaxException} instance containing the
* string that caused the exception, a description of the problem and the
* index at which the error occurred.
*
* @param input
* the string that caused the exception.
* @param reason
* the reason why the exception occurred.
* @param index
* the position where the exception occurred.
* @throws NullPointerException
* if one of the arguments {@code input} or {@code reason} is
* {@code null}.
* @throws IllegalArgumentException
* if the value for {@code index} is lesser than {@code -1}.
*/
public TURISyntaxException(TString input, TString reason, int index) {
super(reason); super(reason);
if (input == null || reason == null) { if (input == null || reason == null) {
@ -65,19 +39,7 @@ public class TURISyntaxException extends TException {
this.index = index; this.index = index;
} }
/** public TURISyntaxException(String input, String reason) {
* Constructs a new {@code URISyntaxException} instance containing the
* string that caused the exception and a description of the problem.
*
*@param input
* the string that caused the exception.
* @param reason
* the reason why the exception occurred.
* @throws NullPointerException
* if one of the arguments {@code input} or {@code reason} is
* {@code null}.
*/
public TURISyntaxException(TString input, TString reason) {
super(reason); super(reason);
if (input == null || reason == null) { if (input == null || reason == null) {
@ -88,45 +50,21 @@ public class TURISyntaxException extends TException {
index = -1; index = -1;
} }
/**
* Gets the index at which the syntax error was found or {@code -1} if the
* index is unknown/unavailable.
*
* @return the index of the syntax error.
*/
public int getIndex() { public int getIndex() {
return index; return index;
} }
/** public String getReason() {
* Gets a description of the syntax error. return super.getMessage();
*
* @return the string describing the syntax error.
*/
public TString getReason() {
return TString.wrap(super.getMessage());
} }
/** public String getInput() {
* Gets the initial string that contains an invalid syntax.
*
* @return the string that caused the exception.
*/
public TString getInput() {
return input; return input;
} }
/**
* Gets a description of the exception, including the reason, the string
* that caused the syntax error and the position of the syntax error if
* available.
*
* @return a sting containing information about the exception.
* @see java.lang.Throwable#getMessage()
*/
@Override @Override
@Rename("getMessage") @Rename("getMessage")
public TString getMessage0() { public String getMessage0() {
return TString.wrap(""); return "";
} }
} }

View File

@ -22,7 +22,6 @@ import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.net.impl.TDummyStreamHandler; import org.teavm.classlib.java.net.impl.TDummyStreamHandler;
import org.teavm.classlib.java.net.impl.TXHRStreamHandler; import org.teavm.classlib.java.net.impl.TXHRStreamHandler;
@ -316,7 +315,7 @@ public final class TURL implements Serializable {
} }
public TURI toURI() throws TURISyntaxException { public TURI toURI() throws TURISyntaxException {
return new TURI((TString) (Object) toExternalForm()); return new TURI(toExternalForm());
} }
@Override @Override

View File

@ -16,18 +16,17 @@
package org.teavm.classlib.java.security; package org.teavm.classlib.java.security;
import org.teavm.classlib.java.lang.TSecurityException; import org.teavm.classlib.java.lang.TSecurityException;
import org.teavm.classlib.java.lang.TString;
public class TAccessControlException extends TSecurityException { public class TAccessControlException extends TSecurityException {
private static final long serialVersionUID = 8282514874369266797L; private static final long serialVersionUID = 8282514874369266797L;
private TPermission permission; private TPermission permission;
public TAccessControlException(TString message) { public TAccessControlException(String message) {
super(message); super(message);
} }
public TAccessControlException(String s, TPermission permission) { public TAccessControlException(String s, TPermission permission) {
super((TString) (Object) s); super(s);
this.permission = permission; this.permission = permission;
} }

View File

@ -19,11 +19,9 @@ import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.util.Arrays; import java.util.Arrays;
import org.teavm.classlib.impl.unicode.CLDRHelper; import org.teavm.classlib.impl.unicode.CLDRHelper;
import org.teavm.classlib.java.lang.TArithmeticException; import org.teavm.classlib.java.lang.TArithmeticException;
import org.teavm.classlib.java.lang.TDouble; import org.teavm.classlib.java.lang.TDouble;
import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.util.TLocale; import org.teavm.classlib.java.util.TLocale;
public class TDecimalFormat extends TNumberFormat { public class TDecimalFormat extends TNumberFormat {
@ -984,7 +982,7 @@ public class TDecimalFormat extends TNumberFormat {
break; break;
case UNNECESSARY: case UNNECESSARY:
if (mantissa % rounding != 0) { if (mantissa % rounding != 0) {
throw new TArithmeticException(TString.wrap("Can't avoid rounding")); throw new TArithmeticException("Can't avoid rounding");
} }
break; break;
case HALF_DOWN: case HALF_DOWN:
@ -1040,7 +1038,7 @@ public class TDecimalFormat extends TNumberFormat {
break; break;
case UNNECESSARY: case UNNECESSARY:
if (mantissa.remainder(rounding).equals(BigInteger.ZERO)) { if (mantissa.remainder(rounding).equals(BigInteger.ZERO)) {
throw new TArithmeticException(TString.wrap("Can't avoid rounding")); throw new TArithmeticException("Can't avoid rounding");
} }
break; break;
case HALF_DOWN: case HALF_DOWN:

View File

@ -22,7 +22,6 @@ import java.util.function.IntFunction;
import java.util.function.IntToDoubleFunction; import java.util.function.IntToDoubleFunction;
import java.util.function.IntToLongFunction; import java.util.function.IntToLongFunction;
import java.util.function.IntUnaryOperator; import java.util.function.IntUnaryOperator;
import org.teavm.classlib.java.lang.TClass;
import org.teavm.classlib.java.lang.TComparable; import org.teavm.classlib.java.lang.TComparable;
import org.teavm.classlib.java.lang.TDouble; import org.teavm.classlib.java.lang.TDouble;
import org.teavm.classlib.java.lang.TFloat; import org.teavm.classlib.java.lang.TFloat;
@ -30,9 +29,7 @@ import org.teavm.classlib.java.lang.TIllegalArgumentException;
import org.teavm.classlib.java.lang.TInteger; import org.teavm.classlib.java.lang.TInteger;
import org.teavm.classlib.java.lang.TMath; import org.teavm.classlib.java.lang.TMath;
import org.teavm.classlib.java.lang.TObject; import org.teavm.classlib.java.lang.TObject;
import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.lang.TStringBuilder; import org.teavm.classlib.java.lang.TStringBuilder;
import org.teavm.classlib.java.lang.reflect.TArray;
import org.teavm.classlib.java.util.stream.TDoubleStream; import org.teavm.classlib.java.util.stream.TDoubleStream;
import org.teavm.classlib.java.util.stream.TIntStream; import org.teavm.classlib.java.util.stream.TIntStream;
import org.teavm.classlib.java.util.stream.TLongStream; import org.teavm.classlib.java.util.stream.TLongStream;
@ -126,12 +123,12 @@ public class TArrays extends TObject {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T, U> T[] copyOf(U[] original, int newLength, TClass<? extends T[]> cls) { public static <T, U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> cls) {
TClass<?> componentType = cls.getComponentType(); Class<?> componentType = cls.getComponentType();
T[] result = (T[]) (Object) TArray.newInstance(componentType, newLength); T[] result = (T[]) Array.newInstance(componentType, newLength);
int sz = TMath.min(newLength, original.length); int sz = TMath.min(newLength, original.length);
for (int i = 0; i < sz; ++i) { for (int i = 0; i < sz; ++i) {
result[i] = (T) componentType.cast(TObject.wrap(original[i])); result[i] = (T) componentType.cast(original[i]);
} }
return result; return result;
} }
@ -210,130 +207,130 @@ public class TArrays extends TObject {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T, U> T[] copyOfRange(U[] original, int from, int to, TClass<? extends T[]> newType) { public static <T, U> T[] copyOfRange(U[] original, int from, int to, Class<? extends T[]> newType) {
TClass<?> componentType = newType.getComponentType(); Class<?> componentType = newType.getComponentType();
T[] result = (T[]) (Object) TArray.newInstance(componentType, to - from); T[] result = (T[]) (Object) Array.newInstance(componentType, to - from);
for (int i = from; i < to; ++i) { for (int i = from; i < to; ++i) {
result[i - from] = (T) newType.getComponentType().cast(TObject.wrap(original[i])); result[i - from] = (T) newType.getComponentType().cast(original[i]);
} }
return result; return result;
} }
public static TString toString(TObject[] a) { public static String toString(TObject[] a) {
TStringBuilder sb = new TStringBuilder(); TStringBuilder sb = new TStringBuilder();
sb.append(TString.wrap("[")); sb.append("[");
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
if (i > 0) { if (i > 0) {
sb.append(TString.wrap(", ")); sb.append(", ");
} }
sb.append(a[i]); sb.append(a[i]);
} }
sb.append(TString.wrap("]")); sb.append("]");
return TString.wrap(sb.toString()); return sb.toString();
} }
public static TString toString(boolean[] a) { public static String toString(boolean[] a) {
TStringBuilder sb = new TStringBuilder(); TStringBuilder sb = new TStringBuilder();
sb.append(TString.wrap("[")); sb.append("[");
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
if (i > 0) { if (i > 0) {
sb.append(TString.wrap(", ")); sb.append(", ");
} }
sb.append(a[i]); sb.append(a[i]);
} }
sb.append(TString.wrap("]")); sb.append("]");
return TString.wrap(sb.toString()); return sb.toString();
} }
public static TString toString(byte[] a) { public static String toString(byte[] a) {
TStringBuilder sb = new TStringBuilder(); TStringBuilder sb = new TStringBuilder();
sb.append(TString.wrap("[")); sb.append("[");
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
if (i > 0) { if (i > 0) {
sb.append(TString.wrap(", ")); sb.append(", ");
} }
sb.append(a[i]); sb.append(a[i]);
} }
sb.append(TString.wrap("]")); sb.append("]");
return TString.wrap(sb.toString()); return sb.toString();
} }
public static TString toString(short[] a) { public static String toString(short[] a) {
TStringBuilder sb = new TStringBuilder(); TStringBuilder sb = new TStringBuilder();
sb.append(TString.wrap("[")); sb.append("[");
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
if (i > 0) { if (i > 0) {
sb.append(TString.wrap(", ")); sb.append(", ");
} }
sb.append(a[i]); sb.append(a[i]);
} }
sb.append(TString.wrap("]")); sb.append("]");
return TString.wrap(sb.toString()); return sb.toString();
} }
public static TString toString(char[] a) { public static String toString(char[] a) {
TStringBuilder sb = new TStringBuilder(); TStringBuilder sb = new TStringBuilder();
sb.append(TString.wrap("[")); sb.append("[");
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
if (i > 0) { if (i > 0) {
sb.append(TString.wrap(", ")); sb.append(", ");
} }
sb.append(a[i]); sb.append(a[i]);
} }
sb.append(TString.wrap("]")); sb.append("]");
return TString.wrap(sb.toString()); return sb.toString();
} }
public static TString toString(int[] a) { public static String toString(int[] a) {
TStringBuilder sb = new TStringBuilder(); TStringBuilder sb = new TStringBuilder();
sb.append(TString.wrap("[")); sb.append("[");
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
if (i > 0) { if (i > 0) {
sb.append(TString.wrap(", ")); sb.append(", ");
} }
sb.append(a[i]); sb.append(a[i]);
} }
sb.append(TString.wrap("]")); sb.append("]");
return TString.wrap(sb.toString()); return sb.toString();
} }
public static TString toString(long[] a) { public static String toString(long[] a) {
TStringBuilder sb = new TStringBuilder(); TStringBuilder sb = new TStringBuilder();
sb.append(TString.wrap("[")); sb.append("[");
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
if (i > 0) { if (i > 0) {
sb.append(TString.wrap(", ")); sb.append(", ");
} }
sb.append(a[i]); sb.append(a[i]);
} }
sb.append(TString.wrap("]")); sb.append("]");
return TString.wrap(sb.toString()); return sb.toString();
} }
public static TString toString(float[] a) { public static String toString(float[] a) {
TStringBuilder sb = new TStringBuilder(); TStringBuilder sb = new TStringBuilder();
sb.append(TString.wrap("[")); sb.append("[");
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
if (i > 0) { if (i > 0) {
sb.append(TString.wrap(", ")); sb.append(", ");
} }
sb.append(a[i]); sb.append(a[i]);
} }
sb.append(TString.wrap("]")); sb.append("]");
return TString.wrap(sb.toString()); return sb.toString();
} }
public static TString toString(double[] a) { public static String toString(double[] a) {
TStringBuilder sb = new TStringBuilder(); TStringBuilder sb = new TStringBuilder();
sb.append(TString.wrap("[")); sb.append("[");
for (int i = 0; i < a.length; ++i) { for (int i = 0; i < a.length; ++i) {
if (i > 0) { if (i > 0) {
sb.append(TString.wrap(", ")); sb.append(", ");
} }
sb.append(a[i]); sb.append(a[i]);
} }
sb.append(TString.wrap("]")); sb.append("]");
return TString.wrap(sb.toString()); return sb.toString();
} }
public static void fill(long[] a, int fromIndex, int toIndex, long val) { public static void fill(long[] a, int fromIndex, int toIndex, long val) {
@ -1529,22 +1526,22 @@ public class TArrays extends TObject {
} }
} }
public static TString deepToString(Object[] a) { public static String deepToString(Object[] a) {
TStringBuilder sb = new TStringBuilder(); StringBuilder sb = new StringBuilder();
deepToString(a, sb, new TArrayList<>()); deepToString(a, sb, new TArrayList<>());
return TString.wrap(sb.toString()); return sb.toString();
} }
private static void deepToString(Object[] a, TStringBuilder out, TList<Object[]> visited) { private static void deepToString(Object[] a, StringBuilder out, TList<Object[]> visited) {
out.append('['); out.append('[');
if (visited.contains(a)) { if (visited.contains(a)) {
out.append(TString.wrap("...")); out.append("...");
} else { } else {
visited.add(a); visited.add(a);
if (a.length > 0) { if (a.length > 0) {
deepToString(a[0], out, visited); deepToString(a[0], out, visited);
for (int i = 1; i < a.length; ++i) { for (int i = 1; i < a.length; ++i) {
out.append(TString.wrap(", ")); out.append(", ");
deepToString(a[i], out, visited); deepToString(a[i], out, visited);
} }
} }
@ -1553,11 +1550,11 @@ public class TArrays extends TObject {
out.append(']'); out.append(']');
} }
private static void deepToString(Object a, TStringBuilder out, TList<Object[]> visited) { private static void deepToString(Object a, StringBuilder out, TList<Object[]> visited) {
if (a instanceof Object[]) { if (a instanceof Object[]) {
deepToString((Object[]) a, out, visited); deepToString((Object[]) a, out, visited);
} else { } else {
out.append(TObject.wrap(a)); out.append(a);
} }
} }

View File

@ -15,14 +15,11 @@
*/ */
package org.teavm.classlib.java.util; package org.teavm.classlib.java.util;
import org.teavm.classlib.java.lang.TClass;
import org.teavm.classlib.java.lang.TObject;
class TCheckedCollection<E> implements TCollection<E> { class TCheckedCollection<E> implements TCollection<E> {
TCollection<E> innerCollection; TCollection<E> innerCollection;
TClass<E> type; Class<E> type;
public TCheckedCollection(TCollection<E> innerCollection, TClass<E> type) { public TCheckedCollection(TCollection<E> innerCollection, Class<E> type) {
this.innerCollection = innerCollection; this.innerCollection = innerCollection;
this.type = type; this.type = type;
} }
@ -59,7 +56,7 @@ class TCheckedCollection<E> implements TCollection<E> {
@Override @Override
public boolean add(E e) { public boolean add(E e) {
return innerCollection.add(type.cast(TObject.wrap(e))); return innerCollection.add(type.cast(e));
} }
@Override @Override
@ -77,7 +74,7 @@ class TCheckedCollection<E> implements TCollection<E> {
public boolean addAll(TCollection<? extends E> c) { public boolean addAll(TCollection<? extends E> c) {
Object[] items = c.toArray(); Object[] items = c.toArray();
for (int i = 0; i < items.length; ++i) { for (int i = 0; i < items.length; ++i) {
items[i] = type.cast(TObject.wrap(items[i])); items[i] = type.cast(items[i]);
} }
return innerCollection.addAll(TArrays.asList((E[]) items)); return innerCollection.addAll(TArrays.asList((E[]) items));
} }

View File

@ -15,13 +15,10 @@
*/ */
package org.teavm.classlib.java.util; package org.teavm.classlib.java.util;
import org.teavm.classlib.java.lang.TClass;
import org.teavm.classlib.java.lang.TObject;
class TCheckedList<E> extends TCheckedCollection<E> implements TList<E> { class TCheckedList<E> extends TCheckedCollection<E> implements TList<E> {
private TList<E> innerList; private TList<E> innerList;
public TCheckedList(TList<E> innerList, TClass<E> type) { public TCheckedList(TList<E> innerList, Class<E> type) {
super(innerList, type); super(innerList, type);
this.innerList = innerList; this.innerList = innerList;
} }
@ -31,7 +28,7 @@ class TCheckedList<E> extends TCheckedCollection<E> implements TList<E> {
public boolean addAll(int index, TCollection<? extends E> c) { public boolean addAll(int index, TCollection<? extends E> c) {
Object[] items = c.toArray(); Object[] items = c.toArray();
for (int i = 0; i < items.length; ++i) { for (int i = 0; i < items.length; ++i) {
items[i] = type.cast(TObject.wrap(items[i])); items[i] = type.cast(items[i]);
} }
return innerList.addAll(index, TArrays.asList((E[]) items)); return innerList.addAll(index, TArrays.asList((E[]) items));
} }
@ -43,12 +40,12 @@ class TCheckedList<E> extends TCheckedCollection<E> implements TList<E> {
@Override @Override
public E set(int index, E element) { public E set(int index, E element) {
return innerList.set(index, type.cast(TObject.wrap(element))); return innerList.set(index, type.cast(element));
} }
@Override @Override
public void add(int index, E element) { public void add(int index, E element) {
innerList.add(index, type.cast(TObject.wrap(element))); innerList.add(index, type.cast(element));
} }
@Override @Override

View File

@ -15,14 +15,11 @@
*/ */
package org.teavm.classlib.java.util; package org.teavm.classlib.java.util;
import org.teavm.classlib.java.lang.TClass;
import org.teavm.classlib.java.lang.TObject;
class TCheckedListIterator<E> implements TListIterator<E> { class TCheckedListIterator<E> implements TListIterator<E> {
private TListIterator<E> innerIterator; private TListIterator<E> innerIterator;
private TClass<E> type; private Class<E> type;
public TCheckedListIterator(TListIterator<E> innerIterator, TClass<E> type) { TCheckedListIterator(TListIterator<E> innerIterator, Class<E> type) {
this.innerIterator = innerIterator; this.innerIterator = innerIterator;
this.type = type; this.type = type;
} }
@ -64,11 +61,11 @@ class TCheckedListIterator<E> implements TListIterator<E> {
@Override @Override
public void set(E e) { public void set(E e) {
innerIterator.set(type.cast(TObject.wrap(e))); innerIterator.set(type.cast(e));
} }
@Override @Override
public void add(E e) { public void add(E e) {
innerIterator.add(type.cast(TObject.wrap(e))); innerIterator.add(type.cast(e));
} }
} }

View File

@ -15,15 +15,12 @@
*/ */
package org.teavm.classlib.java.util; package org.teavm.classlib.java.util;
import org.teavm.classlib.java.lang.TClass;
import org.teavm.classlib.java.lang.TObject;
class TCheckedMap<K, V> implements TMap<K, V> { class TCheckedMap<K, V> implements TMap<K, V> {
private TMap<K, V> innerMap; private TMap<K, V> innerMap;
private TClass<K> keyType; private Class<K> keyType;
private TClass<V> valueType; private Class<V> valueType;
public TCheckedMap(TMap<K, V> innerMap, TClass<K> keyType, TClass<V> valueType) { public TCheckedMap(TMap<K, V> innerMap, Class<K> keyType, Class<V> valueType) {
this.innerMap = innerMap; this.innerMap = innerMap;
this.keyType = keyType; this.keyType = keyType;
this.valueType = valueType; this.valueType = valueType;
@ -56,7 +53,7 @@ class TCheckedMap<K, V> implements TMap<K, V> {
@Override @Override
public V put(K key, V value) { public V put(K key, V value) {
return innerMap.put(keyType.cast(TObject.wrap(key)), valueType.cast(TObject.wrap(value))); return innerMap.put(keyType.cast(key), valueType.cast(value));
} }
@Override @Override
@ -69,8 +66,8 @@ class TCheckedMap<K, V> implements TMap<K, V> {
m = new THashMap<>(m); m = new THashMap<>(m);
for (TIterator<? extends Entry<? extends K, ? extends V>> iter = m.entrySet().iterator(); iter.hasNext();) { for (TIterator<? extends Entry<? extends K, ? extends V>> iter = m.entrySet().iterator(); iter.hasNext();) {
Entry<? extends K, ? extends V> entry = iter.next(); Entry<? extends K, ? extends V> entry = iter.next();
keyType.cast(TObject.wrap(entry.getKey())); keyType.cast(entry.getKey());
valueType.cast(TObject.wrap(entry.getValue())); valueType.cast(entry.getValue());
} }
innerMap.putAll(m); innerMap.putAll(m);
} }

View File

@ -15,10 +15,8 @@
*/ */
package org.teavm.classlib.java.util; package org.teavm.classlib.java.util;
import org.teavm.classlib.java.lang.TClass;
class TCheckedSet<E> extends TCheckedCollection<E> implements TSet<E> { class TCheckedSet<E> extends TCheckedCollection<E> implements TSet<E> {
public TCheckedSet(TCollection<E> innerCollection, TClass<E> type) { public TCheckedSet(TCollection<E> innerCollection, Class<E> type) {
super(innerCollection, type); super(innerCollection, type);
} }
} }

View File

@ -572,19 +572,19 @@ public class TCollections extends TObject {
return list; return list;
} }
public static <E> TCollection<E> checkedCollection(TCollection<E> c, TClass<E> type) { public static <E> TCollection<E> checkedCollection(TCollection<E> c, Class<E> type) {
return new TCheckedCollection<>(c, type); return new TCheckedCollection<>(c, type);
} }
public static <E> TSet<E> checkedSet(TSet<E> s, TClass<E> type) { public static <E> TSet<E> checkedSet(TSet<E> s, Class<E> type) {
return new TCheckedSet<>(s, type); return new TCheckedSet<>(s, type);
} }
public static <E> TList<E> checkedList(TList<E> list, TClass<E> type) { public static <E> TList<E> checkedList(TList<E> list, Class<E> type) {
return new TCheckedList<>(list, type); return new TCheckedList<>(list, type);
} }
public static <K, V> TMap<K, V> checkedMap(TMap<K, V> m, TClass<K> keyType, TClass<V> valueType) { public static <K, V> TMap<K, V> checkedMap(TMap<K, V> m, Class<K> keyType, Class<V> valueType) {
return new TCheckedMap<>(m, keyType, valueType); return new TCheckedMap<>(m, keyType, valueType);
} }

View File

@ -16,7 +16,6 @@
package org.teavm.classlib.java.util; package org.teavm.classlib.java.util;
import org.teavm.classlib.java.lang.TRuntimeException; import org.teavm.classlib.java.lang.TRuntimeException;
import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.lang.TThrowable; import org.teavm.classlib.java.lang.TThrowable;
public class TConcurrentModificationException extends TRuntimeException { public class TConcurrentModificationException extends TRuntimeException {
@ -26,11 +25,11 @@ public class TConcurrentModificationException extends TRuntimeException {
super(); super();
} }
public TConcurrentModificationException(TString message, TThrowable cause) { public TConcurrentModificationException(String message, TThrowable cause) {
super(message, cause); super(message, cause);
} }
public TConcurrentModificationException(TString message) { public TConcurrentModificationException(String message) {
super(message); super(message);
} }

View File

@ -16,7 +16,6 @@
package org.teavm.classlib.java.util; package org.teavm.classlib.java.util;
import org.teavm.classlib.java.lang.TRuntimeException; import org.teavm.classlib.java.lang.TRuntimeException;
import org.teavm.classlib.java.lang.TString;
public class TMissingResourceException extends TRuntimeException { public class TMissingResourceException extends TRuntimeException {
private static final long serialVersionUID = 6730397307327337970L; private static final long serialVersionUID = 6730397307327337970L;
@ -24,7 +23,7 @@ public class TMissingResourceException extends TRuntimeException {
private String key; private String key;
public TMissingResourceException(String s, String className, String key) { public TMissingResourceException(String s, String className, String key) {
super(TString.wrap(s)); super(s);
this.className = className; this.className = className;
this.key = key; this.key = key;
} }

View File

@ -16,7 +16,6 @@
package org.teavm.classlib.java.util; package org.teavm.classlib.java.util;
import org.teavm.classlib.java.lang.TRuntimeException; import org.teavm.classlib.java.lang.TRuntimeException;
import org.teavm.classlib.java.lang.TString;
public class TNoSuchElementException extends TRuntimeException { public class TNoSuchElementException extends TRuntimeException {
private static final long serialVersionUID = -4890604137042866919L; private static final long serialVersionUID = -4890604137042866919L;
@ -25,7 +24,7 @@ public class TNoSuchElementException extends TRuntimeException {
super(); super();
} }
public TNoSuchElementException(TString message) { public TNoSuchElementException(String message) {
super(message); super(message);
} }
} }

View File

@ -15,14 +15,13 @@
*/ */
package org.teavm.classlib.java.util; package org.teavm.classlib.java.util;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import org.teavm.classlib.java.io.TBufferedInputStream; import org.teavm.classlib.java.io.TBufferedInputStream;
import org.teavm.classlib.java.io.TIOException;
import org.teavm.classlib.java.io.TInputStream; import org.teavm.classlib.java.io.TInputStream;
import org.teavm.classlib.java.io.TOutputStream;
import org.teavm.classlib.java.io.TOutputStreamWriter;
import org.teavm.classlib.java.io.TPrintStream; import org.teavm.classlib.java.io.TPrintStream;
import org.teavm.classlib.java.io.TWriter;
import org.teavm.classlib.java.lang.TString;
public class TProperties extends THashtable<Object, Object> { public class TProperties extends THashtable<Object, Object> {
/** /**
@ -139,17 +138,17 @@ public class TProperties extends THashtable<Object, Object> {
} }
if (property.length() > 40) { if (property.length() > 40) {
buffer.append(property.substring(0, 37)); buffer.append(property.substring(0, 37));
buffer.append("..."); //$NON-NLS-1$ buffer.append("...");
} else { } else {
buffer.append(property); buffer.append(property);
} }
out.println(TString.wrap(buffer.toString())); out.println(buffer.toString());
buffer.setLength(0); buffer.setLength(0);
} }
} }
@SuppressWarnings("fallthrough") @SuppressWarnings("fallthrough")
public synchronized void load(TInputStream in) throws TIOException { public synchronized void load(TInputStream in) throws IOException {
if (in == null) { if (in == null) {
throw new NullPointerException(); throw new NullPointerException();
} }
@ -339,10 +338,10 @@ public class TProperties extends THashtable<Object, Object> {
} }
@Deprecated @Deprecated
public void save(TOutputStream out, String comment) { public void save(OutputStream out, String comment) {
try { try {
store(out, comment); store(out, comment);
} catch (TIOException e) { } catch (IOException e) {
// do nothing // do nothing
} }
} }
@ -351,8 +350,8 @@ public class TProperties extends THashtable<Object, Object> {
return put(name, value); return put(name, value);
} }
public synchronized void store(TOutputStream out, String comments) throws TIOException { public synchronized void store(OutputStream out, String comments) throws IOException {
TOutputStreamWriter writer = new TOutputStreamWriter(out, "ISO8859_1"); OutputStreamWriter writer = new OutputStreamWriter(out, "ISO8859_1");
if (comments != null) { if (comments != null) {
writeComments(writer, comments); writeComments(writer, comments);
} }
@ -374,7 +373,7 @@ public class TProperties extends THashtable<Object, Object> {
writer.flush(); writer.flush();
} }
private void writeComments(TWriter writer, String comments) throws TIOException { private void writeComments(Writer writer, String comments) throws IOException {
writer.write('#'); writer.write('#');
char[] chars = comments.toCharArray(); char[] chars = comments.toCharArray();
for (int index = 0; index < chars.length; index++) { for (int index = 0; index < chars.length; index++) {

Some files were not shown because too many files have changed in this diff Show More