From 8c7905e9cc1c843b12c3ed87645492c3033acf47 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Sat, 7 Oct 2017 14:59:54 +0200 Subject: [PATCH] Adjusting TeaVM to forthcoming release of Apache HTML/Java API version 1.5 --- .../teavm/classlib/java/lang/TClassValue.java | 50 +++++++++++++++++++ .../classlib/java/nio/charset/TCharset.java | 5 ++ .../teavm/html4j/test/KnockoutTCKTest.java | 5 ++ pom.xml | 2 +- 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 classlib/src/main/java/org/teavm/classlib/java/lang/TClassValue.java diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TClassValue.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TClassValue.java new file mode 100644 index 000000000..e4db31c19 --- /dev/null +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TClassValue.java @@ -0,0 +1,50 @@ +/* + * Copyright 2013 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; + +public abstract class TClassValue extends TObject { + private Item items; + + protected TClassValue() { + } + + protected abstract T computeValue(Class clazz); + + public T get(Class clazz) { + Item it = items; + while (it != null) { + if (it.clazz == clazz) { + return it.value; + } + it = it.next; + } + T value = computeValue(clazz); + items = new Item(items, clazz, value); + return value; + } + + private class Item { + final Class clazz; + final T value; + final Item next; + + Item(Item next, Class clazz, T value) { + this.clazz = clazz; + this.value = value; + this.next = next; + } + } +} diff --git a/classlib/src/main/java/org/teavm/classlib/java/nio/charset/TCharset.java b/classlib/src/main/java/org/teavm/classlib/java/nio/charset/TCharset.java index 92e40b32a..90c4b1465 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/nio/charset/TCharset.java +++ b/classlib/src/main/java/org/teavm/classlib/java/nio/charset/TCharset.java @@ -80,6 +80,11 @@ public abstract class TCharset implements Comparable { return charset; } + public static TCharset defaultCharset() { + return charsets.get("UTF-8"); + } + + public final String name() { return canonicalName; } diff --git a/html4j/src/test/java/org/teavm/html4j/test/KnockoutTCKTest.java b/html4j/src/test/java/org/teavm/html4j/test/KnockoutTCKTest.java index 0208709ab..df5eb8e28 100644 --- a/html4j/src/test/java/org/teavm/html4j/test/KnockoutTCKTest.java +++ b/html4j/src/test/java/org/teavm/html4j/test/KnockoutTCKTest.java @@ -220,6 +220,11 @@ public class KnockoutTCKTest { knockoutTest.archetypeArrayModificationVisible(); } + @Test + public void fromJsonWithUTF8() throws Throwable { + jsonTest.fromJsonWithUTF8(); + } + @Test public void toJSONInABrowser() throws Throwable { jsonTest.toJSONInABrowser(); diff --git a/pom.xml b/pom.xml index 1c1945d0f..715ae555b 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ UTF-8 https://oss.sonatype.org/content/repositories/snapshots/ - 1.4 + 1.5 9.2.1.v20140609 1.7.7 2.47.2