diff --git a/classlib/src/main/java/org/teavm/classlib/impl/Base64.java b/classlib/src/main/java/org/teavm/classlib/impl/Base64.java index 665469e87..f68a756a9 100644 --- a/classlib/src/main/java/org/teavm/classlib/impl/Base64.java +++ b/classlib/src/main/java/org/teavm/classlib/impl/Base64.java @@ -21,7 +21,7 @@ import java.util.Arrays; * * @author Alexey Andreev */ -public class Base64 { +public final class Base64 { private static char[] alphabet = new char[64]; private static int[] reverse = new int[256]; @@ -45,9 +45,13 @@ public class Base64 { } } + private Base64() { + } + public static byte[] decode(String text) { int outputSize = ((text.length() - 1) / 4 + 1) * 3; - int i, j; + int i; + int j; for (i = text.length() - 1; i >= 0 && text.charAt(i) == '='; --i) { --outputSize; } @@ -55,7 +59,7 @@ public class Base64 { int triples = (outputSize / 3) * 3; i = 0; - for (j = 0; i < triples;) { + for (j = 0; j < triples;) { int a = decode(text.charAt(i++)); int b = decode(text.charAt(i++)); int c = decode(text.charAt(i++)); @@ -63,7 +67,7 @@ public class Base64 { int out = (a << 18) | (b << 12) | (c << 6) | d; output[j++] = (byte) (out >>> 16); output[j++] = (byte) (out >>> 8); - output[j++] = (byte) (out); + output[j++] = (byte) out; } int rem = output.length - j; if (rem == 1) { diff --git a/tests/src/test/java/org/teavm/classlib/java/lang/ClassLoaderTest.java b/tests/src/test/java/org/teavm/classlib/java/lang/ClassLoaderTest.java index 24c65332a..e09db0d7a 100644 --- a/tests/src/test/java/org/teavm/classlib/java/lang/ClassLoaderTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/lang/ClassLoaderTest.java @@ -36,6 +36,7 @@ public class ClassLoaderTest { assertEquals("qwerty", loadResource("6")); assertEquals("qwertyu", loadResource("7")); assertEquals("qwertyui", loadResource("8")); + assertEquals("qwertyuiopasdfghjklzxcvbnm", loadResource("9")); } @Test diff --git a/tests/src/test/java/org/teavm/classlib/java/lang/TestResourcesSupplier.java b/tests/src/test/java/org/teavm/classlib/java/lang/TestResourcesSupplier.java index 0b9efa5bd..89261e252 100644 --- a/tests/src/test/java/org/teavm/classlib/java/lang/TestResourcesSupplier.java +++ b/tests/src/test/java/org/teavm/classlib/java/lang/TestResourcesSupplier.java @@ -21,7 +21,7 @@ import org.teavm.classlib.ResourceSupplierContext; public class TestResourcesSupplier implements ResourceSupplier { @Override public String[] supplyResources(ResourceSupplierContext context) { - String[] result = { "1", "2", "3", "4", "5", "6", "7", "8" }; + String[] result = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; for (int i = 0; i < result.length; ++i) { result[i] = "resources-for-test/" + result[i]; } diff --git a/tests/src/test/resources/resources-for-test/9 b/tests/src/test/resources/resources-for-test/9 new file mode 100644 index 000000000..62d04801f --- /dev/null +++ b/tests/src/test/resources/resources-for-test/9 @@ -0,0 +1 @@ +qwertyuiopasdfghjklzxcvbnm