diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedInputStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedInputStream.java index 7fefe7193..9cf821988 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedInputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedInputStream.java @@ -15,7 +15,7 @@ */ package org.teavm.classlib.java.io; -import org.teavm.classlib.java.lang.TString; +import java.io.IOException; public class TBufferedInputStream extends TFilterInputStream { protected volatile byte[] buf; @@ -38,16 +38,16 @@ public class TBufferedInputStream extends TFilterInputStream { } @Override - public int available() throws TIOException { + public int available() throws IOException { TInputStream localIn = in; if (buf == null || localIn == null) { - throw new TIOException(TString.wrap("Stream is closed")); + throw new IOException("Stream is closed"); } return count - pos + localIn.available(); } @Override - public void close() throws TIOException { + public void close() throws IOException { buf = null; TInputStream localIn = in; 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)) { /* Mark position not set or exceeded readlimit */ int result = localIn.read(localBuf); @@ -103,13 +103,13 @@ public class TBufferedInputStream extends TFilterInputStream { } @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 // unsynchronized close() byte[] localBuf = buf; TInputStream localIn = in; if (localBuf == null || localIn == null) { - throw new TIOException(TString.wrap("Stream is closed")); + throw new IOException("Stream is closed"); } /* Are there buffered bytes available? */ @@ -120,7 +120,7 @@ public class TBufferedInputStream extends TFilterInputStream { if (localBuf != buf) { localBuf = buf; 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 - 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; if (localBuf == null) { - throw new TIOException(TString.wrap("Stream is closed")); + throw new IOException("Stream is closed"); } // avoid int overflow if (offset > buffer.length - length || offset < 0 || length < 0) { @@ -146,7 +146,7 @@ public class TBufferedInputStream extends TFilterInputStream { } TInputStream localIn = in; if (localIn == null) { - throw new TIOException(TString.wrap("Stream is closed")); + throw new IOException("Stream is closed"); } int required; @@ -183,7 +183,7 @@ public class TBufferedInputStream extends TFilterInputStream { if (localBuf != buf) { localBuf = buf; 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 - public synchronized void reset() throws TIOException { + public synchronized void reset() throws IOException { if (buf == null) { - throw new TIOException(TString.wrap("Stream is closed")); + throw new IOException("Stream is closed"); } if (-1 == markpos) { - throw new TIOException(TString.wrap("Mark has been invalidated.")); + throw new IOException("Mark has been invalidated."); } pos = markpos; } @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 // unsynchronized close() byte[] localBuf = buf; TInputStream localIn = in; if (localBuf == null) { - throw new TIOException(TString.wrap("Stream is closed")); + throw new IOException("Stream is closed"); } if (amount < 1) { return 0; } if (localIn == null) { - throw new TIOException(TString.wrap("Stream is closed")); + throw new IOException("Stream is closed"); } if (count - pos >= amount) { diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedOutputStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedOutputStream.java index e46af5019..d9bac2ec4 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedOutputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedOutputStream.java @@ -16,6 +16,8 @@ package org.teavm.classlib.java.io; +import java.io.IOException; + public class TBufferedOutputStream extends TFilterOutputStream { protected byte[] buf; protected int count; @@ -34,13 +36,13 @@ public class TBufferedOutputStream extends TFilterOutputStream { } @Override - public void flush() throws TIOException { + public void flush() throws IOException { flushInternal(); out.flush(); } @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; if (internalBuffer != null && length >= internalBuffer.length) { @@ -62,7 +64,7 @@ public class TBufferedOutputStream extends TFilterOutputStream { } if (internalBuffer == null) { - throw new TIOException(); + throw new IOException(); } // flush the internal buffer first if we have not enough space left @@ -76,7 +78,7 @@ public class TBufferedOutputStream extends TFilterOutputStream { } @Override - public void close() throws TIOException { + public void close() throws IOException { if (buf == null) { return; } @@ -89,10 +91,10 @@ public class TBufferedOutputStream extends TFilterOutputStream { } @Override - public void write(int oneByte) throws TIOException { + public void write(int oneByte) throws IOException { byte[] internalBuffer = buf; if (internalBuffer == null) { - throw new TIOException(); + throw new IOException(); } if (count == internalBuffer.length) { @@ -102,7 +104,7 @@ public class TBufferedOutputStream extends TFilterOutputStream { internalBuffer[count++] = (byte) oneByte; } - private void flushInternal() throws TIOException { + private void flushInternal() throws IOException { if (count > 0) { out.write(buf, 0, count); count = 0; diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedReader.java b/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedReader.java index 869a536d4..3c10dc5d6 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedReader.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TBufferedReader.java @@ -15,9 +15,9 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TIllegalArgumentException; 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.util.TArrays; @@ -42,7 +42,7 @@ public class TBufferedReader extends TReader { } @Override - public int read() throws TIOException { + public int read() throws IOException { requireOpened(); if (index >= count) { if (!fillBuffer(0)) { @@ -53,14 +53,14 @@ public class TBufferedReader extends TReader { } @Override - public void close() throws TIOException { + public void close() throws IOException { requireOpened(); innerReader.close(); innerReader = null; } @Override - public int read(char[] cbuf, int off, int len) throws TIOException { + public int read(char[] cbuf, int off, int len) throws IOException { requireOpened(); if (index == count && eof) { return -1; @@ -79,7 +79,7 @@ public class TBufferedReader extends TReader { return charsRead; } - public TString readLine() throws TIOException { + public String readLine() throws IOException { requireOpened(); if (eof && index >= count) { return null; @@ -108,11 +108,11 @@ public class TBufferedReader extends TReader { line.append(ch); } } - return TString.wrap(line.toString()); + return line.toString(); } @Override - public long skip(long n) throws TIOException { + public long skip(long n) throws IOException { requireOpened(); if (n < count - index) { index += n; @@ -135,7 +135,7 @@ public class TBufferedReader extends TReader { } @Override - public void mark(int readAheadLimit) throws TIOException { + public void mark(int readAheadLimit) throws IOException { if (readAheadLimit > buffer.length) { buffer = TArrays.copyOf(buffer, readAheadLimit); } @@ -149,14 +149,14 @@ public class TBufferedReader extends TReader { } @Override - public void reset() throws TIOException { + public void reset() throws IOException { if (mark == -1) { - throw new TIOException(); + throw new IOException(); } index = mark; } - private boolean fillBuffer(int offset) throws TIOException { + private boolean fillBuffer(int offset) throws IOException { if (eof) { return false; } @@ -177,9 +177,9 @@ public class TBufferedReader extends TReader { return true; } - private void requireOpened() { + private void requireOpened() throws IOException { if (innerReader == null) { - throw new TIOException(); + throw new IOException(); } } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TByteArrayOutputStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TByteArrayOutputStream.java index 2bb7ee990..55052c151 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TByteArrayOutputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TByteArrayOutputStream.java @@ -15,6 +15,7 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TMath; import org.teavm.classlib.java.lang.TString; import org.teavm.classlib.java.util.TArrays; @@ -65,7 +66,7 @@ public class TByteArrayOutputStream extends TOutputStream { 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); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TCloseable.java b/classlib/src/main/java/org/teavm/classlib/java/io/TCloseable.java index f74b79962..27d222a4f 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TCloseable.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TCloseable.java @@ -15,9 +15,10 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TAutoCloseable; public interface TCloseable extends TAutoCloseable { @Override - void close() throws TIOException; + void close() throws IOException; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TDataInput.java b/classlib/src/main/java/org/teavm/classlib/java/io/TDataInput.java index 06d37bdd2..74b89b2a7 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TDataInput.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TDataInput.java @@ -15,36 +15,36 @@ */ package org.teavm.classlib.java.io; -import org.teavm.classlib.java.lang.TString; +import java.io.IOException; 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; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TDataInputStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TDataInputStream.java index 87baea7f9..eee1ff8d0 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TDataInputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TDataInputStream.java @@ -15,6 +15,7 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.*; public class TDataInputStream extends TFilterInputStream implements TDataInput { @@ -26,17 +27,17 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } @Override - public final int read(byte[] buffer) throws TIOException { + public final int read(byte[] buffer) throws IOException { return in.read(buffer, 0, buffer.length); } @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); } @Override - public final boolean readBoolean() throws TIOException { + public final boolean readBoolean() throws IOException { int temp = in.read(); if (temp < 0) { throw new TEOFException(); @@ -45,7 +46,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } @Override - public final byte readByte() throws TIOException { + public final byte readByte() throws IOException { int temp = in.read(); if (temp < 0) { throw new TEOFException(); @@ -53,7 +54,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { return (byte) temp; } - private int readToBuff(int count) throws TIOException { + private int readToBuff(int count) throws IOException { int offset = 0; while (offset < count) { int bytesRead = in.read(buff, offset, count - offset); @@ -66,7 +67,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } @Override - public final char readChar() throws TIOException { + public final char readChar() throws IOException { if (readToBuff(2) < 0) { throw new TEOFException(); } @@ -74,22 +75,22 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } @Override - public final double readDouble() throws TIOException { + public final double readDouble() throws IOException { return TDouble.longBitsToDouble(readLong()); } @Override - public final float readFloat() throws TIOException { + public final float readFloat() throws IOException { return TFloat.intBitsToFloat(readInt()); } @Override - public final void readFully(byte[] buffer) throws TIOException { + public final void readFully(byte[] buffer) throws IOException { readFully(buffer, 0, buffer.length); } @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) { throw new TIndexOutOfBoundsException(); } @@ -116,7 +117,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } @Override - public final int readInt() throws TIOException { + public final int readInt() throws IOException { if (readToBuff(4) < 0) { throw new TEOFException(); } @@ -125,7 +126,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { @Override @Deprecated - public final TString readLine() throws TIOException { + public final String readLine() throws IOException { TStringBuilder line = new TStringBuilder(80); boolean foundTerminator = false; while (true) { @@ -135,11 +136,11 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { if (line.length() == 0 && !foundTerminator) { return null; } - return TString.wrap(line.toString()); + return line.toString(); case (byte) '\r': if (foundTerminator) { ((TPushbackInputStream) in).unread(nextByte); - return TString.wrap(line.toString()); + return line.toString(); } foundTerminator = true; /* Have to be able to peek ahead one byte */ @@ -148,11 +149,11 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } break; case (byte) '\n': - return TString.wrap(line.toString()); + return line.toString(); default: if (foundTerminator) { ((TPushbackInputStream) in).unread(nextByte); - return TString.wrap(line.toString()); + return line.toString(); } line.append((char) nextByte); } @@ -160,7 +161,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } @Override - public final long readLong() throws TIOException { + public final long readLong() throws IOException { if (readToBuff(8) < 0) { throw new TEOFException(); } @@ -172,7 +173,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } @Override - public final short readShort() throws TIOException { + public final short readShort() throws IOException { if (readToBuff(2) < 0) { throw new TEOFException(); } @@ -180,7 +181,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } @Override - public final int readUnsignedByte() throws TIOException { + public final int readUnsignedByte() throws IOException { int temp = in.read(); if (temp < 0) { throw new TEOFException(); @@ -189,7 +190,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } @Override - public final int readUnsignedShort() throws TIOException { + public final int readUnsignedShort() throws IOException { if (readToBuff(2) < 0) { throw new TEOFException(); } @@ -197,15 +198,15 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { } @Override - public final TString readUTF() throws TIOException { + public final String readUTF() throws IOException { return decodeUTF(readUnsignedShort()); } - TString decodeUTF(int utfSize) throws TIOException { + String decodeUTF(int utfSize) throws IOException { 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]; char[] out = new char[utfSize]; in.readFully(buf, 0, utfSize); @@ -213,12 +214,12 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { 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); } @Override - public final int skipBytes(int count) throws TIOException { + public final int skipBytes(int count) throws IOException { int skipped = 0; while (skipped < count) { @@ -234,7 +235,7 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { 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 { int count = 0; int s = 0; @@ -247,27 +248,27 @@ public class TDataInputStream extends TFilterInputStream implements TDataInput { s++; } else if ((a & 0xe0) == 0xc0) { if (count >= utfSize) { - throw new TUTFDataFormatException(TString.wrap("End of stream reached")); + throw new TUTFDataFormatException("End of stream reached"); } int b = buf[offset + count++]; 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)); } else if ((a & 0xf0) == 0xe0) { 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 c = buf[offset + count++]; 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)); } 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); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TDataOutput.java b/classlib/src/main/java/org/teavm/classlib/java/io/TDataOutput.java index aef7bb989..6f05a361a 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TDataOutput.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TDataOutput.java @@ -15,34 +15,35 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TString; 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; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TDataOutputStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TDataOutputStream.java index 906e0a568..3cc9b0bad 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TDataOutputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TDataOutputStream.java @@ -14,6 +14,7 @@ * limitations under the License. */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.*; public class TDataOutputStream extends TFilterOutputStream implements TDataOutput { @@ -29,7 +30,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu } @Override - public void flush() throws TIOException { + public void flush() throws IOException { super.flush(); } @@ -41,7 +42,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu } @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) { throw new TNullPointerException(); } @@ -50,25 +51,25 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu } @Override - public void write(int oneByte) throws TIOException { + public void write(int oneByte) throws IOException { out.write(oneByte); written++; } @Override - public final void writeBoolean(boolean val) throws TIOException { + public final void writeBoolean(boolean val) throws IOException { out.write(val ? 1 : 0); written++; } @Override - public final void writeByte(int val) throws TIOException { + public final void writeByte(int val) throws IOException { out.write(val); written++; } @Override - public final void writeBytes(TString str) throws TIOException { + public final void writeBytes(TString str) throws IOException { if (str.length() == 0) { return; } @@ -81,7 +82,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu } @Override - public final void writeChar(int val) throws TIOException { + public final void writeChar(int val) throws IOException { buff[0] = (byte) (val >> 8); buff[1] = (byte) val; out.write(buff, 0, 2); @@ -89,7 +90,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu } @Override - public final void writeChars(TString str) throws TIOException { + public final void writeChars(TString str) throws IOException { byte[] newBytes = new byte[str.length() * 2]; for (int index = 0; index < str.length(); index++) { int newIndex = index == 0 ? index : index * 2; @@ -101,17 +102,17 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu } @Override - public final void writeDouble(double val) throws TIOException { + public final void writeDouble(double val) throws IOException { writeLong(TDouble.doubleToLongBits(val)); } @Override - public final void writeFloat(float val) throws TIOException { + public final void writeFloat(float val) throws IOException { writeInt(TFloat.floatToIntBits(val)); } @Override - public final void writeInt(int val) throws TIOException { + public final void writeInt(int val) throws IOException { buff[0] = (byte) (val >> 24); buff[1] = (byte) (val >> 16); buff[2] = (byte) (val >> 8); @@ -121,7 +122,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu } @Override - public final void writeLong(long val) throws TIOException { + public final void writeLong(long val) throws IOException { buff[0] = (byte) (val >> 56); buff[1] = (byte) (val >> 48); buff[2] = (byte) (val >> 40); @@ -134,7 +135,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu 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 >> 48); buffer[offset++] = (byte) (val >> 40); @@ -147,24 +148,24 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu } @Override - public final void writeShort(int val) throws TIOException { + public final void writeShort(int val) throws IOException { buff[0] = (byte) (val >> 8); buff[1] = (byte) val; out.write(buff, 0, 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; return offset; } @Override - public final void writeUTF(TString str) throws TIOException { + public final void writeUTF(TString str) throws IOException { long utfCount = countUTFBytes(str); if (utfCount > 65535) { - throw new TIOException(TString.wrap("UTF Error")); + throw new IOException("UTF Error"); } byte[] buffer = new byte[(int) utfCount + 2]; int offset = 0; @@ -189,7 +190,7 @@ public class TDataOutputStream extends TFilterOutputStream implements TDataOutpu 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(); for (int i = 0; i < length; i++) { int charValue = str.charAt(i); diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TEOFException.java b/classlib/src/main/java/org/teavm/classlib/java/io/TEOFException.java index 07436fd5d..562026f78 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TEOFException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TEOFException.java @@ -15,16 +15,16 @@ */ 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; public TEOFException() { super(); } - public TEOFException(TString message) { + public TEOFException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TFilterInputStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TFilterInputStream.java index 79e662448..f2481f8ac 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TFilterInputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TFilterInputStream.java @@ -15,6 +15,8 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; + public class TFilterInputStream extends TInputStream { protected volatile TInputStream in; @@ -23,12 +25,12 @@ public class TFilterInputStream extends TInputStream { } @Override - public int available() throws TIOException { + public int available() throws IOException { return in.available(); } @Override - public void close() throws TIOException { + public void close() throws IOException { in.close(); } @@ -43,27 +45,27 @@ public class TFilterInputStream extends TInputStream { } @Override - public int read() throws TIOException { + public int read() throws IOException { return in.read(); } @Override - public int read(byte[] buffer) throws TIOException { + public int read(byte[] buffer) throws IOException { return read(buffer, 0, buffer.length); } @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); } @Override - public synchronized void reset() throws TIOException { + public synchronized void reset() throws IOException { in.reset(); } @Override - public long skip(long count) throws TIOException { + public long skip(long count) throws IOException { return in.skip(count); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TFilterOutputStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TFilterOutputStream.java index e97610dfe..324c3cf4d 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TFilterOutputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TFilterOutputStream.java @@ -15,6 +15,8 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; + public class TFilterOutputStream extends TOutputStream { protected TOutputStream out; @@ -23,22 +25,22 @@ public class TFilterOutputStream extends TOutputStream { } @Override - public void write(int b) throws TIOException { + public void write(int b) throws IOException { out.write(b); } @Override - public void close() throws TIOException { + public void close() throws IOException { try { out.flush(); - } catch (TIOException e) { + } catch (IOException e) { // do nothing } out.close(); } @Override - public void flush() throws TIOException { + public void flush() throws IOException { out.flush(); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TFlushable.java b/classlib/src/main/java/org/teavm/classlib/java/io/TFlushable.java index 6c594c62e..2f327f784 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TFlushable.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TFlushable.java @@ -15,6 +15,8 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; + public interface TFlushable { - void flush() throws TIOException; + void flush() throws IOException; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TIOException.java b/classlib/src/main/java/org/teavm/classlib/java/io/TIOException.java index ad5de3a50..b323d491e 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TIOException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TIOException.java @@ -15,26 +15,22 @@ */ package org.teavm.classlib.java.io; -import org.teavm.classlib.java.lang.TException; -import org.teavm.classlib.java.lang.TString; -import org.teavm.classlib.java.lang.TThrowable; - -public class TIOException extends TException { +public class TIOException extends Exception { private static final long serialVersionUID = 3626109154700059455L; public TIOException() { super(); } - public TIOException(TString message, TThrowable cause) { + public TIOException(String message, Throwable cause) { super(message, cause); } - public TIOException(TString message) { + public TIOException(String message) { super(message); } - public TIOException(TThrowable cause) { + public TIOException(Throwable cause) { super(cause); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TInputStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TInputStream.java index edd7de6da..d7dce0fe4 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TInputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TInputStream.java @@ -15,6 +15,7 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TInteger; import org.teavm.classlib.java.lang.TObject; @@ -22,13 +23,13 @@ public abstract class TInputStream extends TObject implements TCloseable { 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); } - 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) { int bt = read(); if (bt < 0) { @@ -39,7 +40,7 @@ public abstract class TInputStream extends TObject implements TCloseable { return len > 0 ? len : -1; } - public long skip(long n) throws TIOException { + public long skip(long n) throws IOException { if (n < TInteger.MAX_VALUE) { return skip((int) n); } 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) { if (read() < 0) { return i; @@ -61,19 +62,19 @@ public abstract class TInputStream extends TObject implements TCloseable { return n; } - public int available() throws TIOException { + public int available() throws IOException { return 0; } @Override - public void close() throws TIOException { + public void close() throws IOException { } public void mark(@SuppressWarnings("unused") int readlimit) { } - public void reset() throws TIOException { - throw new TIOException(); + public void reset() throws IOException { + throw new IOException(); } public boolean markSupported() { diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TInputStreamReader.java b/classlib/src/main/java/org/teavm/classlib/java/io/TInputStreamReader.java index 37ab18c92..894731623 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TInputStreamReader.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TInputStreamReader.java @@ -15,7 +15,7 @@ */ 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.TCharBuffer; import org.teavm.classlib.java.nio.charset.TCharset; @@ -34,7 +34,7 @@ public class TInputStreamReader extends TReader { private boolean streamEof; private boolean eof; - public TInputStreamReader(TInputStream in, TString charsetName) throws TUnsupportedEncodingException { + public TInputStreamReader(TInputStream in, String charsetName) throws TUnsupportedEncodingException { this(in, getCharset(charsetName)); } @@ -55,7 +55,7 @@ public class TInputStreamReader extends TReader { inBuffer.position(inBuffer.limit()); } - private static TCharset getCharset(TString charsetName) throws TUnsupportedEncodingException { + private static TCharset getCharset(String charsetName) throws TUnsupportedEncodingException { try { return TCharset.forName(charsetName.toString()); } catch (TUnsupportedCharsetException e) { @@ -63,17 +63,17 @@ public class TInputStreamReader extends TReader { } } - public TString getEncoding() { - return TString.wrap(decoder.charset().name()); + public String getEncoding() { + return decoder.charset().name(); } @Override - public void close() throws TIOException { + public void close() throws IOException { stream.close(); } @Override - public int read() throws TIOException { + public int read() throws IOException { if (eof && !outBuffer.hasRemaining()) { return -1; } @@ -84,7 +84,7 @@ public class TInputStreamReader extends TReader { } @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()) { return -1; } @@ -101,7 +101,7 @@ public class TInputStreamReader extends TReader { return bytesRead; } - private boolean fillBuffer() throws TIOException { + private boolean fillBuffer() throws IOException { if (eof) { return false; } @@ -121,7 +121,7 @@ public class TInputStreamReader extends TReader { return true; } - private boolean fillReadBuffer() throws TIOException { + private boolean fillReadBuffer() throws IOException { if (streamEof) { return false; } @@ -143,7 +143,7 @@ public class TInputStreamReader extends TReader { } @Override - public boolean ready() throws TIOException { + public boolean ready() throws IOException { return outBuffer.hasRemaining() || inBuffer.hasRemaining(); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TOutputStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TOutputStream.java index fb531097b..57d1d4b88 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TOutputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TOutputStream.java @@ -15,26 +15,27 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TObject; 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); } - 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) { write(b[off++]); } } @Override - public void close() throws TIOException { + public void close() throws IOException { } @Override - public void flush() throws TIOException { + public void flush() throws IOException { } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TOutputStreamWriter.java b/classlib/src/main/java/org/teavm/classlib/java/io/TOutputStreamWriter.java index 6c40fc466..c68c84f4b 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TOutputStreamWriter.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TOutputStreamWriter.java @@ -15,10 +15,14 @@ */ 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.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; public class TOutputStreamWriter extends TWriter { @@ -61,12 +65,12 @@ public class TOutputStreamWriter extends TWriter { try { return TCharset.forName(charsetName); } catch (TUnsupportedCharsetException | TIllegalCharsetNameException e) { - throw new TUnsupportedEncodingException(TString.wrap(charsetName)); + throw new TUnsupportedEncodingException(charsetName); } } @Override - public void close() throws TIOException { + public void close() throws IOException { if (!closed) { flush(); closed = true; @@ -76,7 +80,7 @@ public class TOutputStreamWriter extends TWriter { } @Override - public void flush() throws TIOException { + public void flush() throws IOException { checkStatus(); if (buffer.position() > 0) { out.write(bufferData, 0, buffer.position()); @@ -85,9 +89,9 @@ public class TOutputStreamWriter extends TWriter { out.flush(); } - private void checkStatus() throws TIOException { + private void checkStatus() throws IOException { 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 - public void write(char[] buf, int offset, int count) throws TIOException { + public void write(char[] buf, int offset, int count) throws IOException { synchronized (lock) { checkStatus(); if (buf == null) { @@ -116,13 +120,13 @@ public class TOutputStreamWriter extends TWriter { } @Override - public void write(int oneChar) throws TIOException { + public void write(int oneChar) throws IOException { char[] array = { (char) oneChar }; write(array, 0, array.length); } @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) { throw new NullPointerException(); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TPrintStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TPrintStream.java index e3c806630..248e6b543 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TPrintStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TPrintStream.java @@ -15,13 +15,17 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TMath; 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.nio.TByteBuffer; 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; public class TPrintStream extends TFilterOutputStream { @@ -31,7 +35,7 @@ public class TPrintStream extends TFilterOutputStream { private char[] buffer = new char[32]; 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); this.autoFlush = autoFlush; try { @@ -71,7 +75,7 @@ public class TPrintStream extends TFilterOutputStream { } try { out.write(b); - } catch (TIOException e) { + } catch (IOException e) { errorState = true; } if (autoFlush && !errorState) { @@ -86,19 +90,19 @@ public class TPrintStream extends TFilterOutputStream { } try { out.write(b, off, len); - } catch (TIOException e) { + } catch (IOException e) { errorState = true; } } @Override - public void close() throws TIOException { + public void close() { if (!checkError()) { return; } try { out.close(); - } catch (TIOException e) { + } catch (IOException e) { errorState = true; } finally { out = null; @@ -106,13 +110,13 @@ public class TPrintStream extends TFilterOutputStream { } @Override - public void flush() throws TIOException { + public void flush() { if (!check()) { return; } try { out.flush(); - } catch (TIOException e) { + } catch (IOException e) { errorState = true; } } @@ -173,7 +177,7 @@ public class TPrintStream extends TFilterOutputStream { printSB(); } - public void print(TString s) { + public void print(String s) { sb.append(s); printSB(); } @@ -198,7 +202,7 @@ public class TPrintStream extends TFilterOutputStream { printSB(); } - public void println(TString s) { + public void println(String s) { sb.append(s).append('\n'); printSB(); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TPushbackInputStream.java b/classlib/src/main/java/org/teavm/classlib/java/io/TPushbackInputStream.java index ab19eec25..d044343f5 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TPushbackInputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TPushbackInputStream.java @@ -15,8 +15,8 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TArrayIndexOutOfBoundsException; -import org.teavm.classlib.java.lang.TString; public class TPushbackInputStream extends TFilterInputStream { protected byte[] buf; @@ -38,15 +38,15 @@ public class TPushbackInputStream extends TFilterInputStream { } @Override - public int available() throws TIOException { + public int available() throws IOException { if (buf == null) { - throw new TIOException(); + throw new IOException(); } return buf.length - pos + in.available(); } @Override - public void close() throws TIOException { + public void close() throws IOException { if (in != null) { in.close(); in = null; @@ -60,9 +60,9 @@ public class TPushbackInputStream extends TFilterInputStream { } @Override - public int read() throws TIOException { + public int read() throws IOException { if (buf == null) { - throw new TIOException(); + throw new IOException(); } // Is there a pushback byte available? if (pos < buf.length) { @@ -74,16 +74,16 @@ public class TPushbackInputStream extends TFilterInputStream { } @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) { - throw new TIOException(TString.wrap("Stream is closed")); + throw new IOException("Stream is closed"); } // Force buffer null check first! 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) { - throw new TArrayIndexOutOfBoundsException(TString.wrap("Length out of bounds: " + length)); + throw new TArrayIndexOutOfBoundsException("Length out of bounds: " + length); } int copiedBytes = 0; @@ -113,9 +113,9 @@ public class TPushbackInputStream extends TFilterInputStream { } @Override - public long skip(long count) throws TIOException { + public long skip(long count) throws IOException { if (in == null) { - throw new TIOException(); + throw new IOException(); } if (count <= 0) { return 0; @@ -131,44 +131,43 @@ public class TPushbackInputStream extends TFilterInputStream { return numSkipped; } - public void unread(byte[] buffer) throws TIOException { + public void unread(byte[] buffer) throws IOException { 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) { - throw new TIOException(TString.wrap("Pushback buffer full")); + throw new IOException("Pushback buffer full"); } 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) { - throw new TArrayIndexOutOfBoundsException(TString.wrap("Length out of bounds: " + length)); + throw new TArrayIndexOutOfBoundsException("Length out of bounds: " + length); } 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); pos = pos - length; } - public void unread(int oneByte) throws TIOException { + public void unread(int oneByte) throws IOException { if (buf == null) { - throw new TIOException(); + throw new IOException(); } if (pos == 0) { - throw new TIOException(); + throw new IOException(); } buf[--pos] = (byte) oneByte; } @Override public void mark(int readlimit) { - return; } @Override - public void reset() throws TIOException { - throw new TIOException(); + public void reset() throws IOException { + throw new IOException(); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TRandomAccessFile.java b/classlib/src/main/java/org/teavm/classlib/java/io/TRandomAccessFile.java index 70e8dac11..e093389ab 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TRandomAccessFile.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TRandomAccessFile.java @@ -456,7 +456,7 @@ public class TRandomAccessFile implements DataInput, DataOutput, Closeable { 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; return offset; diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TReader.java b/classlib/src/main/java/org/teavm/classlib/java/io/TReader.java index 0f3882cf7..c6dcaf0b4 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TReader.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TReader.java @@ -15,6 +15,7 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TMath; import org.teavm.classlib.java.lang.TObject; @@ -29,18 +30,18 @@ public abstract class TReader implements TCloseable { this.lock = lock; } - public int read() throws TIOException { + public int read() throws IOException { char[] buf = new char[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); } - 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]; long skipped = 0; while (skipped < n) { @@ -53,7 +54,7 @@ public abstract class TReader implements TCloseable { return skipped; } - public boolean ready() throws TIOException { + public boolean ready() throws IOException { return true; } @@ -61,11 +62,11 @@ public abstract class TReader implements TCloseable { return false; } - public void mark(@SuppressWarnings("unused") int readAheadLimit) throws TIOException { - throw new TIOException(); + public void mark(@SuppressWarnings("unused") int readAheadLimit) throws IOException { + throw new IOException(); } - public void reset() throws TIOException { - throw new TIOException(); + public void reset() throws IOException { + throw new IOException(); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TStringReader.java b/classlib/src/main/java/org/teavm/classlib/java/io/TStringReader.java index e89180acb..8dd2aa022 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TStringReader.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TStringReader.java @@ -15,6 +15,7 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TIllegalArgumentException; import org.teavm.classlib.java.lang.TMath; import org.teavm.classlib.java.lang.TNullPointerException; @@ -33,7 +34,7 @@ public class TStringReader extends TReader { } @Override - public int read() throws TIOException { + public int read() throws IOException { checkOpened(); if (index >= string.length()) { return -1; @@ -42,7 +43,7 @@ public class TStringReader extends TReader { } @Override - public int read(char[] cbuf, int off, int len) throws TIOException { + public int read(char[] cbuf, int off, int len) throws IOException { checkOpened(); if (index >= string.length()) { return -1; @@ -55,7 +56,7 @@ public class TStringReader extends TReader { } @Override - public long skip(long n) throws TIOException { + public long skip(long n) throws IOException { checkOpened(); if (n < 0) { n = TMath.max(n, -index); @@ -67,7 +68,7 @@ public class TStringReader extends TReader { } @Override - public boolean ready() throws TIOException { + public boolean ready() throws IOException { checkOpened(); return true; } @@ -78,7 +79,7 @@ public class TStringReader extends TReader { } @Override - public void mark(int readAheadLimit) throws TIOException { + public void mark(int readAheadLimit) throws IOException { checkOpened(); if (readAheadLimit < 0) { throw new TIllegalArgumentException(); @@ -87,7 +88,7 @@ public class TStringReader extends TReader { } @Override - public void reset() throws TIOException { + public void reset() throws IOException { checkOpened(); index = mark; } @@ -97,9 +98,9 @@ public class TStringReader extends TReader { string = null; } - private void checkOpened() throws TIOException { + private void checkOpened() throws IOException { if (string == null) { - throw new TIOException(); + throw new IOException(); } } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TUTFDataFormatException.java b/classlib/src/main/java/org/teavm/classlib/java/io/TUTFDataFormatException.java index 291f33345..f37c77f92 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TUTFDataFormatException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TUTFDataFormatException.java @@ -15,16 +15,16 @@ */ 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; public TUTFDataFormatException() { super(); } - public TUTFDataFormatException(TString message) { + public TUTFDataFormatException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TUnsupportedEncodingException.java b/classlib/src/main/java/org/teavm/classlib/java/io/TUnsupportedEncodingException.java index 297e3bbd0..9e29f066d 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TUnsupportedEncodingException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TUnsupportedEncodingException.java @@ -15,8 +15,6 @@ */ package org.teavm.classlib.java.io; -import org.teavm.classlib.java.lang.TString; - public class TUnsupportedEncodingException extends TIOException { private static final long serialVersionUID = 2403781130729330252L; @@ -24,7 +22,7 @@ public class TUnsupportedEncodingException extends TIOException { super(); } - public TUnsupportedEncodingException(TString message) { + public TUnsupportedEncodingException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/io/TWriter.java b/classlib/src/main/java/org/teavm/classlib/java/io/TWriter.java index 83184ad8a..20e4b852d 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/io/TWriter.java +++ b/classlib/src/main/java/org/teavm/classlib/java/io/TWriter.java @@ -15,6 +15,7 @@ */ package org.teavm.classlib.java.io; +import java.io.IOException; import org.teavm.classlib.java.lang.TAppendable; import org.teavm.classlib.java.lang.TCharSequence; @@ -33,13 +34,13 @@ public abstract class TWriter implements TAppendable, TCloseable, TFlushable { this.lock = lock; } - public void write(char[] buf) throws TIOException { + public void write(char[] buf) throws IOException { 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) { char[] oneCharArray = new char[1]; 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()); } - 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) { throw new StringIndexOutOfBoundsException(); } @@ -63,19 +64,19 @@ public abstract class TWriter implements TAppendable, TCloseable, TFlushable { } @Override - public TWriter append(char c) throws TIOException { + public TWriter append(char c) throws IOException { write(c); return this; } @Override - public TWriter append(TCharSequence csq) throws TIOException { + public TWriter append(TCharSequence csq) throws IOException { write(csq != null ? csq.toString() : "null"); return this; } @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"); return this; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java index 2bb62b779..2bd030d25 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java @@ -56,16 +56,16 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ length = value.length(); } - protected TAbstractStringBuilder append(TString string) { + protected TAbstractStringBuilder append(String string) { return insert(length, string); } - protected TAbstractStringBuilder insert(int index, TString string) { + protected TAbstractStringBuilder insert(int index, String string) { if (index < 0 || index > length) { throw new TStringIndexOutOfBoundsException(); } if (string == null) { - string = TString.wrap("null"); + string = "null"; } else if (string.isEmpty()) { return this; } @@ -502,7 +502,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ } 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) { @@ -510,7 +510,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ } 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) { @@ -606,7 +606,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { if (srcBegin > srcEnd) { - throw new TIndexOutOfBoundsException(TString.wrap("Index out of bounds")); + throw new IndexOutOfBoundsException("Index out of bounds"); } while (srcBegin < srcEnd) { dst[dstBegin++] = buffer[srcBegin++]; diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TAppendable.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TAppendable.java index 19f5609f6..96fec461c 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TAppendable.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TAppendable.java @@ -15,12 +15,12 @@ */ package org.teavm.classlib.java.lang; -import org.teavm.classlib.java.io.TIOException; +import java.io.IOException; 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; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TArithmeticException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TArithmeticException.java index 742163980..3efcc2f59 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TArithmeticException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TArithmeticException.java @@ -22,7 +22,7 @@ public class TArithmeticException extends TRuntimeException { super(); } - public TArithmeticException(TString message) { + public TArithmeticException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TArrayIndexOutOfBoundsException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TArrayIndexOutOfBoundsException.java index be3ed642a..62c940b6c 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TArrayIndexOutOfBoundsException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TArrayIndexOutOfBoundsException.java @@ -22,11 +22,11 @@ public class TArrayIndexOutOfBoundsException extends TIndexOutOfBoundsException super(); } - public TArrayIndexOutOfBoundsException(TString message) { + public TArrayIndexOutOfBoundsException(String message) { super(message); } public TArrayIndexOutOfBoundsException(int index) { - super(TString.wrap(Integer.toString(index))); + super(Integer.toString(index)); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TArrayStoreException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TArrayStoreException.java index 101e049af..e3fa07889 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TArrayStoreException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TArrayStoreException.java @@ -22,7 +22,7 @@ public class TArrayStoreException extends TRuntimeException { super(); } - public TArrayStoreException(TString message) { + public TArrayStoreException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TAssertionError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TAssertionError.java index 6f6981afb..2e53bb3ee 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TAssertionError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TAssertionError.java @@ -22,11 +22,11 @@ public class TAssertionError extends TError { super(); } - public TAssertionError(TString message, TThrowable cause) { + public TAssertionError(String message, TThrowable cause) { super(message, cause); } - public TAssertionError(TObject message) { + public TAssertionError(Object message) { super(TString.valueOf(message)); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TAutoCloseable.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TAutoCloseable.java index 5c832b4d5..5eff97626 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TAutoCloseable.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TAutoCloseable.java @@ -16,5 +16,5 @@ package org.teavm.classlib.java.lang; public interface TAutoCloseable { - void close() throws TException; + void close() throws Exception; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TBoolean.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TBoolean.java index fbd361ee9..b43d39e2c 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TBoolean.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TBoolean.java @@ -27,7 +27,7 @@ public class TBoolean extends TObject implements TSerializable, TComparable { this.value = value; } - public TByte(TString value) { + public TByte(String value) { this.value = parseByte(value, 10); } @@ -88,11 +88,11 @@ public class TByte extends TNumber implements TComparable { 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); } - 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); if (value < MIN_VALUE || value >= MAX_VALUE) { throw new TNumberFormatException(); @@ -100,15 +100,15 @@ public class TByte extends TNumber implements TComparable { 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)); } - public static TByte valueOf(TString s) throws TNumberFormatException { + public static TByte valueOf(String s) throws TNumberFormatException { 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); if (value.intValue() < MIN_VALUE || value.intValue() >= MAX_VALUE) { throw new TNumberFormatException(); diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java index 55ebbc1c4..84b1314fa 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java @@ -53,8 +53,8 @@ import org.teavm.runtime.RuntimeClass; import org.teavm.runtime.RuntimeObject; public class TClass extends TObject implements TAnnotatedElement { - TString name; - TString simpleName; + String name; + String simpleName; private PlatformClass platformClass; private TAnnotation[] annotationsCache; private Map, TAnnotation> annotationsByType; @@ -105,22 +105,22 @@ public class TClass extends TObject implements TAnnotatedElement { } @Unmanaged - public TString getName() { + public String getName() { if (PlatformDetector.isLowLevel()) { - return TString.wrap(Platform.getName(platformClass)); + return Platform.getName(platformClass); } else { if (name == null) { - name = TString.wrap(Platform.getName(platformClass)); + name = Platform.getName(platformClass); } return name; } } - public TString getSimpleName() { - TString simpleName = getSimpleNameCache(); + public String getSimpleName() { + String simpleName = getSimpleNameCache(); if (simpleName == null) { if (isArray()) { - simpleName = getComponentType().getSimpleName().concat(TString.wrap("[]")); + simpleName = getComponentType().getSimpleName() + "[]"; setSimpleNameCache(simpleName); return simpleName; } @@ -137,14 +137,14 @@ public class TClass extends TObject implements TAnnotatedElement { name = name.substring(lastDot + 1); } } - simpleName = TString.wrap(name); + simpleName = name; setSimpleNameCache(simpleName); } return simpleName; } @DelegateTo("getSimpleNameCacheLowLevel") - private TString getSimpleNameCache() { + private String getSimpleNameCache() { return simpleName; } @@ -154,7 +154,7 @@ public class TClass extends TObject implements TAnnotatedElement { return Address.ofObject(this).toStructure().simpleName; } - private void setSimpleNameCache(TString value) { + private void setSimpleNameCache(String value) { simpleName = value; } @@ -559,8 +559,7 @@ public class TClass extends TObject implements TAnnotatedElement { @SuppressWarnings("unchecked") public T cast(TObject obj) { if (obj != null && !isAssignableFrom((TClass) (Object) obj.getClass())) { - throw new TClassCastException(TString.wrap(obj.getClass().getName() - + " is not subtype of " + name)); + throw new TClassCastException(obj.getClass().getName() + " is not subtype of " + name); } return (T) obj; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TClassCastException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TClassCastException.java index 8e4a82888..1382ff313 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TClassCastException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TClassCastException.java @@ -22,7 +22,7 @@ public class TClassCastException extends TRuntimeException { super(); } - public TClassCastException(TString message) { + public TClassCastException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TClassNotFoundException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TClassNotFoundException.java index f7fc9e2df..7ccf93385 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TClassNotFoundException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TClassNotFoundException.java @@ -22,11 +22,11 @@ public class TClassNotFoundException extends TReflectiveOperationException { super(); } - public TClassNotFoundException(TString message, TThrowable cause) { + public TClassNotFoundException(String message, TThrowable cause) { super(message, cause); } - public TClassNotFoundException(TString message) { + public TClassNotFoundException(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TCloneNotSupportedException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TCloneNotSupportedException.java index f2c299d0d..501611929 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TCloneNotSupportedException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TCloneNotSupportedException.java @@ -22,7 +22,7 @@ public class TCloneNotSupportedException extends TException { super(); } - public TCloneNotSupportedException(TString message) { + public TCloneNotSupportedException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleInputStream.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleInputStream.java index 00ac370d8..b7a9f0a12 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleInputStream.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleInputStream.java @@ -15,18 +15,18 @@ */ package org.teavm.classlib.java.lang; +import java.io.IOException; import org.teavm.classlib.java.io.TEOFException; -import org.teavm.classlib.java.io.TIOException; import org.teavm.classlib.java.io.TInputStream; class TConsoleInputStream extends TInputStream { @Override - public int read(byte[] b) throws TIOException { + public int read(byte[] b) throws IOException { throw new TEOFException(); } @Override - public int read() throws TIOException { + public int read() throws IOException { throw new TEOFException(); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleOutputStreamStderr.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleOutputStreamStderr.java index eb7f3b0ea..5abe0726c 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleOutputStreamStderr.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleOutputStreamStderr.java @@ -15,7 +15,7 @@ */ 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.interop.DelegateTo; import org.teavm.interop.Import; @@ -24,7 +24,7 @@ import org.teavm.jso.JSBody; class TConsoleOutputStreamStderr extends TOutputStream { @Override @DelegateTo("writeLowLevel") - public void write(int b) throws TIOException { + public void write(int b) throws IOException { writeJs(b); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleOutputStreamStdout.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleOutputStreamStdout.java index de3503e20..5d2f37ed6 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleOutputStreamStdout.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TConsoleOutputStreamStdout.java @@ -15,7 +15,7 @@ */ 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.interop.DelegateTo; import org.teavm.jso.JSBody; @@ -23,7 +23,7 @@ import org.teavm.jso.JSBody; class TConsoleOutputStreamStdout extends TOutputStream { @Override @DelegateTo("writeLowLevel") - public void write(int b) throws TIOException { + public void write(int b) throws IOException { writeJs(b); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TDouble.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TDouble.java index 80857e9b2..a49a6bf6f 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TDouble.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TDouble.java @@ -251,11 +251,11 @@ public class TDouble extends TNumber implements TComparable { @Import(name = "teavm_reinterpretLongToDouble") public static native double longBitsToDouble(long bits); - public static TString toHexString(double d) { + public static String toHexString(double d) { if (isNaN(d)) { - return TString.wrap("NaN"); + return "NaN"; } else if (isInfinite(d)) { - return d > 0 ? TString.wrap("Infinity") : TString.wrap("-Infinity"); + return d > 0 ? "Infinity" : "-Infinity"; } char[] buffer = new char[30]; int sz = 0; @@ -312,6 +312,6 @@ public class TDouble extends TNumber implements TComparable { buffer[sz++] = '0'; } - return new TString(buffer, 0, sz); + return new String(buffer, 0, sz); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TEnum.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TEnum.java index 6cd9a4def..3d6d83838 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TEnum.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TEnum.java @@ -64,8 +64,8 @@ public abstract class TEnum> extends TObject implements TComp @Override public final int compareTo(E o) { if (o.getDeclaringClass() != getDeclaringClass()) { - throw new TIllegalArgumentException(TString.wrap("Can't compare " - + getDeclaringClass().getName().toString() + " to " + o.getDeclaringClass().getName().toString())); + throw new TIllegalArgumentException("Can't compare " + + getDeclaringClass().getName() + " to " + o.getDeclaringClass().getName()); } return TInteger.compare(ordinal, o.ordinal()); } @@ -74,14 +74,13 @@ public abstract class TEnum> extends TObject implements TComp // TODO: speed-up this method, use caching T[] constants = enumType.getEnumConstants(); 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) { if (constant.name().equals(name)) { return constant; } } - throw new TIllegalArgumentException(TString.wrap("Enum " + enumType.getName() + " does not have the " + name - + "constant")); + throw new TIllegalArgumentException("Enum " + enumType.getName() + " does not have the " + name + "constant"); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TError.java index c1544911a..8256a5d8b 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TError.java @@ -21,11 +21,11 @@ public class TError extends TThrowable { public TError() { } - public TError(TString message, TThrowable cause) { + public TError(String message, TThrowable cause) { super(message, cause); } - public TError(TString message) { + public TError(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TException.java index 4dd061213..19ac1e19c 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TException.java @@ -22,11 +22,11 @@ public class TException extends TThrowable { super(); } - public TException(TString message, TThrowable cause) { + public TException(String message, TThrowable cause) { super(message, cause); } - public TException(TString message) { + public TException(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TFloat.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TFloat.java index fdfa6fc12..2dd0d482b 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TFloat.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TFloat.java @@ -256,11 +256,11 @@ public class TFloat extends TNumber implements TComparable { @Import(name = "teavm_reinterpretIntToFloat") public static native float intBitsToFloat(int bits); - public static TString toHexString(float f) { + public static String toHexString(float f) { if (isNaN(f)) { - return TString.wrap("NaN"); + return "NaN"; } else if (isInfinite(f)) { - return f > 0 ? TString.wrap("Infinity") : TString.wrap("-Infinity"); + return f > 0 ? "Infinity" : "-Infinity"; } char[] buffer = new char[18]; int sz = 0; @@ -317,6 +317,6 @@ public class TFloat extends TNumber implements TComparable { buffer[sz++] = '0'; } - return new TString(buffer, 0, sz); + return new String(buffer, 0, sz); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalArgumentException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalArgumentException.java index 3b3e20313..38d7dc22a 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalArgumentException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalArgumentException.java @@ -22,11 +22,11 @@ public class TIllegalArgumentException extends TRuntimeException { super(); } - public TIllegalArgumentException(TString message, TThrowable cause) { + public TIllegalArgumentException(String message, TThrowable cause) { super(message, cause); } - public TIllegalArgumentException(TString message) { + public TIllegalArgumentException(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalMonitorStateException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalMonitorStateException.java index e737ffa62..74c98279c 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalMonitorStateException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalMonitorStateException.java @@ -22,7 +22,7 @@ public class TIllegalMonitorStateException extends TRuntimeException { super(); } - public TIllegalMonitorStateException(TString message) { + public TIllegalMonitorStateException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalStateException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalStateException.java index f50388353..bc0a30f54 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalStateException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TIllegalStateException.java @@ -22,11 +22,11 @@ public class TIllegalStateException extends TException { super(); } - public TIllegalStateException(TString message, TThrowable cause) { + public TIllegalStateException(String message, TThrowable cause) { super(message, cause); } - public TIllegalStateException(TString message) { + public TIllegalStateException(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TIncompatibleClassChangeError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TIncompatibleClassChangeError.java index 8f85315d9..dd839797a 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TIncompatibleClassChangeError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TIncompatibleClassChangeError.java @@ -22,7 +22,7 @@ public class TIncompatibleClassChangeError extends TLinkageError { super(); } - public TIncompatibleClassChangeError(TString message) { + public TIncompatibleClassChangeError(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TIndexOutOfBoundsException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TIndexOutOfBoundsException.java index 378a8466f..a27892c69 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TIndexOutOfBoundsException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TIndexOutOfBoundsException.java @@ -22,7 +22,7 @@ public class TIndexOutOfBoundsException extends TRuntimeException { super(); } - public TIndexOutOfBoundsException(TString message) { + public TIndexOutOfBoundsException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TInteger.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TInteger.java index edc150018..42099cb2c 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TInteger.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TInteger.java @@ -30,7 +30,7 @@ public class TInteger extends TNumber implements TComparable { this.value = value; } - public TInteger(TString s) throws NumberFormatException { + public TInteger(String s) throws NumberFormatException { this(parseInt(s)); } @@ -57,12 +57,12 @@ public class TInteger extends TNumber implements TComparable { 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) { - throw new TNumberFormatException(TString.wrap("Illegal radix: " + radix)); + throw new TNumberFormatException("Illegal radix: " + radix); } 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; int index = 0; @@ -82,32 +82,32 @@ public class TInteger extends TNumber implements TComparable { while (index < s.length()) { int digit = TCharacter.getNumericValue(s.charAt(index++)); if (digit < 0) { - throw new TNumberFormatException(TString.wrap("String contains invalid digits: " + s)); + throw new TNumberFormatException("String contains invalid digits: " + s); } if (digit >= radix) { - throw new TNumberFormatException(TString.wrap("String contains digits out of radix " + radix - + ": " + s)); + throw new TNumberFormatException("String contains digits out of radix " + radix + + ": " + s); } value = radix * value + digit; if (value < 0) { if (index == s.length() && value == MIN_VALUE && negative) { 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; } - public static int parseInt(TString s) throws TNumberFormatException { + public static int parseInt(String s) throws TNumberFormatException { 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)); } - public static TInteger valueOf(TString s) throws TNumberFormatException { + public static TInteger valueOf(String s) throws TNumberFormatException { return valueOf(s, 10); } @@ -175,7 +175,7 @@ public class TInteger extends TNumber implements TComparable { } 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 { return result != null ? TInteger.valueOf(result) : val; } catch (NumberFormatException e) { @@ -183,9 +183,9 @@ public class TInteger extends TNumber implements TComparable { } } - public static TInteger decode(TString nm) throws TNumberFormatException { + public static TInteger decode(String nm) throws TNumberFormatException { 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; boolean negaive = false; @@ -196,7 +196,7 @@ public class TInteger extends TNumber implements TComparable { negaive = true; } 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; if (nm.charAt(index) == '#') { @@ -215,20 +215,20 @@ public class TInteger extends TNumber implements TComparable { } } 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; while (index < nm.length()) { int digit = decodeDigit(nm.charAt(index++)); 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; if (value < 0) { if (negaive && value == MIN_VALUE && index == nm.length()) { 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); diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TInternalError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TInternalError.java index 649b86dfa..4e0a36d27 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TInternalError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TInternalError.java @@ -20,11 +20,11 @@ public class TInternalError extends TVirtualMachineError { public TInternalError() { } - public TInternalError(TString message) { + public TInternalError(String message) { super(message); } - public TInternalError(TString message, TThrowable cause) { + public TInternalError(String message, TThrowable cause) { super(message, cause); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TLinkageError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TLinkageError.java index ab27912f1..0d0e5d628 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TLinkageError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TLinkageError.java @@ -22,11 +22,11 @@ public class TLinkageError extends TError { super(); } - public TLinkageError(TString message, TThrowable cause) { + public TLinkageError(String message, TThrowable cause) { super(message, cause); } - public TLinkageError(TString message) { + public TLinkageError(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TLong.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TLong.java index db6c138bc..990455656 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TLong.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TLong.java @@ -29,7 +29,7 @@ public class TLong extends TNumber implements TComparable { this.value = value; } - public TLong(TString value) throws TNumberFormatException { + public TLong(String value) throws TNumberFormatException { this(parseLong(value)); } @@ -37,12 +37,12 @@ public class TLong extends TNumber implements TComparable { 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) { - throw new TNumberFormatException(TString.wrap("Illegal radix: " + radix)); + throw new TNumberFormatException("Illegal radix: " + radix); } 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; int index = 0; @@ -59,38 +59,38 @@ public class TLong extends TNumber implements TComparable { while (index < s.length()) { int digit = TCharacter.getNumericValue(s.charAt(index++)); if (digit < 0) { - throw new TNumberFormatException(TString.wrap("String contains invalid digits: " + s)); + throw new TNumberFormatException("String contains invalid digits: " + s); } if (digit >= radix) { - throw new TNumberFormatException(TString.wrap("String contains digits out of radix " + radix - + ": " + s)); + throw new TNumberFormatException("String contains digits out of radix " + radix + + ": " + s); } value = radix * value + digit; if (value < 0) { if (index == s.length() && value == MIN_VALUE && negative) { 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; } - public static long parseLong(TString s) throws TNumberFormatException { + public static long parseLong(String s) throws TNumberFormatException { 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)); } - public static TLong valueOf(TString s) throws TNumberFormatException { + public static TLong valueOf(String s) throws TNumberFormatException { return valueOf(parseLong(s)); } public static TLong decode(TString nm) throws TNumberFormatException { 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; boolean negaive = false; @@ -101,7 +101,7 @@ public class TLong extends TNumber implements TComparable { negaive = true; } 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; if (nm.charAt(index) == '#') { @@ -120,20 +120,20 @@ public class TLong extends TNumber implements TComparable { } } 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; while (index < nm.length()) { int digit = decodeDigit(nm.charAt(index++)); 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; if (value < 0) { if (negaive && value == MIN_VALUE && index == nm.length()) { 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); @@ -219,16 +219,16 @@ public class TLong extends TNumber implements TComparable { return compare(value, other.value); } - public static TLong getLong(TString nm) { + public static TLong getLong(String nm) { 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)); } - public static TLong getLong(TString nm, TLong val) { - TString result = nm != null ? TString.wrap(TSystem.getProperty(nm.toString())) : null; + public static TLong getLong(String nm, TLong val) { + String result = nm != null ? TSystem.getProperty(nm) : null; try { return result != null ? TLong.valueOf(result) : val; } catch (NumberFormatException e) { diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TNegativeArraySizeException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TNegativeArraySizeException.java index c27dc2cfa..c74da880e 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TNegativeArraySizeException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TNegativeArraySizeException.java @@ -22,7 +22,7 @@ public class TNegativeArraySizeException extends TRuntimeException { super(); } - public TNegativeArraySizeException(TString message) { + public TNegativeArraySizeException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TNoClassDefFoundError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TNoClassDefFoundError.java index 082d982af..341431f7f 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TNoClassDefFoundError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TNoClassDefFoundError.java @@ -22,7 +22,7 @@ public class TNoClassDefFoundError extends TLinkageError { super(); } - public TNoClassDefFoundError(TString message) { + public TNoClassDefFoundError(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchFieldError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchFieldError.java index 6ad59e3db..d7bc4663c 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchFieldError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchFieldError.java @@ -22,7 +22,7 @@ public class TNoSuchFieldError extends TIncompatibleClassChangeError { super(); } - public TNoSuchFieldError(TString message) { + public TNoSuchFieldError(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchMethodError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchMethodError.java index 4fa25f335..ec7054612 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchMethodError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchMethodError.java @@ -22,7 +22,7 @@ public class TNoSuchMethodError extends TIncompatibleClassChangeError { super(); } - public TNoSuchMethodError(TString message) { + public TNoSuchMethodError(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchMethodException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchMethodException.java index 2cd78206a..8956f15f8 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchMethodException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TNoSuchMethodException.java @@ -19,7 +19,7 @@ public class TNoSuchMethodException extends TReflectiveOperationException { public TNoSuchMethodException() { } - public TNoSuchMethodException(TString message) { + public TNoSuchMethodException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TNullPointerException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TNullPointerException.java index 48124187a..6f0a5e8b4 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TNullPointerException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TNullPointerException.java @@ -18,7 +18,7 @@ package org.teavm.classlib.java.lang; public class TNullPointerException extends TRuntimeException { private static final long serialVersionUID = 2639861320773057190L; - public TNullPointerException(TString message) { + public TNullPointerException(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TNumberFormatException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TNumberFormatException.java index 6acceba48..345b9fc6a 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TNumberFormatException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TNumberFormatException.java @@ -22,7 +22,7 @@ public class TNumberFormatException extends TIllegalArgumentException { super(); } - public TNumberFormatException(TString message) { + public TNumberFormatException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java index 9a81ffc9b..a8977b063 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java @@ -23,7 +23,6 @@ import org.teavm.interop.Rename; import org.teavm.interop.Structure; import org.teavm.interop.Superclass; import org.teavm.interop.Sync; -import org.teavm.interop.Unmanaged; import org.teavm.jso.browser.TimerHandler; import org.teavm.platform.Platform; import org.teavm.platform.PlatformObject; @@ -392,9 +391,4 @@ public class TObject { @Override protected void finalize() throws TThrowable { } - - @Unmanaged - public static TObject wrap(Object obj) { - return (TObject) obj; - } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TOutOfMemoryError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TOutOfMemoryError.java index 540664a23..a9c03b142 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TOutOfMemoryError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TOutOfMemoryError.java @@ -22,7 +22,7 @@ public class TOutOfMemoryError extends TVirtualMachineError { super(); } - public TOutOfMemoryError(TString message) { + public TOutOfMemoryError(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TReflectiveOperationException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TReflectiveOperationException.java index cebbc742b..6ad06a6db 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TReflectiveOperationException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TReflectiveOperationException.java @@ -22,11 +22,11 @@ public class TReflectiveOperationException extends TException { super(); } - public TReflectiveOperationException(TString message, TThrowable cause) { + public TReflectiveOperationException(String message, TThrowable cause) { super(message, cause); } - public TReflectiveOperationException(TString message) { + public TReflectiveOperationException(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TRuntimeException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TRuntimeException.java index 2aec5adf2..2938d5207 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TRuntimeException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TRuntimeException.java @@ -25,11 +25,11 @@ public class TRuntimeException extends TException { super(); } - public TRuntimeException(TString message, TThrowable cause) { + public TRuntimeException(String message, TThrowable cause) { super(message, cause); } - public TRuntimeException(TString message) { + public TRuntimeException(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TSecurityException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TSecurityException.java index 42942f2c4..326b03f8b 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TSecurityException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TSecurityException.java @@ -22,11 +22,11 @@ public class TSecurityException extends TRuntimeException { super(); } - public TSecurityException(TString message, TThrowable cause) { + public TSecurityException(String message, TThrowable cause) { super(message, cause); } - public TSecurityException(TString message) { + public TSecurityException(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TShort.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TShort.java index 867537047..56531a8e1 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TShort.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TShort.java @@ -26,7 +26,7 @@ public class TShort extends TNumber implements TComparable { this.value = value; } - public TShort(TString s) throws TNumberFormatException { + public TShort(String s) throws TNumberFormatException { this(parseShort(s)); } @@ -87,7 +87,7 @@ public class TShort extends TNumber implements TComparable { 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); if (value < MIN_VALUE || value > MAX_VALUE) { throw new TNumberFormatException(); @@ -95,19 +95,19 @@ public class TShort extends TNumber implements TComparable { return (short) value; } - public static short parseShort(TString s) throws TNumberFormatException { + public static short parseShort(String s) throws TNumberFormatException { 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)); } - public static TShort valueOf(TString s) throws TNumberFormatException { + public static TShort valueOf(String s) throws TNumberFormatException { 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(); if (value < MIN_VALUE || value > MAX_VALUE) { throw new TNumberFormatException(); diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TStackOverflowError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TStackOverflowError.java index 0b95e23bb..51240b41b 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TStackOverflowError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TStackOverflowError.java @@ -31,17 +31,13 @@ */ package org.teavm.classlib.java.lang; -/** - * - * @author Sergey Kapralov - */ public class TStackOverflowError extends TVirtualMachineError { public TStackOverflowError() { super(); } - public TStackOverflowError(TString string) { + public TStackOverflowError(String string) { super(string); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TStackTraceElement.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TStackTraceElement.java index 207addf93..8fe0dbc51 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TStackTraceElement.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TStackTraceElement.java @@ -20,12 +20,12 @@ import org.teavm.classlib.java.io.TSerializable; import org.teavm.classlib.java.util.TObjects; public final class TStackTraceElement extends TObject implements TSerializable { - private TString declaringClass; - private TString methodName; - private TString fileName; + private String declaringClass; + private String methodName; + private String fileName; 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) { throw new TNullPointerException(); } @@ -35,15 +35,15 @@ public final class TStackTraceElement extends TObject implements TSerializable { this.lineNumber = lineNumber; } - public TString getClassName() { + public String getClassName() { return declaringClass; } - public TString getMethodName() { + public String getMethodName() { return methodName; } - public TString getFileName() { + public String getFileName() { return fileName; } @@ -77,15 +77,15 @@ public final class TStackTraceElement extends TObject implements TSerializable { @Override public String toString() { - TStringBuilder sb = new TStringBuilder(); + StringBuilder sb = new StringBuilder(); int index = declaringClass.lastIndexOf('.'); sb.append(declaringClass.substring(index + 1)).append('.').append(methodName).append('('); if (fileName != null) { sb.append(fileName).append(':').append(lineNumber); } else { - sb.append(TString.wrap("Unknown Source")); + sb.append("Unknown Source"); } - sb.append(TString.wrap(")")); + sb.append(")"); return sb.toString(); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TString.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TString.java index 069be2bac..a615e7bf2 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TString.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TString.java @@ -30,7 +30,6 @@ import org.teavm.classlib.java.util.THashMap; import org.teavm.classlib.java.util.TLocale; import org.teavm.classlib.java.util.TMap; import org.teavm.classlib.java.util.regex.TPattern; -import org.teavm.interop.Unmanaged; public class TString extends TObject implements TSerializable, TComparable, TCharSequence { public static final TComparator CASE_INSENSITIVE_ORDER = (o1, o2) -> o1.compareToIgnoreCase(o2); @@ -425,8 +424,8 @@ public class TString extends TObject implements TSerializable, TComparable TArray.getLength(src) || destPos + length > TArray.getLength(dest)) { diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TThread.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TThread.java index 50d91f213..2e6fcf75f 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TThread.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TThread.java @@ -21,7 +21,7 @@ import org.teavm.platform.PlatformRunnable; import org.teavm.platform.async.AsyncCallback; 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 long nextId = 1; private static int activeCount = 1; @@ -33,7 +33,7 @@ public class TThread extends TObject implements TRunnable { private boolean interruptedFlag; public TThreadInterruptHandler interruptHandler; - private TString name; + private String name; private boolean alive = true; TRunnable target; @@ -41,7 +41,7 @@ public class TThread extends TObject implements TRunnable { this(null, null); } - public TThread(TString name) { + public TThread(String name) { this(null, name); } @@ -49,7 +49,7 @@ public class TThread extends TObject implements TRunnable { this(target, null); } - public TThread(TRunnable target, TString name) { + public TThread(TRunnable target, String name) { this.name = name; this.target = target; id = nextId++; @@ -94,7 +94,7 @@ public class TThread extends TObject implements TRunnable { return currentThread; } - public TString getName() { + public String getName() { return name; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TThrowable.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TThrowable.java index d584f5d4e..cb19834e0 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TThrowable.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TThrowable.java @@ -15,8 +15,8 @@ */ package org.teavm.classlib.java.lang; -import org.teavm.classlib.java.io.TPrintStream; -import org.teavm.classlib.java.io.TPrintWriter; +import java.io.PrintStream; +import java.io.PrintWriter; import org.teavm.classlib.java.util.TArrays; import org.teavm.interop.DelegateTo; import org.teavm.interop.Remove; @@ -27,7 +27,7 @@ import org.teavm.runtime.ExceptionHandling; @Superclass("java.lang.Object") public class TThrowable extends RuntimeException { private static final long serialVersionUID = 2026791432677149320L; - private TString message; + private String message; private TThrowable cause; private boolean suppressionEnabled; private boolean writableStackTrace; @@ -36,11 +36,11 @@ public class TThrowable extends RuntimeException { @SuppressWarnings("unused") @Rename("fakeInit") - protected TThrowable(TString message, TThrowable cause, boolean enableSuppression, boolean writableStackTrace) { + protected TThrowable(String message, TThrowable cause, boolean enableSuppression, boolean writableStackTrace) { } @Rename("") - public void init(TString message, TThrowable cause, boolean enableSuppression, boolean writableStackTrace) { + public void init(String message, TThrowable cause, boolean enableSuppression, boolean writableStackTrace) { if (writableStackTrace) { fillInStackTrace(); } @@ -62,11 +62,11 @@ public class TThrowable extends RuntimeException { } @Rename("fakeInit") - public TThrowable(@SuppressWarnings("unused") TString message) { + public TThrowable(@SuppressWarnings("unused") String message) { } @Rename("") - private void init(TString message) { + private void init(String message) { this.suppressionEnabled = true; this.writableStackTrace = true; fillInStackTrace(); @@ -75,11 +75,11 @@ public class TThrowable extends RuntimeException { @SuppressWarnings("unused") @Rename("fakeInit") - public TThrowable(TString message, TThrowable cause) { + public TThrowable(String message, TThrowable cause) { } @Rename("") - private void init(TString message, TThrowable cause) { + private void init(String message, TThrowable cause) { this.suppressionEnabled = true; this.writableStackTrace = true; fillInStackTrace(); @@ -114,13 +114,13 @@ public class TThrowable extends RuntimeException { } @Rename("getMessage") - public TString getMessage0() { + public String getMessage0() { return message; } @Rename("getLocalizedMessage") - public TString getLocalizedMessage0() { - return TString.wrap(getMessage()); + public String getLocalizedMessage0() { + return getMessage(); } @Remove @@ -132,17 +132,17 @@ public class TThrowable extends RuntimeException { } @Remove - public native TClass getClass0(); + public native Class getClass0(); @Remove - public native TString toString0(); + public native String toString0(); public TThrowable initCause(TThrowable cause) { if (this.cause != this && this.cause != null) { - throw new TIllegalStateException(TString.wrap("Cause already set")); + throw new IllegalStateException("Cause already set"); } if (cause == this) { - throw new TIllegalArgumentException(TString.wrap("Circular causation relation")); + throw new IllegalArgumentException("Circular causation relation"); } this.cause = cause; return this; @@ -150,38 +150,38 @@ public class TThrowable extends RuntimeException { @Override public void printStackTrace() { - printStackTrace(TSystem.err()); + printStackTrace(System.err); } - public void printStackTrace(TPrintStream stream) { - stream.print(TString.wrap(getClass().getName())); + public void printStackTrace(PrintStream stream) { + stream.print(getClass().getName()); String message = getMessage(); if (message != null) { - stream.print(TString.wrap(": " + getMessage())); + stream.print(": " + getMessage()); } stream.println(); if (stackTrace != null) { for (TStackTraceElement element : stackTrace) { - stream.print(TString.wrap(" at ")); + stream.print(" at "); stream.println(element); } } if (cause != null && cause != this) { - stream.print(TString.wrap("Caused by: ")); + stream.print("Caused by: "); cause.printStackTrace(stream); } } - public void printStackTrace(TPrintWriter stream) { - stream.println(TString.wrap(getClass().getName() + ": " + getMessage())); + public void printStackTrace(PrintWriter stream) { + stream.println(getClass().getName() + ": " + getMessage()); if (stackTrace != null) { for (TStackTraceElement element : stackTrace) { - stream.print(TString.wrap(" at ")); + stream.print(" at "); stream.println(element); } } if (cause != null && cause != this) { - stream.print(TString.wrap("Caused by: ")); + stream.print("Caused by: "); cause.printStackTrace(stream); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TUnsupportedOperationException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TUnsupportedOperationException.java index a03ba3b16..b699f1928 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TUnsupportedOperationException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TUnsupportedOperationException.java @@ -22,11 +22,11 @@ public class TUnsupportedOperationException extends TRuntimeException { super(); } - public TUnsupportedOperationException(TString message, TThrowable cause) { + public TUnsupportedOperationException(String message, TThrowable cause) { super(message, cause); } - public TUnsupportedOperationException(TString message) { + public TUnsupportedOperationException(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TVirtualMachineError.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TVirtualMachineError.java index a6e2fe542..ef928b0d2 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TVirtualMachineError.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TVirtualMachineError.java @@ -22,7 +22,7 @@ public class TVirtualMachineError extends TError { super(); } - public TVirtualMachineError(TString message) { + public TVirtualMachineError(String message) { super(message); } @@ -30,7 +30,7 @@ public class TVirtualMachineError extends TError { super(cause); } - public TVirtualMachineError(TString message, TThrowable cause) { + public TVirtualMachineError(String message, TThrowable cause) { super(message, cause); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TAnnotatedElement.java b/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TAnnotatedElement.java index 062d44295..f8e0f1739 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TAnnotatedElement.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TAnnotatedElement.java @@ -32,7 +32,7 @@ public interface TAnnotatedElement { TAnnotation[] getDeclaredAnnotations(); - default T[] getAnnotationsByType(TClass annotationClass) { + default T[] getAnnotationsByType(Class annotationClass) { List result = new ArrayList<>(); Object classAsObject = annotationClass; for (TAnnotation annot : getAnnotations()) { @@ -55,7 +55,7 @@ public interface TAnnotatedElement { return null; } - default T[] getDeclaredAnnotationsByType(TClass annotationClass) { + default T[] getDeclaredAnnotationsByType(Class annotationClass) { List result = new ArrayList<>(); Object classAsObject = annotationClass; for (TAnnotation annot : getDeclaredAnnotations()) { diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TArray.java b/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TArray.java index 308afde37..a49dc2622 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TArray.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TArray.java @@ -48,17 +48,17 @@ public final class TArray extends TObject { } @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) { throw new TNullPointerException(); } - if (componentType == TClass.wrap(void.class)) { + if (componentType == void.class) { throw new TIllegalArgumentException(); } if (length < 0) { throw new TNegativeArraySizeException(); } - return newInstanceImpl(componentType.getPlatformClass(), length); + return newInstanceImpl(((TClass) (Object) componentType).getPlatformClass(), length); } @GeneratedBy(ArrayNativeGenerator.class) diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TInvocationTargetException.java b/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TInvocationTargetException.java index 064c3e667..fab2f9267 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TInvocationTargetException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/reflect/TInvocationTargetException.java @@ -16,7 +16,6 @@ package org.teavm.classlib.java.lang.reflect; import org.teavm.classlib.java.lang.TReflectiveOperationException; -import org.teavm.classlib.java.lang.TString; import org.teavm.classlib.java.lang.TThrowable; public class TInvocationTargetException extends TReflectiveOperationException { @@ -27,7 +26,7 @@ public class TInvocationTargetException extends TReflectiveOperationException { super(null, target); } - public TInvocationTargetException(TThrowable target, TString s) { + public TInvocationTargetException(TThrowable target, String s) { super(s, target); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/net/TURI.java b/classlib/src/main/java/org/teavm/classlib/java/net/TURI.java index e86ab2dde..eb051875a 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/net/TURI.java +++ b/classlib/src/main/java/org/teavm/classlib/java/net/TURI.java @@ -15,6 +15,7 @@ */ package org.teavm.classlib.java.net; +import java.util.Objects; import org.teavm.classlib.java.io.TSerializable; import org.teavm.classlib.java.lang.*; @@ -22,22 +23,22 @@ import org.teavm.classlib.java.lang.*; * This class represents an instance of a URI as defined by RFC 2396. */ public final class TURI implements TComparable, TSerializable { - static final TString unreserved = TString.wrap("_-!.~\'()*"); - static final TString punct = TString.wrap(",;:$&+="); - static final TString reserved = TString.wrap(punct.toString() + "?/[]@"); - static final TString someLegal = TString.wrap(unreserved.toString() + punct.toString()); - static final TString queryLegal = TString.wrap(unreserved.toString() + reserved.toString() + "\\\""); - static final TString allLegal = TString.wrap(unreserved.toString() + reserved.toString()); - private TString string; - private transient TString scheme; - private transient TString schemespecificpart; - private transient TString authority; - private transient TString userinfo; - private transient TString host; + static final String unreserved = "_-!.~\'()*"; + static final String punct = ",;:$&+="; + static final String reserved = punct + "?/[]@"; + static final String someLegal = unreserved + punct; + static final String queryLegal = unreserved + reserved + "\\\""; + static final String allLegal = unreserved + reserved; + private String string; + private transient String scheme; + private transient String schemespecificpart; + private transient String authority; + private transient String userinfo; + private transient String host; private transient int port = -1; - private transient TString path; - private transient TString query; - private transient TString fragment; + private transient String path; + private transient String query; + private transient String fragment; private transient boolean opaque; private transient boolean absolute; private transient boolean serverAuthority; @@ -46,38 +47,12 @@ public final class TURI implements TComparable, TSerializable { private TURI() { } - /** - * Creates a new URI instance according to the given string {@code uri}. - * - * @param uri - * the textual URI representation to be parsed into a URI object. - * @throws TURISyntaxException - * if the given string {@code uri} doesn't fit to the - * specification RFC2396 or could not be parsed correctly. - */ - public TURI(TString uri) throws TURISyntaxException { + public TURI(String uri) throws TURISyntaxException { new Helper().parseURI(uri, false); } - /** - * Creates a new URI instance using the given arguments. This constructor - * first creates a temporary URI string from the given components. This - * string will be parsed later on to create the URI instance. - *

- * {@code [scheme:]scheme-specific-part[#fragment]} - * - * @param scheme - * the scheme part of the URI. - * @param ssp - * the scheme-specific-part of the URI. - * @param frag - * the fragment part of the URI. - * @throws TURISyntaxException - * if the temporary created string doesn't fit to the - * specification RFC2396 or could not be parsed correctly. - */ - public TURI(TString scheme, TString ssp, TString frag) throws TURISyntaxException { - TStringBuilder uri = new TStringBuilder(); + public TURI(String scheme, String ssp, String frag) throws TURISyntaxException { + StringBuilder uri = new StringBuilder(); if (scheme != null) { uri.append(scheme); uri.append(':'); @@ -92,46 +67,19 @@ public final class TURI implements TComparable, TSerializable { uri.append(quoteComponent(frag, allLegal)); } - new Helper().parseURI(TString.wrap(uri.toString()), false); + new Helper().parseURI(uri.toString(), false); } - /** - * Creates a new URI instance using the given arguments. This constructor - * first creates a temporary URI string from the given components. This - * string will be parsed later on to create the URI instance. - *

- * {@code [scheme:][user-info@]host[:port][path][?query][#fragment]} - * - * @param scheme - * the scheme part of the URI. - * @param userinfo - * the user information of the URI for authentication and - * authorization. - * @param host - * the host name of the URI. - * @param port - * the port number of the URI. - * @param path - * the path to the resource on the host. - * @param query - * the query part of the URI to specify parameters for the - * resource. - * @param fragment - * the fragment part of the URI. - * @throws TURISyntaxException - * if the temporary created string doesn't fit to the - * specification RFC2396 or could not be parsed correctly. - */ - public TURI(TString scheme, TString userinfo, TString host, int port, TString path, TString query, - TString fragment) throws TURISyntaxException { + public TURI(String scheme, String userinfo, String host, int port, String path, String query, + String fragment) throws TURISyntaxException { if (scheme == null && userinfo == null && host == null && path == null && query == null && fragment == null) { - this.path = TString.wrap(""); + this.path = ""; return; } if (scheme != null && path != null && path.length() > 0 && path.charAt(0) != '/') { - throw new TURISyntaxException(path, TString.wrap("")); + throw new TURISyntaxException(path, ""); } TStringBuilder uri = new TStringBuilder(); @@ -141,7 +89,7 @@ public final class TURI implements TComparable, TSerializable { } if (userinfo != null || host != null || port != -1) { - uri.append(TString.wrap("//")); + uri.append("//"); } if (userinfo != null) { @@ -154,7 +102,7 @@ public final class TURI implements TComparable, TSerializable { // check for ipv6 addresses that hasn't been enclosed // in square brackets if (host.indexOf(':') != -1 && host.indexOf(']') == -1 && host.indexOf('[') == -1) { - host = TString.wrap("[" + host.toString() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + host = "[" + host + "]"; } uri.append(host); } @@ -166,7 +114,7 @@ public final class TURI implements TComparable, TSerializable { if (path != null) { // QUOTE ILLEGAL CHARS - uri.append(quoteComponent(path, TString.wrap("/@" + someLegal.toString()))); //$NON-NLS-1$ + uri.append(quoteComponent(path, "/@" + someLegal)); } if (query != null) { @@ -181,58 +129,17 @@ public final class TURI implements TComparable, TSerializable { uri.append(quoteComponent(fragment, allLegal)); } - new Helper().parseURI(TString.wrap(uri.toString()), true); + new Helper().parseURI(uri.toString(), true); } - /** - * Creates a new URI instance using the given arguments. This constructor - * first creates a temporary URI string from the given components. This - * string will be parsed later on to create the URI instance. - *

- * {@code [scheme:]host[path][#fragment]} - * - * @param scheme - * the scheme part of the URI. - * @param host - * the host name of the URI. - * @param path - * the path to the resource on the host. - * @param fragment - * the fragment part of the URI. - * @throws TURISyntaxException - * if the temporary created string doesn't fit to the - * specification RFC2396 or could not be parsed correctly. - */ - public TURI(TString scheme, TString host, TString path, TString fragment) throws TURISyntaxException { + public TURI(String scheme, String host, String path, String fragment) throws TURISyntaxException { this(scheme, null, host, -1, path, null, fragment); } - /** - * Creates a new URI instance using the given arguments. This constructor - * first creates a temporary URI string from the given components. This - * string will be parsed later on to create the URI instance. - *

- * {@code [scheme:][//authority][path][?query][#fragment]} - * - * @param scheme - * the scheme part of the URI. - * @param authority - * the authority part of the URI. - * @param path - * the path to the resource on the host. - * @param query - * the query part of the URI to specify parameters for the - * resource. - * @param fragment - * the fragment part of the URI. - * @throws TURISyntaxException - * if the temporary created string doesn't fit to the - * specification RFC2396 or could not be parsed correctly. - */ - public TURI(TString scheme, TString authority, TString path, TString query, TString fragment) + public TURI(String scheme, String authority, String path, String query, String fragment) throws TURISyntaxException { if (scheme != null && path != null && path.length() > 0 && path.charAt(0) != '/') { - throw new TURISyntaxException(path, TString.wrap("")); + throw new TURISyntaxException(path, ""); } TStringBuilder uri = new TStringBuilder(); @@ -241,14 +148,14 @@ public final class TURI implements TComparable, TSerializable { uri.append(':'); } if (authority != null) { - uri.append(TString.wrap("//")); //$NON-NLS-1$ + uri.append("//"); // QUOTE ILLEGAL CHARS - uri.append(quoteComponent(authority, TString.wrap("@[]" + someLegal.toString()))); //$NON-NLS-1$ + uri.append(quoteComponent(authority, "@[]" + someLegal)); } if (path != null) { // QUOTE ILLEGAL CHARS - uri.append(quoteComponent(path, TString.wrap("/@" + someLegal.toString()))); //$NON-NLS-1$ + uri.append(quoteComponent(path, "/@" + someLegal)); } if (query != null) { // QUOTE ILLEGAL CHARS @@ -261,14 +168,14 @@ public final class TURI implements TComparable, TSerializable { uri.append(quoteComponent(fragment, allLegal)); } - new Helper().parseURI(TString.wrap(uri.toString()), false); + new Helper().parseURI(uri.toString(), false); } private class Helper { - private void parseURI(TString uri, boolean forceServer) + private void parseURI(String uri, boolean forceServer) throws TURISyntaxException { - TString temp = uri; + String temp = uri; // assign uri string to the input value per spec string = uri; int index; @@ -300,12 +207,12 @@ public final class TURI implements TComparable, TSerializable { absolute = true; scheme = temp.substring(0, index); if (scheme.length() == 0) { - throw new TURISyntaxException(uri, TString.wrap("")); + throw new TURISyntaxException(uri, ""); } validateScheme(uri, scheme, 0); schemespecificpart = temp.substring(index + 1); if (schemespecificpart.length() == 0) { - throw new TURISyntaxException(uri, TString.wrap("")); + throw new TURISyntaxException(uri, ""); } } else { absolute = false; @@ -327,7 +234,7 @@ public final class TURI implements TComparable, TSerializable { } // Authority and Path - if (temp.startsWith(TString.wrap("//"))) { + if (temp.startsWith("//")) { index = temp.indexOf('/', 2); if (index != -1) { authority = temp.substring(2, index); @@ -336,10 +243,10 @@ public final class TURI implements TComparable, TSerializable { authority = temp.substring(2); if (authority.length() == 0 && query == null && fragment == null) { - throw new TURISyntaxException(uri, TString.wrap("")); + throw new TURISyntaxException(uri, ""); } - path = TString.wrap(""); + path = ""; // nothing left, so path is empty (not null, path should // never be null) } @@ -369,63 +276,63 @@ public final class TURI implements TComparable, TSerializable { parseAuthority(forceServer); } - private void validateScheme(TString uri, TString scheme, int index) throws TURISyntaxException { + private void validateScheme(String uri, String scheme, int index) throws TURISyntaxException { // first char needs to be an alpha char char ch = scheme.charAt(0); if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) { - throw new TURISyntaxException(uri, TString.wrap(""), 0); + throw new TURISyntaxException(uri, "", 0); } try { - TURIEncoderDecoder.validateSimple(scheme, TString.wrap("+-.")); + TURIEncoderDecoder.validateSimple(scheme, "+-."); } catch (TURISyntaxException e) { - throw new TURISyntaxException(uri, TString.wrap(""), index + e.getIndex()); + throw new TURISyntaxException(uri, "", index + e.getIndex()); } } - private void validateSsp(TString uri, TString ssp, int index) + private void validateSsp(String uri, String ssp, int index) throws TURISyntaxException { try { TURIEncoderDecoder.validate(ssp, allLegal); } catch (TURISyntaxException e) { - throw new TURISyntaxException(uri, TString.wrap(""), index + e.getIndex()); + throw new TURISyntaxException(uri, "", index + e.getIndex()); } } - private void validateAuthority(TString uri, TString authority, int index) + private void validateAuthority(String uri, String authority, int index) throws TURISyntaxException { try { - TURIEncoderDecoder.validate(authority, TString.wrap("@[]" + someLegal.toString())); + TURIEncoderDecoder.validate(authority, "@[]" + someLegal); } catch (TURISyntaxException e) { - throw new TURISyntaxException(uri, TString.wrap(""), index + e.getIndex()); + throw new TURISyntaxException(uri, "", index + e.getIndex()); } } - private void validatePath(TString uri, TString path, int index) + private void validatePath(String uri, String path, int index) throws TURISyntaxException { try { - TURIEncoderDecoder.validate(path, TString.wrap("/@" + someLegal.toString())); //$NON-NLS-1$ + TURIEncoderDecoder.validate(path, "/@" + someLegal); } catch (TURISyntaxException e) { - throw new TURISyntaxException(uri, TString.wrap(""), index + e.getIndex()); + throw new TURISyntaxException(uri, "", index + e.getIndex()); } } - private void validateQuery(TString uri, TString query, int index) + private void validateQuery(String uri, String query, int index) throws TURISyntaxException { try { TURIEncoderDecoder.validate(query, queryLegal); } catch (TURISyntaxException e) { - throw new TURISyntaxException(uri, TString.wrap(""), index + e.getIndex()); + throw new TURISyntaxException(uri, "", index + e.getIndex()); } } - private void validateFragment(TString uri, TString fragment, int index) + private void validateFragment(String uri, String fragment, int index) throws TURISyntaxException { try { TURIEncoderDecoder.validate(fragment, allLegal); } catch (TURISyntaxException e) { - throw new TURISyntaxException(uri, TString.wrap(""), index + e.getIndex()); + throw new TURISyntaxException(uri, "", index + e.getIndex()); } } @@ -446,9 +353,9 @@ public final class TURI implements TComparable, TSerializable { return; } - TString temp; - TString tempUserinfo = null; - TString tempHost = null; + String temp; + String tempUserinfo = null; + String tempHost; int index; int hostindex = 0; int tempPort = -1; @@ -475,13 +382,13 @@ public final class TURI implements TComparable, TSerializable { tempPort = TInteger.parseInt(temp.substring(index + 1)); if (tempPort < 0) { if (forceServer) { - throw new TURISyntaxException(authority, TString.wrap(""), hostindex + index + 1); + throw new TURISyntaxException(authority, "", hostindex + index + 1); } return; } } catch (TNumberFormatException e) { if (forceServer) { - throw new TURISyntaxException(authority, TString.wrap(""), hostindex + index + 1); + throw new TURISyntaxException(authority, "", hostindex + index + 1); } return; } @@ -490,9 +397,9 @@ public final class TURI implements TComparable, TSerializable { tempHost = temp; } - if (tempHost.equals(TString.wrap(""))) { + if (tempHost.equals("")) { if (forceServer) { - throw new TURISyntaxException(authority, TString.wrap(""), hostindex); + throw new TURISyntaxException(authority, "", hostindex); } return; } @@ -509,12 +416,12 @@ public final class TURI implements TComparable, TSerializable { serverAuthority = true; } - private void validateUserinfo(TString uri, TString userinfo, int index) + private void validateUserinfo(String uri, String userinfo, int index) throws TURISyntaxException { for (int i = 0; i < userinfo.length(); i++) { char ch = userinfo.charAt(i); if (ch == ']' || ch == '[') { - throw new TURISyntaxException(uri, TString.wrap(""), index + i); + throw new TURISyntaxException(uri, "", index + i); } } } @@ -523,15 +430,15 @@ public final class TURI implements TComparable, TSerializable { * distinguish between IPv4, IPv6, domain name and validate it based on * its type */ - private boolean isValidHost(boolean forceServer, TString host) + private boolean isValidHost(boolean forceServer, String host) throws TURISyntaxException { if (host.charAt(0) == '[') { // ipv6 address if (host.charAt(host.length() - 1) != ']') { - throw new TURISyntaxException(host, TString.wrap(""), 0); + throw new TURISyntaxException(host, "", 0); } if (!isValidIP6Address(host)) { - throw new TURISyntaxException(host, TString.wrap("")); + throw new TURISyntaxException(host, ""); } return true; } @@ -539,7 +446,7 @@ public final class TURI implements TComparable, TSerializable { // '[' and ']' can only be the first char and last char // of the host name if (host.indexOf('[') != -1 || host.indexOf(']') != -1) { - throw new TURISyntaxException(host, TString.wrap(""), 0); + throw new TURISyntaxException(host, "", 0); } int index = host.lastIndexOf('.'); @@ -550,7 +457,7 @@ public final class TURI implements TComparable, TSerializable { return true; } if (forceServer) { - throw new TURISyntaxException(host, TString.wrap(""), 0); + throw new TURISyntaxException(host, "", 0); } return false; } @@ -560,14 +467,14 @@ public final class TURI implements TComparable, TSerializable { return true; } if (forceServer) { - throw new TURISyntaxException(host, TString.wrap(""), 0); + throw new TURISyntaxException(host, "", 0); } return false; } - private boolean isValidDomainName(TString host) { + private boolean isValidDomainName(String host) { try { - TURIEncoderDecoder.validateSimple(host, TString.wrap("-.")); + TURIEncoderDecoder.validateSimple(host, "-."); } catch (TURISyntaxException e) { return false; } @@ -588,17 +495,15 @@ public final class TURI implements TComparable, TSerializable { return false; } - TString label = host.substring(index); + String label = host.substring(index); if (!label.equals(host)) { char ch = label.charAt(0); - if (ch >= '0' && ch <= '9') { - return false; - } + return ch < '0' || ch > '9'; } return true; } - private boolean isValidIPv4Address(TString host) { + private boolean isValidIPv4Address(String host) { int index; int index2; try { @@ -628,12 +533,12 @@ public final class TURI implements TComparable, TSerializable { return true; } - private boolean isValidIP6Address(TString ipAddress) { + private boolean isValidIP6Address(String ipAddress) { int length = ipAddress.length(); boolean doubleColon = false; int numberOfColons = 0; int numberOfPeriods = 0; - TString word = TString.wrap(""); + String word = ""; char c = 0; char prevChar = 0; int offset = 0; // offset for [] ip addresses @@ -696,7 +601,7 @@ public final class TURI implements TComparable, TSerializable { && ipAddress.charAt(1 + offset) != ':') { return false; } - word = TString.wrap(""); + word = ""; break; case ':': @@ -713,7 +618,7 @@ public final class TURI implements TComparable, TSerializable { } doubleColon = true; } - word = TString.wrap(""); + word = ""; break; default: @@ -729,9 +634,7 @@ public final class TURI implements TComparable, TSerializable { // Check if we have an IPv4 ending if (numberOfPeriods > 0) { - if (numberOfPeriods != 3 || !isValidIP4Word(word)) { - return false; - } + return numberOfPeriods == 3 && isValidIP4Word(word); } else { // If we're at then end and we haven't had 7 colons then there // is a problem unless we encountered a doubleColon @@ -742,16 +645,12 @@ public final class TURI implements TComparable, TSerializable { // If we have an empty word at the end, it means we ended in // either a : or a . // If we did not end in :: then this is invalid - if (word.isEmpty() && ipAddress.charAt(length - 1 - offset) != ':' - && ipAddress.charAt(length - 2 - offset) != ':') { - return false; - } + return !word.isEmpty() || ipAddress.charAt(length - 1 - offset) == ':' + || ipAddress.charAt(length - 2 - offset) == ':'; } - - return true; } - private boolean isValidIP4Word(TString word) { + private boolean isValidIP4Word(String word) { char c; if (word.length() < 1 || word.length() > 3) { return false; @@ -762,10 +661,7 @@ public final class TURI implements TComparable, TSerializable { return false; } } - if (TInteger.parseInt(word) > 255) { - return false; - } - return true; + return TInteger.parseInt(word) <= 255; } private boolean isValidHexChar(char c) { @@ -775,14 +671,7 @@ public final class TURI implements TComparable, TSerializable { } } - /* - * Quote illegal chars for each component, but not the others - * - * @param component java.lang.String the component to be converted @param - * legalset java.lang.String the legal character set allowed in the - * component s @return java.lang.String the converted string - */ - private TString quoteComponent(TString component, TString legalset) { + private String quoteComponent(String component, String legalset) { /* * Use a different encoder than URLEncoder since: 1. chars like "/", * "#", "@" etc needs to be preserved instead of being encoded, 2. @@ -792,21 +681,6 @@ public final class TURI implements TComparable, TSerializable { return TURIEncoderDecoder.quoteIllegal(component, legalset); } - /** - * Compares this URI with the given argument {@code uri}. This method will - * return a negative value if this URI instance is less than the given - * argument and a positive value if this URI instance is greater than the - * given argument. The return value {@code 0} indicates that the two - * instances represent the same URI. To define the order the single parts of - * the URI are compared with each other. String components will be orderer - * in the natural case-sensitive way. A hierarchical URI is less than an - * opaque URI and if one part is {@code null} the URI with the undefined - * part is less than the other one. - * - * @param uri - * the URI this instance has to compare with. - * @return the value representing the order of the two instances. - */ @Override public int compareTo(TURI uri) { int ret = 0; @@ -920,8 +794,8 @@ public final class TURI implements TComparable, TSerializable { * the string which has to be parsed to create the URI instance. * @return the created instance representing the given URI. */ - public static TURI create(TString uri) { - TURI result = null; + public static TURI create(String uri) { + TURI result; try { result = new TURI(uri); } catch (TURISyntaxException e) { @@ -951,7 +825,7 @@ public final class TURI implements TComparable, TSerializable { * Takes a string that may contain hex sequences like %F1 or %2b and * converts the hex values following the '%' to lowercase */ - private TString convertHexToLowerCase(TString s) { + private String convertHexToLowerCase(String s) { TStringBuilder result = new TStringBuilder(); if (s.indexOf('%') == -1) { return s; @@ -959,13 +833,17 @@ public final class TURI implements TComparable, TSerializable { int index = 0; int previndex = 0; - while ((index = s.indexOf('%', previndex)) != -1) { + while (true) { + index = s.indexOf('%', previndex); + if (index == -1) { + break; + } result.append(s.substring(previndex, index + 1)); result.append(s.substring(index + 1, index + 3).toLowerCase()); index += 3; previndex = index; } - return TString.wrap(result.toString()); + return result.toString(); } /* @@ -973,7 +851,7 @@ public final class TURI implements TComparable, TSerializable { * compares them, ignoring case for the hex values. Hex values must always * occur in pairs as above */ - private boolean equalsHexCaseInsensitive(TString first, TString second) { + private boolean equalsHexCaseInsensitive(String first, String second) { if (first.indexOf('%') != second.indexOf('%')) { return first.equals(second); } @@ -1005,16 +883,6 @@ public final class TURI implements TComparable, TSerializable { return first.substring(previndex).equals(second.substring(previndex)); } - /** - * Compares this URI instance with the given argument {@code o} and - * determines if both are equal. Two URI instances are equal if all single - * parts are identical in their meaning. - * - * @param o - * the URI this instance has to be compared with. - * @return {@code true} if both URI instances point to the same resource, - * {@code false} otherwise. - */ @Override public boolean equals(Object o) { if (!(o instanceof TURI)) { @@ -1096,146 +964,66 @@ public final class TURI implements TComparable, TSerializable { } } - /** - * Gets the decoded authority part of this URI. - * - * @return the decoded authority part or {@code null} if undefined. - */ - public TString getAuthority() { + public String getAuthority() { return decode(authority); } - /** - * Gets the decoded fragment part of this URI. - * - * @return the decoded fragment part or {@code null} if undefined. - */ - public TString getFragment() { + public String getFragment() { return decode(fragment); } - /** - * Gets the host part of this URI. - * - * @return the host part or {@code null} if undefined. - */ - public TString getHost() { + public String getHost() { return host; } - /** - * Gets the decoded path part of this URI. - * - * @return the decoded path part or {@code null} if undefined. - */ - public TString getPath() { + public String getPath() { return decode(path); } - /** - * Gets the port number of this URI. - * - * @return the port number or {@code -1} if undefined. - */ public int getPort() { return port; } - /** - * Gets the decoded query part of this URI. - * - * @return the decoded query part or {@code null} if undefined. - */ - public TString getQuery() { + public String getQuery() { return decode(query); } - /** - * Gets the authority part of this URI in raw form. - * - * @return the encoded authority part or {@code null} if undefined. - */ - public TString getRawAuthority() { + public String getRawAuthority() { return authority; } - /** - * Gets the fragment part of this URI in raw form. - * - * @return the encoded fragment part or {@code null} if undefined. - */ - public TString getRawFragment() { + public String getRawFragment() { return fragment; } - /** - * Gets the path part of this URI in raw form. - * - * @return the encoded path part or {@code null} if undefined. - */ - public TString getRawPath() { + public String getRawPath() { return path; } - /** - * Gets the query part of this URI in raw form. - * - * @return the encoded query part or {@code null} if undefined. - */ - public TString getRawQuery() { + public String getRawQuery() { return query; } - /** - * Gets the scheme-specific part of this URI in raw form. - * - * @return the encoded scheme-specific part or {@code null} if undefined. - */ - public TString getRawSchemeSpecificPart() { + public String getRawSchemeSpecificPart() { return schemespecificpart; } - /** - * Gets the user-info part of this URI in raw form. - * - * @return the encoded user-info part or {@code null} if undefined. - */ - public TString getRawUserInfo() { + public String getRawUserInfo() { return userinfo; } - /** - * Gets the scheme part of this URI. - * - * @return the scheme part or {@code null} if undefined. - */ - public TString getScheme() { + public String getScheme() { return scheme; } - /** - * Gets the decoded scheme-specific part of this URI. - * - * @return the decoded scheme-specific part or {@code null} if undefined. - */ - public TString getSchemeSpecificPart() { + public String getSchemeSpecificPart() { return decode(schemespecificpart); } - /** - * Gets the decoded user-info part of this URI. - * - * @return the decoded user-info part or {@code null} if undefined. - */ - public TString getUserInfo() { + public String getUserInfo() { return decode(userinfo); } - /** - * Gets the hashcode value of this URI instance. - * - * @return the appropriate hashcode value. - */ @Override public int hashCode() { if (hash == -1) { @@ -1269,7 +1057,7 @@ public final class TURI implements TComparable, TSerializable { /* * normalize path, and return the resulting string */ - private TString normalize(TString path) { + private String normalize(String path) { // count the number of '/'s, to determine number of segments int index = -1; int pathlen = path.length(); @@ -1277,20 +1065,28 @@ public final class TURI implements TComparable, TSerializable { if (pathlen > 0 && path.charAt(0) != '/') { size++; } - while ((index = path.indexOf('/', index + 1)) != -1) { + while (true) { + index = path.indexOf('/', index + 1); + if (index == -1) { + break; + } if (index + 1 < pathlen && path.charAt(index + 1) != '/') { size++; } } - TString[] seglist = new TString[size]; + String[] seglist = new String[size]; boolean[] include = new boolean[size]; // break the path into segments and store in the list int current = 0; int index2 = 0; index = (pathlen > 0 && path.charAt(0) == '/') ? 1 : 0; - while ((index2 = path.indexOf('/', index + 1)) != -1) { + while (index2 != -1) { + index2 = path.indexOf('/', index + 1); + if (index2 == -1) { + break; + } seglist[current++] = path.substring(index, index2); index = index2 + 1; } @@ -1304,7 +1100,7 @@ public final class TURI implements TComparable, TSerializable { // determine which segments get included in the normalized path for (int i = 0; i < size; i++) { include[i] = true; - if (seglist[i].equals(TString.wrap(".."))) { //$NON-NLS-1$ + if (seglist[i].equals("..")) { int remove = i - 1; // search back to find a segment to remove, if possible while (remove > -1 && !include[remove]) { @@ -1312,18 +1108,18 @@ public final class TURI implements TComparable, TSerializable { } // if we find a segment to remove, remove it and the ".." // segment - if (remove > -1 && !seglist[remove].equals(TString.wrap(".."))) { //$NON-NLS-1$ + if (remove > -1 && !seglist[remove].equals("..")) { include[remove] = false; include[i] = false; } - } else if (seglist[i].equals(TString.wrap("."))) { //$NON-NLS-1$ + } else if (seglist[i].equals(".")) { include[i] = false; } } // put the path back together TStringBuilder newpath = new TStringBuilder(); - if (path.startsWith(TString.wrap("/"))) { + if (path.startsWith("/")) { newpath.append('/'); } @@ -1337,34 +1133,28 @@ public final class TURI implements TComparable, TSerializable { // if we used at least one segment and the path previously ended with // a slash and the last segment is still used, then delete the extra // trailing '/' - if (!path.endsWith(TString.wrap("/")) && seglist.length > 0 && include[seglist.length - 1]) { + if (!path.endsWith("/") && seglist.length > 0 && include[seglist.length - 1]) { newpath.deleteCharAt(newpath.length() - 1); } - TString result = TString.wrap(newpath.toString()); + String result = newpath.toString(); // check for a ':' in the first segment if one exists, // prepend "./" to normalize index = result.indexOf(':'); index2 = result.indexOf('/'); if (index != -1 && (index < index2 || index2 == -1)) { - newpath.insert(0, TString.wrap("./")); - result = TString.wrap(newpath.toString()); + newpath.insert(0, "./"); + result = newpath.toString(); } return result; } - /** - * Normalizes the path part of this URI. - * - * @return an URI object which represents this instance with a normalized - * path. - */ public TURI normalize() { if (opaque) { return this; } - TString normalizedPath = normalize(path); + String normalizedPath = normalize(path); // if the path is already normalized, return this if (path.equals(normalizedPath)) { return this; @@ -1377,16 +1167,6 @@ public final class TURI implements TComparable, TSerializable { return result; } - /** - * Tries to parse the authority component of this URI to divide it into the - * host, port, and user-info. If this URI is already determined as a - * ServerAuthority this instance will be returned without changes. - * - * @return this instance with the components of the parsed server authority. - * @throws TURISyntaxException - * if the authority part could not be parsed as a server-based - * authority. - */ public TURI parseServerAuthority() throws TURISyntaxException { if (!serverAuthority) { new Helper().parseAuthority(true); @@ -1394,32 +1174,22 @@ public final class TURI implements TComparable, TSerializable { return this; } - /** - * Makes the given URI {@code relative} to a relative URI against the URI - * represented by this instance. - * - * @param relative - * the URI which has to be relativized against this URI. - * @return the relative URI. - */ public TURI relativize(TURI relative) { if (relative.opaque || opaque) { return relative; } - if (scheme == null ? relative.scheme != null : !scheme - .equals(relative.scheme)) { + if (!Objects.equals(scheme, relative.scheme)) { return relative; } - if (authority == null ? relative.authority != null : !authority - .equals(relative.authority)) { + if (!Objects.equals(authority, relative.authority)) { return relative; } // normalize both paths - TString thisPath = normalize(path); - TString relativePath = normalize(relative.path); + String thisPath = normalize(path); + String relativePath = normalize(relative.path); /* * if the paths aren't equal, then we need to determine if this URI's @@ -1427,8 +1197,8 @@ public final class TURI implements TComparable, TSerializable { */ if (!thisPath.equals(relativePath)) { // if this URI's path doesn't end in a '/', add one - if (!thisPath.endsWith(TString.wrap("/"))) { //$NON-NLS-1$ - thisPath = TString.wrap(thisPath.toString()).concat(TString.valueOf('/')); + if (!thisPath.endsWith("/")) { + thisPath = thisPath + '/'; } /* * if the relative URI's path doesn't start with this URI's path, @@ -1449,21 +1219,13 @@ public final class TURI implements TComparable, TSerializable { return result; } - /** - * Resolves the given URI {@code relative} against the URI represented by - * this instance. - * - * @param relative - * the URI which has to be resolved against this URI. - * @return the resolved URI. - */ public TURI resolve(TURI relative) { if (relative.absolute || opaque) { return relative; } TURI result; - if (relative.path.equals(TString.wrap("")) && relative.scheme == null //$NON-NLS-1$ + if (relative.path.equals("") && relative.scheme == null //$NON-NLS-1$ && relative.authority == null && relative.query == null && relative.fragment != null) { // if the relative URI only consists of fragment, @@ -1491,7 +1253,7 @@ public final class TURI implements TComparable, TSerializable { result = duplicate(); result.fragment = relative.fragment; result.query = relative.query; - if (relative.path.startsWith(TString.wrap("/"))) { + if (relative.path.startsWith("/")) { result.path = relative.path; } else { // resolve a relative reference @@ -1505,52 +1267,28 @@ public final class TURI implements TComparable, TSerializable { return result; } - /** - * Helper method used to re-calculate the scheme specific part of the - * resolved or normalized URIs - */ private void setSchemeSpecificPart() { // ssp = [//authority][path][?query] TStringBuilder ssp = new TStringBuilder(); if (authority != null) { - ssp.append(TString.wrap("//")).append(authority); + ssp.append("//").append(authority); } if (path != null) { ssp.append(path); } if (query != null) { - ssp.append(TString.wrap("?")).append(query); + ssp.append("?").append(query); } - schemespecificpart = TString.wrap(ssp.toString()); + schemespecificpart = ssp.toString(); // reset string, so that it can be re-calculated correctly when asked. string = null; } - /** - * Creates a new URI instance by parsing the given string {@code relative} - * and resolves the created URI against the URI represented by this - * instance. - * - * @param relative - * the given string to create the new URI instance which has to - * be resolved later on. - * @return the created and resolved URI. - */ - public TURI resolve(TString relative) { + public TURI resolve(String relative) { return resolve(create(relative)); } - /* - * Encode unicode chars that are not part of US-ASCII char set into the - * escaped form - * - * i.e. The Euro currency symbol is encoded as "%E2%82%AC". - * - * @param component java.lang.String the component to be converted @param - * legalset java.lang.String the legal character set allowed in the - * component s @return java.lang.String the converted string - */ - private TString encodeOthers(TString s) { + private String encodeOthers(String s) { /* * Use a different encoder than URLEncoder since: 1. chars like "/", * "#", "@" etc needs to be preserved instead of being encoded, 2. @@ -1560,7 +1298,7 @@ public final class TURI implements TComparable, TSerializable { return TURIEncoderDecoder.encodeOthers(s); } - private TString decode(TString s) { + private String decode(String s) { if (s == null) { return s; } @@ -1568,21 +1306,10 @@ public final class TURI implements TComparable, TSerializable { return TURIEncoderDecoder.decode(s); } - /** - * Returns the textual string representation of this URI instance using the - * US-ASCII encoding. - * - * @return the US-ASCII string representation of this URI. - */ - public TString toASCIIString() { - return encodeOthers(TString.wrap(toString())); + public String toASCIIString() { + return encodeOthers(toString()); } - /** - * Returns the textual string representation of this URI instance. - * - * @return the textual string representation of this URI. - */ @Override public String toString() { if (string == null) { @@ -1595,7 +1322,7 @@ public final class TURI implements TComparable, TSerializable { result.append(schemespecificpart); } else { if (authority != null) { - result.append(TString.wrap("//")); + result.append("//"); result.append(authority); } @@ -1614,9 +1341,9 @@ public final class TURI implements TComparable, TSerializable { result.append(fragment); } - string = TString.wrap(result.toString()); + string = result.toString(); } - return string.toString(); + return string; } /* @@ -1624,7 +1351,7 @@ public final class TURI implements TComparable, TSerializable { * toString() method. But this method converts scheme and host to lowercase, * and converts escaped octets to lowercase. */ - private TString getHashString() { + private String getHashString() { TStringBuilder result = new TStringBuilder(); if (scheme != null) { result.append(scheme.toLowerCase()); @@ -1634,12 +1361,12 @@ public final class TURI implements TComparable, TSerializable { result.append(schemespecificpart); } else { if (authority != null) { - result.append(TString.wrap("//")); + result.append("//"); if (host == null) { result.append(authority); } else { if (userinfo != null) { - result.append(userinfo).append(TString.wrap("@")); + result.append(userinfo).append("@"); } result.append(host.toLowerCase()); if (port != -1) { @@ -1662,7 +1389,7 @@ public final class TURI implements TComparable, TSerializable { result.append(fragment); } - return convertHexToLowerCase(TString.wrap(result.toString())); + return convertHexToLowerCase(result.toString()); } public TURL toURL() throws TMalformedURLException { diff --git a/classlib/src/main/java/org/teavm/classlib/java/net/TURIEncoderDecoder.java b/classlib/src/main/java/org/teavm/classlib/java/net/TURIEncoderDecoder.java index 4eb3d3ac8..0200f1780 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/net/TURIEncoderDecoder.java +++ b/classlib/src/main/java/org/teavm/classlib/java/net/TURIEncoderDecoder.java @@ -21,44 +21,24 @@ import org.teavm.classlib.java.lang.TIllegalArgumentException; import org.teavm.classlib.java.lang.TString; 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 { - static final TString digits = TString.wrap("0123456789ABCDEF"); + static final String digits = "0123456789ABCDEF"; private TURIEncoderDecoder() { } - /** - * 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) - *

- * 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 { + static void validate(String s, String legal) throws TURISyntaxException { for (int i = 0; i < s.length();) { char ch = s.charAt(i); if (ch == '%') { do { 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 d2 = TCharacter.digit(s.charAt(i + 2), 16); if (d1 == -1 || d2 == -1) { - throw new TURISyntaxException(s, TString.wrap(""), i); + throw new TURISyntaxException(s, "", i); } i += 3; @@ -69,7 +49,7 @@ class TURIEncoderDecoder { if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || legal.indexOf(ch) > -1 || (ch > 127 && !isSpaceChar(ch) && !TCharacter.isISOControl(ch)))) { - throw new TURISyntaxException(s, TString.wrap(""), i); //$NON-NLS-1$ + throw new TURISyntaxException(s, "", i); } i++; } @@ -85,38 +65,19 @@ class TURIEncoderDecoder { } } - static void validateSimple(TString s, TString legal) + static void validateSimple(String s, String legal) throws TURISyntaxException { for (int i = 0; i < s.length();) { char ch = s.charAt(i); if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || legal.indexOf(ch) > -1)) { - throw new TURISyntaxException(s, TString.wrap(""), i); //$NON-NLS-1$ + throw new TURISyntaxException(s, "", i); } i++; } } - /** - * All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') - * and legal characters are converted into their hexidecimal value prepended - * by '%'. - *

- * 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. - *

- * 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) { + static String quoteIllegal(String s, String legal) { TStringBuilder buf = new TStringBuilder(); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); @@ -135,23 +96,10 @@ class TURIEncoderDecoder { } } } - return TString.wrap(buf.toString()); + return buf.toString(); } - /** - * 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 '%'. - *

- * For example: Euro currency symbol -> "%E2%82%AC". - *

- * 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) { + static String encodeOthers(String s) { TStringBuilder buf = new TStringBuilder(); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); @@ -166,27 +114,10 @@ class TURIEncoderDecoder { } } } - return TString.wrap(buf.toString()); + return buf.toString(); } - /** - * 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. - *

- *'%' and two following hex digit characters are converted to the - * equivalent byte value. All other characters are passed through - * unmodified. - *

- * e.g. "A%20B%20C %24%25" -> "A B C $%" - *

- * 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) { - + static String decode(String s) { TStringBuilder result = new TStringBuilder(); TByteArrayOutputStream out = new TByteArrayOutputStream(); for (int i = 0; i < s.length();) { @@ -205,13 +136,13 @@ class TURIEncoderDecoder { out.write((byte) ((d1 << 4) + d2)); i += 3; } while (i < s.length() && s.charAt(i) == '%'); - result.append(TString.wrap(out.toString())); + result.append(out.toString()); continue; } result.append(c); i++; } - return TString.wrap(result.toString()); + return result.toString(); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/net/TURISyntaxException.java b/classlib/src/main/java/org/teavm/classlib/java/net/TURISyntaxException.java index 50704fbd2..9eb0b0dcb 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/net/TURISyntaxException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/net/TURISyntaxException.java @@ -18,39 +18,13 @@ package org.teavm.classlib.java.net; import org.teavm.classlib.java.lang.TException; import org.teavm.classlib.java.lang.TIllegalArgumentException; import org.teavm.classlib.java.lang.TNullPointerException; -import org.teavm.classlib.java.lang.TString; 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 { - - private static final long serialVersionUID = 2137979680897488891L; - - private TString input; - + private String input; private 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) { + public TURISyntaxException(String input, String reason, int index) { super(reason); if (input == null || reason == null) { @@ -65,19 +39,7 @@ public class TURISyntaxException extends TException { this.index = index; } - /** - * 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) { + public TURISyntaxException(String input, String reason) { super(reason); if (input == null || reason == null) { @@ -88,45 +50,21 @@ public class TURISyntaxException extends TException { 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() { return index; } - /** - * Gets a description of the syntax error. - * - * @return the string describing the syntax error. - */ - public TString getReason() { - return TString.wrap(super.getMessage()); + public String getReason() { + return super.getMessage(); } - /** - * Gets the initial string that contains an invalid syntax. - * - * @return the string that caused the exception. - */ - public TString getInput() { + public String getInput() { 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 @Rename("getMessage") - public TString getMessage0() { - return TString.wrap(""); + public String getMessage0() { + return ""; } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/net/TURL.java b/classlib/src/main/java/org/teavm/classlib/java/net/TURL.java index 45819cfb5..0aba53fa2 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/net/TURL.java +++ b/classlib/src/main/java/org/teavm/classlib/java/net/TURL.java @@ -22,7 +22,6 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; 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.TXHRStreamHandler; @@ -316,7 +315,7 @@ public final class TURL implements Serializable { } public TURI toURI() throws TURISyntaxException { - return new TURI((TString) (Object) toExternalForm()); + return new TURI(toExternalForm()); } @Override diff --git a/classlib/src/main/java/org/teavm/classlib/java/security/TAccessControlException.java b/classlib/src/main/java/org/teavm/classlib/java/security/TAccessControlException.java index 6c79cc449..72da724f2 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/security/TAccessControlException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/security/TAccessControlException.java @@ -16,18 +16,17 @@ package org.teavm.classlib.java.security; import org.teavm.classlib.java.lang.TSecurityException; -import org.teavm.classlib.java.lang.TString; public class TAccessControlException extends TSecurityException { private static final long serialVersionUID = 8282514874369266797L; private TPermission permission; - public TAccessControlException(TString message) { + public TAccessControlException(String message) { super(message); } public TAccessControlException(String s, TPermission permission) { - super((TString) (Object) s); + super(s); this.permission = permission; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/text/TDecimalFormat.java b/classlib/src/main/java/org/teavm/classlib/java/text/TDecimalFormat.java index e9fffaf2b..d8cfad009 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/text/TDecimalFormat.java +++ b/classlib/src/main/java/org/teavm/classlib/java/text/TDecimalFormat.java @@ -19,11 +19,9 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.text.DecimalFormatSymbols; import java.util.Arrays; - import org.teavm.classlib.impl.unicode.CLDRHelper; import org.teavm.classlib.java.lang.TArithmeticException; import org.teavm.classlib.java.lang.TDouble; -import org.teavm.classlib.java.lang.TString; import org.teavm.classlib.java.util.TLocale; public class TDecimalFormat extends TNumberFormat { @@ -984,7 +982,7 @@ public class TDecimalFormat extends TNumberFormat { break; case UNNECESSARY: if (mantissa % rounding != 0) { - throw new TArithmeticException(TString.wrap("Can't avoid rounding")); + throw new TArithmeticException("Can't avoid rounding"); } break; case HALF_DOWN: @@ -1040,7 +1038,7 @@ public class TDecimalFormat extends TNumberFormat { break; case UNNECESSARY: if (mantissa.remainder(rounding).equals(BigInteger.ZERO)) { - throw new TArithmeticException(TString.wrap("Can't avoid rounding")); + throw new TArithmeticException("Can't avoid rounding"); } break; case HALF_DOWN: diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TArrays.java b/classlib/src/main/java/org/teavm/classlib/java/util/TArrays.java index 359ac5283..c73a90d0e 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TArrays.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TArrays.java @@ -22,7 +22,6 @@ import java.util.function.IntFunction; import java.util.function.IntToDoubleFunction; import java.util.function.IntToLongFunction; 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.TDouble; 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.TMath; 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.reflect.TArray; import org.teavm.classlib.java.util.stream.TDoubleStream; import org.teavm.classlib.java.util.stream.TIntStream; import org.teavm.classlib.java.util.stream.TLongStream; @@ -126,12 +123,12 @@ public class TArrays extends TObject { } @SuppressWarnings("unchecked") - public static T[] copyOf(U[] original, int newLength, TClass cls) { - TClass componentType = cls.getComponentType(); - T[] result = (T[]) (Object) TArray.newInstance(componentType, newLength); + public static T[] copyOf(U[] original, int newLength, Class cls) { + Class componentType = cls.getComponentType(); + T[] result = (T[]) Array.newInstance(componentType, newLength); int sz = TMath.min(newLength, original.length); 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; } @@ -210,130 +207,130 @@ public class TArrays extends TObject { } @SuppressWarnings("unchecked") - public static T[] copyOfRange(U[] original, int from, int to, TClass newType) { - TClass componentType = newType.getComponentType(); - T[] result = (T[]) (Object) TArray.newInstance(componentType, to - from); + public static T[] copyOfRange(U[] original, int from, int to, Class newType) { + Class componentType = newType.getComponentType(); + T[] result = (T[]) (Object) Array.newInstance(componentType, to - from); 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; } - public static TString toString(TObject[] a) { + public static String toString(TObject[] a) { TStringBuilder sb = new TStringBuilder(); - sb.append(TString.wrap("[")); + sb.append("["); for (int i = 0; i < a.length; ++i) { if (i > 0) { - sb.append(TString.wrap(", ")); + sb.append(", "); } sb.append(a[i]); } - sb.append(TString.wrap("]")); - return TString.wrap(sb.toString()); + sb.append("]"); + return sb.toString(); } - public static TString toString(boolean[] a) { + public static String toString(boolean[] a) { TStringBuilder sb = new TStringBuilder(); - sb.append(TString.wrap("[")); + sb.append("["); for (int i = 0; i < a.length; ++i) { if (i > 0) { - sb.append(TString.wrap(", ")); + sb.append(", "); } sb.append(a[i]); } - sb.append(TString.wrap("]")); - return TString.wrap(sb.toString()); + sb.append("]"); + return sb.toString(); } - public static TString toString(byte[] a) { + public static String toString(byte[] a) { TStringBuilder sb = new TStringBuilder(); - sb.append(TString.wrap("[")); + sb.append("["); for (int i = 0; i < a.length; ++i) { if (i > 0) { - sb.append(TString.wrap(", ")); + sb.append(", "); } sb.append(a[i]); } - sb.append(TString.wrap("]")); - return TString.wrap(sb.toString()); + sb.append("]"); + return sb.toString(); } - public static TString toString(short[] a) { + public static String toString(short[] a) { TStringBuilder sb = new TStringBuilder(); - sb.append(TString.wrap("[")); + sb.append("["); for (int i = 0; i < a.length; ++i) { if (i > 0) { - sb.append(TString.wrap(", ")); + sb.append(", "); } sb.append(a[i]); } - sb.append(TString.wrap("]")); - return TString.wrap(sb.toString()); + sb.append("]"); + return sb.toString(); } - public static TString toString(char[] a) { + public static String toString(char[] a) { TStringBuilder sb = new TStringBuilder(); - sb.append(TString.wrap("[")); + sb.append("["); for (int i = 0; i < a.length; ++i) { if (i > 0) { - sb.append(TString.wrap(", ")); + sb.append(", "); } sb.append(a[i]); } - sb.append(TString.wrap("]")); - return TString.wrap(sb.toString()); + sb.append("]"); + return sb.toString(); } - public static TString toString(int[] a) { + public static String toString(int[] a) { TStringBuilder sb = new TStringBuilder(); - sb.append(TString.wrap("[")); + sb.append("["); for (int i = 0; i < a.length; ++i) { if (i > 0) { - sb.append(TString.wrap(", ")); + sb.append(", "); } sb.append(a[i]); } - sb.append(TString.wrap("]")); - return TString.wrap(sb.toString()); + sb.append("]"); + return sb.toString(); } - public static TString toString(long[] a) { + public static String toString(long[] a) { TStringBuilder sb = new TStringBuilder(); - sb.append(TString.wrap("[")); + sb.append("["); for (int i = 0; i < a.length; ++i) { if (i > 0) { - sb.append(TString.wrap(", ")); + sb.append(", "); } sb.append(a[i]); } - sb.append(TString.wrap("]")); - return TString.wrap(sb.toString()); + sb.append("]"); + return sb.toString(); } - public static TString toString(float[] a) { + public static String toString(float[] a) { TStringBuilder sb = new TStringBuilder(); - sb.append(TString.wrap("[")); + sb.append("["); for (int i = 0; i < a.length; ++i) { if (i > 0) { - sb.append(TString.wrap(", ")); + sb.append(", "); } sb.append(a[i]); } - sb.append(TString.wrap("]")); - return TString.wrap(sb.toString()); + sb.append("]"); + return sb.toString(); } - public static TString toString(double[] a) { + public static String toString(double[] a) { TStringBuilder sb = new TStringBuilder(); - sb.append(TString.wrap("[")); + sb.append("["); for (int i = 0; i < a.length; ++i) { if (i > 0) { - sb.append(TString.wrap(", ")); + sb.append(", "); } sb.append(a[i]); } - sb.append(TString.wrap("]")); - return TString.wrap(sb.toString()); + sb.append("]"); + return sb.toString(); } 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) { - TStringBuilder sb = new TStringBuilder(); + public static String deepToString(Object[] a) { + StringBuilder sb = new StringBuilder(); deepToString(a, sb, new TArrayList<>()); - return TString.wrap(sb.toString()); + return sb.toString(); } - private static void deepToString(Object[] a, TStringBuilder out, TList visited) { + private static void deepToString(Object[] a, StringBuilder out, TList visited) { out.append('['); if (visited.contains(a)) { - out.append(TString.wrap("...")); + out.append("..."); } else { visited.add(a); if (a.length > 0) { deepToString(a[0], out, visited); for (int i = 1; i < a.length; ++i) { - out.append(TString.wrap(", ")); + out.append(", "); deepToString(a[i], out, visited); } } @@ -1553,11 +1550,11 @@ public class TArrays extends TObject { out.append(']'); } - private static void deepToString(Object a, TStringBuilder out, TList visited) { + private static void deepToString(Object a, StringBuilder out, TList visited) { if (a instanceof Object[]) { deepToString((Object[]) a, out, visited); } else { - out.append(TObject.wrap(a)); + out.append(a); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedCollection.java b/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedCollection.java index 9fb50a2ef..b7eaad5eb 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedCollection.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedCollection.java @@ -15,14 +15,11 @@ */ package org.teavm.classlib.java.util; -import org.teavm.classlib.java.lang.TClass; -import org.teavm.classlib.java.lang.TObject; - class TCheckedCollection implements TCollection { TCollection innerCollection; - TClass type; + Class type; - public TCheckedCollection(TCollection innerCollection, TClass type) { + public TCheckedCollection(TCollection innerCollection, Class type) { this.innerCollection = innerCollection; this.type = type; } @@ -59,7 +56,7 @@ class TCheckedCollection implements TCollection { @Override public boolean add(E e) { - return innerCollection.add(type.cast(TObject.wrap(e))); + return innerCollection.add(type.cast(e)); } @Override @@ -77,7 +74,7 @@ class TCheckedCollection implements TCollection { public boolean addAll(TCollection c) { Object[] items = c.toArray(); 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)); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedList.java b/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedList.java index 7ccb2683e..781021241 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedList.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedList.java @@ -15,13 +15,10 @@ */ package org.teavm.classlib.java.util; -import org.teavm.classlib.java.lang.TClass; -import org.teavm.classlib.java.lang.TObject; - class TCheckedList extends TCheckedCollection implements TList { private TList innerList; - public TCheckedList(TList innerList, TClass type) { + public TCheckedList(TList innerList, Class type) { super(innerList, type); this.innerList = innerList; } @@ -31,7 +28,7 @@ class TCheckedList extends TCheckedCollection implements TList { public boolean addAll(int index, TCollection c) { Object[] items = c.toArray(); 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)); } @@ -43,12 +40,12 @@ class TCheckedList extends TCheckedCollection implements TList { @Override public E set(int index, E element) { - return innerList.set(index, type.cast(TObject.wrap(element))); + return innerList.set(index, type.cast(element)); } @Override public void add(int index, E element) { - innerList.add(index, type.cast(TObject.wrap(element))); + innerList.add(index, type.cast(element)); } @Override diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedListIterator.java b/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedListIterator.java index 33306f3f0..ada843b1b 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedListIterator.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedListIterator.java @@ -15,14 +15,11 @@ */ package org.teavm.classlib.java.util; -import org.teavm.classlib.java.lang.TClass; -import org.teavm.classlib.java.lang.TObject; - class TCheckedListIterator implements TListIterator { private TListIterator innerIterator; - private TClass type; + private Class type; - public TCheckedListIterator(TListIterator innerIterator, TClass type) { + TCheckedListIterator(TListIterator innerIterator, Class type) { this.innerIterator = innerIterator; this.type = type; } @@ -64,11 +61,11 @@ class TCheckedListIterator implements TListIterator { @Override public void set(E e) { - innerIterator.set(type.cast(TObject.wrap(e))); + innerIterator.set(type.cast(e)); } @Override public void add(E e) { - innerIterator.add(type.cast(TObject.wrap(e))); + innerIterator.add(type.cast(e)); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedMap.java b/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedMap.java index 989157979..9534dc978 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedMap.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedMap.java @@ -15,15 +15,12 @@ */ package org.teavm.classlib.java.util; -import org.teavm.classlib.java.lang.TClass; -import org.teavm.classlib.java.lang.TObject; - class TCheckedMap implements TMap { private TMap innerMap; - private TClass keyType; - private TClass valueType; + private Class keyType; + private Class valueType; - public TCheckedMap(TMap innerMap, TClass keyType, TClass valueType) { + public TCheckedMap(TMap innerMap, Class keyType, Class valueType) { this.innerMap = innerMap; this.keyType = keyType; this.valueType = valueType; @@ -56,7 +53,7 @@ class TCheckedMap implements TMap { @Override 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 @@ -69,8 +66,8 @@ class TCheckedMap implements TMap { m = new THashMap<>(m); for (TIterator> iter = m.entrySet().iterator(); iter.hasNext();) { Entry entry = iter.next(); - keyType.cast(TObject.wrap(entry.getKey())); - valueType.cast(TObject.wrap(entry.getValue())); + keyType.cast(entry.getKey()); + valueType.cast(entry.getValue()); } innerMap.putAll(m); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedSet.java b/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedSet.java index c6fa957cc..fd6a2ac61 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedSet.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TCheckedSet.java @@ -15,10 +15,8 @@ */ package org.teavm.classlib.java.util; -import org.teavm.classlib.java.lang.TClass; - class TCheckedSet extends TCheckedCollection implements TSet { - public TCheckedSet(TCollection innerCollection, TClass type) { + public TCheckedSet(TCollection innerCollection, Class type) { super(innerCollection, type); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TCollections.java b/classlib/src/main/java/org/teavm/classlib/java/util/TCollections.java index a03427399..dec2cd347 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TCollections.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TCollections.java @@ -572,19 +572,19 @@ public class TCollections extends TObject { return list; } - public static TCollection checkedCollection(TCollection c, TClass type) { + public static TCollection checkedCollection(TCollection c, Class type) { return new TCheckedCollection<>(c, type); } - public static TSet checkedSet(TSet s, TClass type) { + public static TSet checkedSet(TSet s, Class type) { return new TCheckedSet<>(s, type); } - public static TList checkedList(TList list, TClass type) { + public static TList checkedList(TList list, Class type) { return new TCheckedList<>(list, type); } - public static TMap checkedMap(TMap m, TClass keyType, TClass valueType) { + public static TMap checkedMap(TMap m, Class keyType, Class valueType) { return new TCheckedMap<>(m, keyType, valueType); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TConcurrentModificationException.java b/classlib/src/main/java/org/teavm/classlib/java/util/TConcurrentModificationException.java index 85328ecb9..dd3c86d7d 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TConcurrentModificationException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TConcurrentModificationException.java @@ -16,7 +16,6 @@ package org.teavm.classlib.java.util; import org.teavm.classlib.java.lang.TRuntimeException; -import org.teavm.classlib.java.lang.TString; import org.teavm.classlib.java.lang.TThrowable; public class TConcurrentModificationException extends TRuntimeException { @@ -26,11 +25,11 @@ public class TConcurrentModificationException extends TRuntimeException { super(); } - public TConcurrentModificationException(TString message, TThrowable cause) { + public TConcurrentModificationException(String message, TThrowable cause) { super(message, cause); } - public TConcurrentModificationException(TString message) { + public TConcurrentModificationException(String message) { super(message); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TMissingResourceException.java b/classlib/src/main/java/org/teavm/classlib/java/util/TMissingResourceException.java index 4ac45a160..564a50de6 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TMissingResourceException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TMissingResourceException.java @@ -16,7 +16,6 @@ package org.teavm.classlib.java.util; import org.teavm.classlib.java.lang.TRuntimeException; -import org.teavm.classlib.java.lang.TString; public class TMissingResourceException extends TRuntimeException { private static final long serialVersionUID = 6730397307327337970L; @@ -24,7 +23,7 @@ public class TMissingResourceException extends TRuntimeException { private String key; public TMissingResourceException(String s, String className, String key) { - super(TString.wrap(s)); + super(s); this.className = className; this.key = key; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TNoSuchElementException.java b/classlib/src/main/java/org/teavm/classlib/java/util/TNoSuchElementException.java index c58f16d76..9147ee6e0 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TNoSuchElementException.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TNoSuchElementException.java @@ -16,7 +16,6 @@ package org.teavm.classlib.java.util; import org.teavm.classlib.java.lang.TRuntimeException; -import org.teavm.classlib.java.lang.TString; public class TNoSuchElementException extends TRuntimeException { private static final long serialVersionUID = -4890604137042866919L; @@ -25,7 +24,7 @@ public class TNoSuchElementException extends TRuntimeException { super(); } - public TNoSuchElementException(TString message) { + public TNoSuchElementException(String message) { super(message); } } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TProperties.java b/classlib/src/main/java/org/teavm/classlib/java/util/TProperties.java index a8f37d9fa..d1bde48a0 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TProperties.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TProperties.java @@ -15,14 +15,13 @@ */ 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.TIOException; 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.TWriter; -import org.teavm.classlib.java.lang.TString; public class TProperties extends THashtable { /** @@ -139,17 +138,17 @@ public class TProperties extends THashtable { } if (property.length() > 40) { buffer.append(property.substring(0, 37)); - buffer.append("..."); //$NON-NLS-1$ + buffer.append("..."); } else { buffer.append(property); } - out.println(TString.wrap(buffer.toString())); + out.println(buffer.toString()); buffer.setLength(0); } } @SuppressWarnings("fallthrough") - public synchronized void load(TInputStream in) throws TIOException { + public synchronized void load(TInputStream in) throws IOException { if (in == null) { throw new NullPointerException(); } @@ -339,10 +338,10 @@ public class TProperties extends THashtable { } @Deprecated - public void save(TOutputStream out, String comment) { + public void save(OutputStream out, String comment) { try { store(out, comment); - } catch (TIOException e) { + } catch (IOException e) { // do nothing } } @@ -351,8 +350,8 @@ public class TProperties extends THashtable { return put(name, value); } - public synchronized void store(TOutputStream out, String comments) throws TIOException { - TOutputStreamWriter writer = new TOutputStreamWriter(out, "ISO8859_1"); + public synchronized void store(OutputStream out, String comments) throws IOException { + OutputStreamWriter writer = new OutputStreamWriter(out, "ISO8859_1"); if (comments != null) { writeComments(writer, comments); } @@ -374,7 +373,7 @@ public class TProperties extends THashtable { writer.flush(); } - private void writeComments(TWriter writer, String comments) throws TIOException { + private void writeComments(Writer writer, String comments) throws IOException { writer.write('#'); char[] chars = comments.toCharArray(); for (int index = 0; index < chars.length; index++) { diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogRecord.java b/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogRecord.java index efa3de620..e8a778805 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogRecord.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogRecord.java @@ -21,17 +21,17 @@ import org.teavm.classlib.java.lang.*; public class TLogRecord extends TObject implements TSerializable { private static long sequenceNumberGenerator; private TLevel level; - private TString loggerName; - private TString message; + private String loggerName; + private String message; private long millis; private Object[] parameters; private long sequenceNumber; - private TString sourceClassName; - private TString sourceMethodName; + private String sourceClassName; + private String sourceMethodName; private long threadID; private TThrowable thrown; - public TLogRecord(TLevel level, TString msg) { + public TLogRecord(TLevel level, String msg) { this.level = level; this.message = msg; this.millis = TSystem.currentTimeMillis(); @@ -47,19 +47,19 @@ public class TLogRecord extends TObject implements TSerializable { this.level = level; } - public TString getLoggerName() { + public String getLoggerName() { return loggerName; } - public void setLoggerName(TString loggerName) { + public void setLoggerName(String loggerName) { this.loggerName = loggerName; } - public TString getMessage() { + public String getMessage() { return message; } - public void setMessage(TString message) { + public void setMessage(String message) { this.message = message; } @@ -87,19 +87,19 @@ public class TLogRecord extends TObject implements TSerializable { this.sequenceNumber = sequenceNumber; } - public TString getSourceClassName() { + public String getSourceClassName() { return sourceClassName; } - public void setSourceClassName(TString sourceClassName) { + public void setSourceClassName(String sourceClassName) { this.sourceClassName = sourceClassName; } - public TString getSourceMethodName() { + public String getSourceMethodName() { return sourceMethodName; } - public void setSourceMethodName(TString sourceMethodName) { + public void setSourceMethodName(String sourceMethodName) { this.sourceMethodName = sourceMethodName; } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogger.java b/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogger.java index 0729a0a11..1bf516650 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogger.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogger.java @@ -17,20 +17,18 @@ package org.teavm.classlib.java.util.logging; import org.teavm.classlib.java.lang.TInteger; 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.TThrowable; import org.teavm.classlib.java.util.THashMap; import org.teavm.classlib.java.util.TMap; import org.teavm.jso.JSBody; public class TLogger { - public static final TString GLOBAL_LOGGER_NAME = TString.wrap("global"); - private static TMap loggerCache = new THashMap<>(); - private TString name; + public static final String GLOBAL_LOGGER_NAME = "global"; + private static TMap loggerCache = new THashMap<>(); + private String name; private TLogger parent; - TLogger(TString name) { + TLogger(String name) { this.name = name; } @@ -38,16 +36,16 @@ public class TLogger { return getLogger(GLOBAL_LOGGER_NAME); } - public static TLogger getLogger(TString name) { + public static TLogger getLogger(String name) { TLogger logger = loggerCache.get(name); if (logger == null) { logger = new TLogger(name); int dotIndex = name.lastIndexOf('.'); if (dotIndex >= 0) { - TString parentName = name.substring(0, dotIndex); + String parentName = name.substring(0, dotIndex); logger.parent = getLogger(parentName); } else if (!name.isEmpty()) { - logger.parent = getLogger(TString.wrap("")); + logger.parent = getLogger(""); } loggerCache.put(name, logger); } @@ -59,7 +57,7 @@ public class TLogger { } public void log(TLogRecord record) { - TString message = format(record.getMessage(), record.getParameters()); + String message = format(record.getMessage(), record.getParameters()); if (record.getLevel().intValue() >= TLevel.SEVERE.intValue()) { error(message); } else if (record.getLevel().intValue() >= TLevel.WARNING.intValue()) { @@ -69,11 +67,11 @@ public class TLogger { } } - private TString format(TString message, Object[] params) { + private String format(String message, Object[] params) { if (params == null) { return message; } - TStringBuilder sb = new TStringBuilder(); + StringBuilder sb = new StringBuilder(); int index = 0; while (index < message.length()) { int next = message.indexOf('{', index); @@ -92,17 +90,17 @@ public class TLogger { } int paramIndex = TInteger.parseInt(message.substring(paramStart, next)); if (paramIndex >= params.length) { - sb.append(message.substring(index, next)); + sb.append(message, index, next); index = next; continue; } - sb.append(TObject.wrap(params[paramIndex])); + sb.append(params[paramIndex]); index = next + 1; } - return TString.wrap(sb.toString()); + return sb.toString(); } - private static int digits(int from, TString message) { + private static int digits(int from, String message) { while (from < message.length()) { int c = message.charAt(from++); if (c <= '0' || c >= '9') { @@ -112,53 +110,53 @@ public class TLogger { return -1; } - public void log(TLevel level, TString msg, Object[] params) { + public void log(TLevel level, String msg, Object[] params) { TLogRecord record = new TLogRecord(level, msg); record.setParameters(params); log(record); } - public void log(TLevel level, TString msg) { + public void log(TLevel level, String msg) { log(new TLogRecord(level, msg)); } - public void log(TLevel level, TString msg, TObject param1) { + public void log(TLevel level, String msg, TObject param1) { TLogRecord record = new TLogRecord(level, msg); record.setParameters(new Object[] { param1 }); log(record); } - public void log(TLevel level, TString msg, TThrowable thrown) { + public void log(TLevel level, String msg, TThrowable thrown) { TLogRecord record = new TLogRecord(level, msg); record.setThrown(thrown); log(record); } - public void severe(TString msg) { + public void severe(String msg) { log(TLevel.SEVERE, msg); } - public void warning(TString msg) { + public void warning(String msg) { log(TLevel.WARNING, msg); } - public void info(TString msg) { + public void info(String msg) { log(TLevel.INFO, msg); } - public void config(TString msg) { + public void config(String msg) { log(TLevel.CONFIG, msg); } - public void fine(TString msg) { + public void fine(String msg) { log(TLevel.FINE, msg); } - public void finer(TString msg) { + public void finer(String msg) { log(TLevel.FINER, msg); } - public void finest(TString msg) { + public void finest(String msg) { log(TLevel.FINEST, msg); } @@ -166,7 +164,7 @@ public class TLogger { return true; } - public TString getName() { + public String getName() { return name; } @@ -182,17 +180,17 @@ public class TLogger { + "if (console) {" + "console.info(message);" + "}") - private static native void infoImpl(TString message); + private static native void infoImpl(String message); @JSBody(params = "message", script = "" + "if (console) {" + "console.warn(message);" + "}") - private static native void warn(TString message); + private static native void warn(String message); @JSBody(params = "message", script = "" + "if (console) {" + "console.error(message);" + "}") - private static native void error(TString message); + private static native void error(String message); }