diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TLong.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TLong.java index 0a022bd4f..286514306 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TLong.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TLong.java @@ -190,7 +190,7 @@ public class TLong extends TNumber implements TComparable { return toString(i, 2); } - public TString toString(long value) { + public static TString toString(long value) { return TString.wrap(new TStringBuilder().append(value).toString()); } diff --git a/teavm-core/src/main/java/org/teavm/tooling/ExceptionHelper.java b/teavm-core/src/main/java/org/teavm/tooling/ExceptionHelper.java new file mode 100644 index 000000000..41a8322e7 --- /dev/null +++ b/teavm-core/src/main/java/org/teavm/tooling/ExceptionHelper.java @@ -0,0 +1,29 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.tooling; + +/** + * + * @author Alexey Andreev + */ +final class ExceptionHelper { + private ExceptionHelper() { + } + + public static String showException(Throwable e) { + return e.getMessage(); + } +} diff --git a/teavm-core/src/main/java/org/teavm/tooling/TeaVMTestTool.java b/teavm-core/src/main/java/org/teavm/tooling/TeaVMTestTool.java index 9d70eca42..69f2738e2 100644 --- a/teavm-core/src/main/java/org/teavm/tooling/TeaVMTestTool.java +++ b/teavm-core/src/main/java/org/teavm/tooling/TeaVMTestTool.java @@ -290,10 +290,9 @@ public class TeaVMTestTool { } File file = new File(outputDir, targetName); try (Writer innerWriter = new OutputStreamWriter(new FileOutputStream(file), "UTF-8")) { - MethodReference cons = new MethodReference(methodRef.getClassName(), - new MethodDescriptor("", ValueType.VOID)); - MethodReference exceptionMsg = new MethodReference("java.lang.Throwable", "getMessage", - ValueType.object("java.lang.String")); + MethodReference cons = new MethodReference(methodRef.getClassName(), "", ValueType.VOID); + MethodReference exceptionMsg = new MethodReference(ExceptionHelper.class, "showException", + Throwable.class, String.class); vm.entryPoint("initInstance", cons); vm.entryPoint("runTest", methodRef).withValue(0, cons.getClassName()); vm.entryPoint("extractException", exceptionMsg); diff --git a/teavm-core/src/main/java/org/teavm/tooling/TestExceptionDependency.java b/teavm-core/src/main/java/org/teavm/tooling/TestExceptionDependency.java index bf447b030..a96fa2d13 100644 --- a/teavm-core/src/main/java/org/teavm/tooling/TestExceptionDependency.java +++ b/teavm-core/src/main/java/org/teavm/tooling/TestExceptionDependency.java @@ -19,15 +19,14 @@ import org.teavm.dependency.*; import org.teavm.model.ClassReader; import org.teavm.model.ClassReaderSource; import org.teavm.model.MethodReference; -import org.teavm.model.ValueType; /** * * @author Alexey Andreev */ class TestExceptionDependency implements DependencyListener { - private MethodReference getMessageRef = new MethodReference("java.lang.Throwable", "getMessage", - ValueType.object("java.lang.String")); + private MethodReference getMessageRef = new MethodReference(ExceptionHelper.class, "showException", + Throwable.class, String.class); private DependencyNode allClasses; @Override @@ -59,7 +58,7 @@ class TestExceptionDependency implements DependencyListener { @Override public void methodAchieved(DependencyAgent agent, MethodDependency method) { if (method.getReference().equals(getMessageRef)) { - allClasses.connect(method.getVariable(0)); + allClasses.connect(method.getVariable(1)); } }