Skip to content

Commit 26bee8c

Browse files
committedJun 11, 2018
Fixes #5208. Encoding of String.name is ASCII-8BIT.
1 parent 3950c09 commit 26bee8c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

Diff for: ‎core/src/main/java/org/jruby/RubyModule.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import java.util.concurrent.ConcurrentHashMap;
5959
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
6060
import org.jcodings.Encoding;
61+
import org.jcodings.specific.USASCIIEncoding;
6162
import org.jruby.anno.AnnotationBinder;
6263
import org.jruby.anno.AnnotationHelper;
6364
import org.jruby.anno.FrameField;
@@ -611,7 +612,8 @@ private RubyString calculateRubyName() {
611612
Collections.reverse(parents);
612613

613614
RubyString colons = runtime.newString("::");
614-
RubyString fullName = runtime.newString();
615+
RubyString fullName = runtime.newString(); // newString creates empty ByteList which ends up as
616+
fullName.setEncoding(USASCIIEncoding.INSTANCE); // ASCII-8BIT. 8BIT is unfriendly to string concats.
615617
for (RubyString parent: parents) {
616618
fullName.cat19(parent).cat19(colons);
617619
}

0 commit comments

Comments
 (0)
Please sign in to comment.