mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Merge branch 'master' into diagnostics
This commit is contained in:
commit
bdf4f7dbae
|
@ -29,6 +29,10 @@
|
|||
<name>TeaVM Java class library</name>
|
||||
<description>TeaVM Java class library emulation</description>
|
||||
|
||||
<properties>
|
||||
<teavm.classlib.test.incremental>false</teavm.classlib.test.incremental>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -93,6 +97,7 @@
|
|||
<properties>
|
||||
<java.util.Locale.available>en, en_US, en_GB, ru, ru_RU</java.util.Locale.available>
|
||||
</properties>
|
||||
<incremental>${teavm.classlib.test.incremental}</incremental>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
@ -64,7 +64,7 @@ public class TBufferedInputStream extends TFilterInputStream {
|
|||
if (result > 0) {
|
||||
markpos = -1;
|
||||
pos = 0;
|
||||
count = result == -1 ? 0 : result;
|
||||
count = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class TFilterOutputStream extends TOutputStream {
|
|||
} catch (TIOException e) {
|
||||
// do nothing
|
||||
}
|
||||
close();
|
||||
out.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package org.teavm.classlib.java.lang;
|
||||
|
||||
import org.teavm.javascript.ni.Rename;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
|
@ -26,5 +28,6 @@ public interface TCharSequence {
|
|||
|
||||
TCharSequence subSequence(int start, int end);
|
||||
|
||||
@Rename("toString")
|
||||
TString toString0();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.teavm.javascript.ni.InjectedBy;
|
|||
*/
|
||||
public class TClass<T> extends TObject {
|
||||
TString name;
|
||||
TString binaryName;
|
||||
boolean primitive;
|
||||
boolean array;
|
||||
boolean isEnum;
|
||||
|
@ -42,7 +43,7 @@ public class TClass<T> extends TObject {
|
|||
public native boolean isAssignableFrom(TClass<?> obj);
|
||||
|
||||
public TString getName() {
|
||||
return new TString(name);
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isPrimitive() {
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TObject {
|
|||
|
||||
@Rename("toString")
|
||||
public TString toString0() {
|
||||
return TString.wrap(getClass().getName() + "@" + identity());
|
||||
return TString.wrap(getClass().getName() + "@" + TInteger.toHexString(identity()));
|
||||
}
|
||||
|
||||
@GeneratedBy(ObjectNativeGenerator.class)
|
||||
|
|
|
@ -200,7 +200,7 @@ public class TStringBuffer extends TAbstractStringBuilder implements TAppendable
|
|||
|
||||
@Override
|
||||
public TStringBuffer deleteCharAt(int index) {
|
||||
deleteCharAt(index);
|
||||
super.deleteCharAt(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ public class TStringBuilder extends TAbstractStringBuilder implements TAppendabl
|
|||
|
||||
@Override
|
||||
public TStringBuilder deleteCharAt(int index) {
|
||||
deleteCharAt(index);
|
||||
super.deleteCharAt(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public class TDateFormatSymbols implements TSerializable, TCloneable {
|
|||
return false;
|
||||
}
|
||||
for (int j = 0; j < element.length; j++) {
|
||||
if (element[j] != element[j] && !(element[j].equals(element[j]))) {
|
||||
if (!(element[j].equals(element[j]))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,19 +54,21 @@ public class TBitSet extends TObject implements TCloneable, TSerializable {
|
|||
int[] ints = new int[(bytes.length + 3) / 4];
|
||||
int fullInts = bytes.length / 4;
|
||||
for (int i = 0; i < fullInts; ++i) {
|
||||
ints[i] = bytes[i * 4] | (bytes[i * 4 + 1] << 8) | (bytes[i * 4 + 2] << 16) | (bytes[i * 4 + 3] << 24);
|
||||
ints[i] = (bytes[i * 4] & 0xFF) | ((bytes[i * 4 + 1] & 0xFF) << 8) | ((bytes[i * 4 + 2] & 0xFF) << 16) |
|
||||
((bytes[i * 4 + 3] & 0xFF) << 24);
|
||||
}
|
||||
int lastInt = ints.length - 1;
|
||||
int lastByte = bytes[lastInt * 4];
|
||||
int lastByte = lastInt * 4;
|
||||
switch (bytes.length % 4) {
|
||||
case 3:
|
||||
ints[lastInt] = bytes[lastByte] | (bytes[lastByte + 1] << 8) | (bytes[lastByte + 2] << 16);
|
||||
ints[lastInt] = (bytes[lastByte] & 0xFF) | ((bytes[lastByte + 1] & 0xFF) << 8) |
|
||||
((bytes[lastByte + 2] & 0xFF) << 16);
|
||||
break;
|
||||
case 2:
|
||||
ints[lastInt] = bytes[lastByte] | (bytes[lastByte + 1] << 8);
|
||||
ints[lastInt] = (bytes[lastByte] & 0xFF) | ((bytes[lastByte + 1] & 0xFF) << 8);
|
||||
break;
|
||||
case 1:
|
||||
ints[lastInt] = bytes[lastByte];
|
||||
ints[lastInt] = bytes[lastByte] & 0xFF;
|
||||
break;
|
||||
}
|
||||
return new TBitSet(ints);
|
||||
|
@ -105,9 +107,9 @@ public class TBitSet extends TObject implements TCloneable, TSerializable {
|
|||
int fullLongs = length / 64;
|
||||
int i = 0;
|
||||
for (; i < fullLongs; ++i) {
|
||||
longs[i] = data[i * 2] | (data[i * 2 + 1] << 32);
|
||||
longs[i] = data[i * 2] | ((long)data[i * 2 + 1] << 32);
|
||||
}
|
||||
if (((31 + length) / 32) % 2 == 1) {
|
||||
if ((((31 + length) / 32) & 1) == 1) {
|
||||
longs[i] = data[i * 2];
|
||||
}
|
||||
return longs;
|
||||
|
|
|
@ -39,7 +39,7 @@ public class TRandom extends TObject implements TSerializable {
|
|||
}
|
||||
|
||||
public void nextBytes(byte[] bytes) {
|
||||
for (int i = 0; i < bytes.length; ) {
|
||||
for (int i = 0; i < bytes.length; ++i) {
|
||||
bytes[i] = (byte)next(8);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ public class ClassTest {
|
|||
@Test
|
||||
public void classNameEvaluated() {
|
||||
assertEquals("java.lang.Object", Object.class.getName());
|
||||
assertEquals("[Ljava.lang.Object;", Object[].class.getName());
|
||||
assertEquals("int", int.class.getName());
|
||||
assertEquals("[I", int[].class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -60,4 +60,11 @@ public class ObjectTest {
|
|||
public void properInstanceDetected() {
|
||||
assertTrue(Object.class.isInstance(new Object()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringWorks() {
|
||||
assertTrue(new Object().toString().startsWith("java.lang.Object@"));
|
||||
assertTrue(new Object[2].toString().startsWith("[Ljava.lang.Object;@"));
|
||||
assertTrue(new byte[3].toString().startsWith("[B@"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
package org.teavm.classlib.java.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BitSetTest {
|
||||
|
||||
BitSet eightbs;
|
||||
|
||||
public BitSetTest() {
|
||||
|
@ -58,6 +58,23 @@ public class BitSetTest {
|
|||
assertEquals("New BitSet had invalid string representation: " + bs, "{}", bs.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructFromBytes() {
|
||||
for (int i = 4; i < 8; ++i) {
|
||||
byte[] bytes = new byte[i];
|
||||
Arrays.fill(bytes, (byte)0x80);
|
||||
BitSet bs = BitSet.valueOf(bytes);
|
||||
assertEquals("Wrong length of BitSet", i * 8, bs.length());
|
||||
for (int j = 0; j < bs.length(); ++j) {
|
||||
if (j % 8 == 7) {
|
||||
assertTrue("Expected that " + j + "th bit is to be set", bs.get(j));
|
||||
} else {
|
||||
assertFalse("Expected that " + j + "th bit is not to be set", bs.get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clonePerformed() {
|
||||
BitSet bs;
|
||||
|
@ -76,12 +93,9 @@ public class BitSetTest {
|
|||
|
||||
bs = (BitSet) eightbs.clone();
|
||||
bs.set(128);
|
||||
assertFalse("Different sized BitSet with higher bit set returned true",
|
||||
eightbs.equals(bs));
|
||||
assertFalse("Different sized BitSet with higher bit set returned true", eightbs.equals(bs));
|
||||
bs.clear(128);
|
||||
assertTrue(
|
||||
"Different sized BitSet with higher bits not set returned false",
|
||||
eightbs.equals(bs));
|
||||
assertTrue("Different sized BitSet with higher bits not set returned false", eightbs.equals(bs));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -53,10 +53,12 @@ public class AstIO {
|
|||
output.writeShort(method.getParameterDebugNames().size());
|
||||
for (Set<String> debugNames : method.getParameterDebugNames()) {
|
||||
output.writeShort(debugNames != null ? debugNames.size() : 0);
|
||||
if (debugNames != null) {
|
||||
for (String debugName : debugNames) {
|
||||
output.writeUTF(debugName);
|
||||
}
|
||||
}
|
||||
}
|
||||
output.writeBoolean(method.isOriginalNamePreserved());
|
||||
try {
|
||||
method.getBody().acceptVisitor(new NodeWriter(output));
|
||||
|
|
|
@ -224,7 +224,7 @@ public class Debugger {
|
|||
}
|
||||
|
||||
public Breakpoint createBreakpoint(SourceLocation location) {
|
||||
synchronized (breakpoints) {
|
||||
synchronized (breakpointMap) {
|
||||
Breakpoint breakpoint = new Breakpoint(this, location);
|
||||
breakpoints.put(breakpoint, dummyObject);
|
||||
updateInternalBreakpoints(breakpoint);
|
||||
|
@ -366,7 +366,7 @@ public class Debugger {
|
|||
breakpointMap.remove(jsBreakpoint);
|
||||
}
|
||||
breakpoint.jsBreakpoints = new ArrayList<>();
|
||||
breakpoints.remove(this);
|
||||
breakpoints.remove(breakpoint);
|
||||
}
|
||||
|
||||
private void fireResumed() {
|
||||
|
|
|
@ -178,6 +178,12 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
.append("clsProto.$meta.name").ws().append("!==").ws().append("undefined").ws().append("?").ws()
|
||||
.append("$rt_str(clsProto.$meta.name)").ws().append(":").ws().append("null;").softNewLine();
|
||||
}
|
||||
if (classSource.get(classClass).getField("name") != null) {
|
||||
writer.append("cls.").appendField(new FieldReference(classClass, "binaryName")).ws().append("=").ws()
|
||||
.append("clsProto.$meta.binaryName").ws().append("!==").ws().append("undefined").ws()
|
||||
.append("?").ws()
|
||||
.append("$rt_str(clsProto.$meta.binaryName)").ws().append(":").ws().append("null;").softNewLine();
|
||||
}
|
||||
if (classSource.get(classClass).getField("primitive") != null) {
|
||||
writer.append("cls.").appendField(new FieldReference(classClass, "primitive"))
|
||||
.append(" = clsProto.$meta.primitive ? 1 : 0;").newLine();
|
||||
|
|
|
@ -60,7 +60,7 @@ class InterferenceGraphBuilder {
|
|||
}
|
||||
for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) {
|
||||
if (tryCatch.getExceptionVariable() != null) {
|
||||
live.remove(tryCatch.getExceptionVariable());
|
||||
live.remove(nodes.get(tryCatch.getExceptionVariable().getIndex()));
|
||||
}
|
||||
}
|
||||
for (int j = block.getInstructions().size() - 1; j >= 0; --j) {
|
||||
|
|
|
@ -128,7 +128,9 @@ function $rt_arraycls(cls) {
|
|||
str += "]";
|
||||
return str;
|
||||
}
|
||||
arraycls.$meta = { item : cls, supertypes : [$rt_objcls()], primitive : false, superclass : $rt_objcls() };
|
||||
var name = "[" + cls.$meta.binaryName;
|
||||
arraycls.$meta = { item : cls, supertypes : [$rt_objcls()], primitive : false, superclass : $rt_objcls(),
|
||||
name : name, binaryName : name };
|
||||
cls.$array = arraycls;
|
||||
}
|
||||
return cls.$array;
|
||||
|
@ -140,84 +142,73 @@ function $rt_createcls() {
|
|||
}
|
||||
};
|
||||
}
|
||||
function $rt_createPrimitiveCls(name, binaryName) {
|
||||
var cls = $rt_createcls();
|
||||
cls.$meta.primitive = true;
|
||||
cls.$meta.name = name;
|
||||
cls.$meta.binaryName = binaryName;
|
||||
return cls;
|
||||
}
|
||||
var $rt_booleanclsCache = null;
|
||||
function $rt_booleancls() {
|
||||
if ($rt_booleanclsCache === null) {
|
||||
$rt_booleanclsCache = $rt_createcls();
|
||||
$rt_booleanclsCache.primitive = true;
|
||||
$rt_booleanclsCache.name = "boolean";
|
||||
$rt_booleanclsCache = $rt_createPrimitiveCls("boolean", "Z");
|
||||
}
|
||||
return $rt_booleanclsCache;
|
||||
}
|
||||
var $rt_charclsCache = null;
|
||||
function $rt_charcls() {
|
||||
if ($rt_charclsCache === null) {
|
||||
$rt_charclsCache = $rt_createcls();
|
||||
$rt_charclsCache.primitive = true;
|
||||
$rt_charclsCache.name = "char";
|
||||
$rt_charclsCache = $rt_createPrimitiveCls("char", "C");
|
||||
}
|
||||
return $rt_charclsCache;
|
||||
}
|
||||
var $rt_byteclsCache = null;
|
||||
function $rt_bytecls() {
|
||||
if ($rt_byteclsCache === null) {
|
||||
$rt_byteclsCache = $rt_createcls();
|
||||
$rt_byteclsCache.primitive = true;
|
||||
$rt_byteclsCache.name = "byte";
|
||||
$rt_byteclsCache = $rt_createPrimitiveCls("byte", "B");
|
||||
}
|
||||
return $rt_byteclsCache;
|
||||
}
|
||||
var $rt_shortclsCache = null;
|
||||
function $rt_shortcls() {
|
||||
if ($rt_shortclsCache === null) {
|
||||
$rt_shortclsCache = $rt_createcls();
|
||||
$rt_shortclsCache.primitive = true;
|
||||
$rt_shortclsCache.name = "short";
|
||||
$rt_shortclsCache = $rt_createPrimitiveCls("short", "S");
|
||||
}
|
||||
return $rt_shortclsCache;
|
||||
}
|
||||
var $rt_intclsCache = null;
|
||||
function $rt_intcls() {
|
||||
if ($rt_intclsCache === null) {
|
||||
$rt_intclsCache = $rt_createcls();
|
||||
$rt_intclsCache.primitive = true;
|
||||
$rt_intclsCache.name = "int";
|
||||
$rt_intclsCache = $rt_createPrimitiveCls("int", "I");
|
||||
}
|
||||
return $rt_intclsCache;
|
||||
}
|
||||
var $rt_longclsCache = null;
|
||||
function $rt_longcls() {
|
||||
if ($rt_longclsCache === null) {
|
||||
$rt_longclsCache = $rt_createcls();
|
||||
$rt_longclsCache.primitive = true;
|
||||
$rt_longclsCache.name = "long";
|
||||
$rt_longclsCache = $rt_createPrimitiveCls("long", "J");
|
||||
}
|
||||
return $rt_longclsCache;
|
||||
}
|
||||
var $rt_floatclsCache = null;
|
||||
function $rt_floatcls() {
|
||||
if ($rt_floatclsCache === null) {
|
||||
$rt_floatclsCache = $rt_createcls();
|
||||
$rt_floatclsCache.primitive = true;
|
||||
$rt_floatclsCache.name = "float";
|
||||
$rt_floatclsCache = $rt_createPrimitiveCls("float", "F");
|
||||
}
|
||||
return $rt_floatclsCache;
|
||||
}
|
||||
var $rt_doubleclsCache = null;
|
||||
function $rt_doublecls() {
|
||||
if ($rt_doubleclsCache === null) {
|
||||
$rt_doubleclsCache = $rt_createcls();
|
||||
$rt_doubleclsCache.primitive = true;
|
||||
$rt_doubleclsCache.name = "double";
|
||||
$rt_doubleclsCache = $rt_createPrimitiveCls("double", "D");
|
||||
}
|
||||
return $rt_doubleclsCache;
|
||||
}
|
||||
var $rt_voidclsCache = null;
|
||||
function $rt_voidcls() {
|
||||
if ($rt_voidclsCache === null) {
|
||||
$rt_voidclsCache = $rt_createcls();
|
||||
$rt_voidclsCache.primitive = true;
|
||||
$rt_voidclsCache.name = "void";
|
||||
$rt_voidclsCache = $rt_createPrimitiveCls("void", "V");
|
||||
}
|
||||
return $rt_voidclsCache;
|
||||
}
|
||||
|
@ -383,6 +374,7 @@ function $rt_declClass(cls, data) {
|
|||
cls.prototype = new Object();
|
||||
}
|
||||
cls.$meta.name = data.name;
|
||||
cls.$meta.binaryName = "L" + data.name + ";";
|
||||
cls.$meta.enum = data.enum;
|
||||
cls.prototype.constructor = cls;
|
||||
cls.$clinit = data.clinit;
|
||||
|
|
|
@ -63,7 +63,7 @@ public interface XMLHttpRequest extends JSObject {
|
|||
Document getResponseXML();
|
||||
|
||||
@JSProperty
|
||||
Integer getStatus();
|
||||
int getStatus();
|
||||
|
||||
@JSProperty
|
||||
String getStatusText();
|
||||
|
|
|
@ -6,7 +6,7 @@ Bundle-Version: 0.3.0.qualifer
|
|||
Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com>
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ClassPath: .,
|
||||
lib/asm-debug-all-4.0.3.jar,
|
||||
lib/asm-debug-all-5.0.3.jar,
|
||||
lib/cdi-api-1.2.jar,
|
||||
lib/commons-io-2.4.jar,
|
||||
lib/jackson-core-asl-1.9.13.jar,
|
||||
|
|
Loading…
Reference in New Issue
Block a user