From 684d1f2be8319dbed6bc33e0c4d677f213e4eb0d Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Sat, 5 Apr 2014 11:14:43 +0400 Subject: [PATCH] Fixes bugs in JCL implementation --- .../teavm/classlib/java/io/TBufferedReader.java | 2 +- .../classlib/java/lang/MathNativeGenerator.java | 16 +--------------- .../org/teavm/classlib/java/util/TArrays.java | 5 +++++ 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/io/TBufferedReader.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/io/TBufferedReader.java index ec50319bf..b745f7fcd 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/io/TBufferedReader.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/io/TBufferedReader.java @@ -85,7 +85,7 @@ public class TBufferedReader extends TReader { public TString readLine() throws TIOException { requireOpened(); - if (eof && index == count) { + if (eof && index >= count) { return null; } TStringBuilder line = new TStringBuilder(); diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/MathNativeGenerator.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/MathNativeGenerator.java index 070f72d00..a3805d412 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/MathNativeGenerator.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/MathNativeGenerator.java @@ -28,21 +28,7 @@ import org.teavm.model.MethodReference; public class MathNativeGenerator implements Generator { @Override public void generate(GeneratorContext context, SourceWriter writer, MethodReference methodRef) throws IOException { - switch (methodRef.getName()) { - case "sin": - case "cos": - case "tan": - case "asin": - case "acos": - case "atan": - case "exp": - case "log": - case "sqrt": - case "floor": - case "ceil": - function(context, writer, "Math." + methodRef.getName(), methodRef.parameterCount()); - break; - } + function(context, writer, "Math." + methodRef.getName(), methodRef.parameterCount()); } private void function(GeneratorContext context, SourceWriter writer, String name, int paramCount) diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TArrays.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TArrays.java index e91ee74c6..3347d658b 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TArrays.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TArrays.java @@ -1492,6 +1492,11 @@ public class TArrays extends TObject { @Override public T get(int index) { return a[index]; } + @Override public T set(int index, T element) { + T old = a[index]; + a[index] = element; + return old; + } @Override public int size() { return a.length; }