diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-09-07 22:00:14 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2016-10-20 22:13:54 -0700 |
commit | 3c5990ce5839f4bdfca8fed7f2c415a72f6a8bd8 (patch) | |
tree | f82b0265bcec314991b8c53d1ff4a9586734f7bf /src | |
parent | 9d3f0777ff883a7c59da3fa7fee156890f51701e (diff) | |
download | scala-3c5990ce5839f4bdfca8fed7f2c415a72f6a8bd8.tar.gz scala-3c5990ce5839f4bdfca8fed7f2c415a72f6a8bd8.tar.bz2 scala-3c5990ce5839f4bdfca8fed7f2c415a72f6a8bd8.zip |
SI-9915 Utf8_info are modified UTF8
Use DataInputStream.readUTF to read CONSTANT_Utf8_info.
This fixes reading embedded null char and supplementary chars.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index f8c1a0d082..10e18eed00 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -8,7 +8,7 @@ package tools.nsc package symtab package classfile -import java.io.{File, IOException} +import java.io.{ByteArrayInputStream, DataInputStream, File, IOException} import java.lang.Integer.toHexString import scala.collection.{immutable, mutable} import scala.collection.mutable.{ArrayBuffer, ListBuffer} @@ -206,10 +206,14 @@ abstract class ClassfileParser { case name: Name => name case _ => val start = firstExpecting(index, CONSTANT_UTF8) - recordAtIndex(newTermName(in.buf, start + 2, in.getChar(start).toInt), index) + val len = in.getChar(start).toInt + recordAtIndex(TermName(fromMUTF8(in.buf, start, len + 2)), index) } ) + private def fromMUTF8(bytes: Array[Byte], offset: Int, len: Int): String = + new DataInputStream(new ByteArrayInputStream(bytes, offset, len)).readUTF + /** Return the name found at given index in the constant pool, with '/' replaced by '.'. */ def getExternalName(index: Int): Name = { if (index <= 0 || len <= index) |