diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TClassLoader.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TClassLoader.java index be243a747..e23b66e67 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TClassLoader.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TClassLoader.java @@ -53,6 +53,10 @@ public abstract class TClassLoader extends TObject { return dataString == null ? null : new ByteArrayInputStream(Base64.decode(dataString)); } + public static InputStream getSystemResourceAsStream(String name) { + return getSystemClassLoader().getResourceAsStream(name); + } + @JSBody(params = "resource", script = "return resource !== null && resource !== void 0 ? resource : null;") private static native String resourceToString(JSObject resource); diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/ref/TSoftReference.java b/classlib/src/main/java/org/teavm/classlib/java/lang/ref/TSoftReference.java new file mode 100644 index 000000000..5b20eef83 --- /dev/null +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/ref/TSoftReference.java @@ -0,0 +1,38 @@ +/* + * Copyright 2017 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.classlib.java.lang.ref; + +public class TSoftReference extends TReference { + private T value; + + public TSoftReference(T value) { + this.value = value; + } + + public TSoftReference(T value, @SuppressWarnings("unused") TReferenceQueue queue) { + this.value = value; + } + + @Override + public T get() { + return value; + } + + @Override + public void clear() { + value = null; + } +} diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/ref/TWeakReference.java b/classlib/src/main/java/org/teavm/classlib/java/lang/ref/TWeakReference.java index b3385efad..51bd9d723 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/ref/TWeakReference.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/ref/TWeakReference.java @@ -15,11 +15,6 @@ */ package org.teavm.classlib.java.lang.ref; -/** - * - * @author Alexey Andreev - * @param - */ public class TWeakReference extends TReference { private T value; diff --git a/tests/src/test/java/org/teavm/classlib/java/util/ResourceBundleTest.java b/tests/src/test/java/org/teavm/classlib/java/util/ResourceBundleTest.java index 7aa2dc376..170fdecb3 100644 --- a/tests/src/test/java/org/teavm/classlib/java/util/ResourceBundleTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/util/ResourceBundleTest.java @@ -84,7 +84,7 @@ public class ResourceBundleTest { // would be loaded. ResourceBundle.getBundle("org.apache.harmony.luni.tests.java.util.ResourceBundleTest$GetBundleTest"); } - }; + } @Test public void getBundleLjava_lang_String() { @@ -95,10 +95,4 @@ public class ResourceBundleTest { // expected } } - - protected void setUp() { - } - - protected void tearDown() { - } } diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java index 2a0dff753..53f90c51f 100644 --- a/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java +++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java @@ -518,6 +518,10 @@ public class TeaVMTool implements BaseTeaVMTool { } private void printStats() { + if (vm == null || vm.getWrittenClasses() == null) { + return; + } + int classCount = vm.getWrittenClasses().getClassNames().size(); int methodCount = 0; for (String className : vm.getWrittenClasses().getClassNames()) {