From 2c902a26ece0891f8240fcb7c1c67542e7da7ccc Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 9 Apr 2013 18:44:54 -0600 Subject: [PATCH] handle non-ASCII strings properly in MyClasspath::makeString --- src/classpath-openjdk.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index c088b9b987..f39464b5cd 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -504,7 +504,23 @@ class MyClasspath : public Classpath { object charArray = makeCharArray(t, length); for (int i = 0; i < length; ++i) { - expect(t, (byteArrayBody(t, array, offset + i) & 0x80) == 0); + if (byteArrayBody(t, array, offset + i) & 0x80) { + object constructor = resolveMethod + (t, type(t, Machine::StringType), "", + "([BIILjava/lang/String;)V"); + PROTECT(t, constructor); + + object utf8 = vm::makeString(t, "UTF8"); + PROTECT(t, utf8); + + object s = makeNew(t, type(t, Machine::StringType)); + PROTECT(t, s); + + t->m->processor->invoke + (t, constructor, s, array, offset, length, utf8); + + return s; + } charArrayBody(t, charArray, i) = byteArrayBody(t, array, offset + i); }