@@ -7,7 +7,7 @@ import Contexts._, Symbols._, Types._, Names._, StdNames._, NameOps._, Scopes._,
7
7
import SymDenotations ._ , unpickleScala2 .Scala2Unpickler ._ , Constants ._ , Annotations ._ , util .Positions ._
8
8
import NameKinds .{ModuleClassName , DefaultGetterName }
9
9
import ast .tpd ._
10
- import java .io .{ ByteArrayInputStream , DataInputStream , File , IOException }
10
+ import java .io .{ ByteArrayInputStream , ByteArrayOutputStream , DataInputStream , File , IOException }
11
11
import java .nio
12
12
import java .lang .Integer .toHexString
13
13
import java .net .URLClassLoader
@@ -795,11 +795,15 @@ class ClassfileParser(
795
795
val path = classfile.path.stripSuffix(" .class" ) + " .tasty"
796
796
val stream = cl.getResourceAsStream(path)
797
797
if (stream != null ) {
798
- val tasty = Array .newBuilder[Byte ]
799
- tasty.sizeHint(stream.available())
800
- while (stream.available() > 0 ) // TODO improve performance
801
- tasty += stream.read().toByte
802
- tasty.result()
798
+ val tastyOutStream = new ByteArrayOutputStream ()
799
+ val buffer = new Array [Byte ](1024 )
800
+ var read = stream.read(buffer, 0 , buffer.length)
801
+ while (read != - 1 ) {
802
+ tastyOutStream.write(buffer, 0 , read)
803
+ read = stream.read(buffer, 0 , buffer.length)
804
+ }
805
+ tastyOutStream.flush()
806
+ tastyOutStream.toByteArray
803
807
} else {
804
808
ctx.error(s " Could not find $path in $jar" )
805
809
Array .empty
0 commit comments