From de117b61ed90ddde1cbbcb537f8560d7a19bc167 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Thu, 24 Dec 2015 07:59:41 +0100 Subject: [PATCH] Converts the resource from base64 encoding before returning it --- .../src/main/java/org/teavm/classlib/java/lang/TClass.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java index 22277a27a..4ea2a9129 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TClass.java @@ -15,6 +15,7 @@ */ package org.teavm.classlib.java.lang; +import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -272,7 +273,7 @@ public class TClass extends TObject implements TAnnotatedElement { @JSBody(params = "res", script = "if (!window.teaVMResources) return null;\n" + "var data = window.teaVMResources[res];\n" - + "return data ? data : null;\n" + + "return data ? window.atob(data) : null;\n" ) private static native String readResource(String message); @@ -285,6 +286,7 @@ public class TClass extends TObject implements TAnnotatedElement { } else { resName = clazzName.substring(0, lastDot).replace('.', '/') + "/" + name; } - throw new IllegalStateException("Read resource " + resName + " yields " + readResource(resName)); + String data = readResource(resName); + return data == null ? null : new ByteArrayInputStream(data.getBytes()); } }