diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-07-22 20:51:05 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2015-07-24 22:06:00 +0200 |
commit | 2678d349b2b2738d9db38d890199f32aa39d8c3e (patch) | |
tree | 2d420e28c24abf278d674cf74549bdf0e4c88686 /src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala | |
parent | 0e9525aa618a2eca143a1c7379ff1e6efd23b86e (diff) | |
download | scala-2678d349b2b2738d9db38d890199f32aa39d8c3e.tar.gz scala-2678d349b2b2738d9db38d890199f32aa39d8c3e.tar.bz2 scala-2678d349b2b2738d9db38d890199f32aa39d8c3e.zip |
SI-9403 fix ICodeReader for negative BIPUSH / SIPUSH values
The byte value of a BIPUSH instruction and the (byte1 << 8) | byte2
value of a SIPUSH instruction are signed, see [1] and [2].
Similar for the increment value of IINC [3].
[1] https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.bipush
[2] https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.sipush
[3] https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.iinc
Diffstat (limited to 'src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 660028eab8..74b531a0d9 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -84,6 +84,9 @@ abstract class ClassfileParser { protected final def u2(): Int = in.nextChar.toInt protected final def u4(): Int = in.nextInt + protected final def s1(): Int = in.nextByte.toInt // sign-extend the byte to int + protected final def s2(): Int = (in.nextByte.toInt << 8) | u1 // sign-extend and shift the first byte, or with the unsigned second byte + private def readInnerClassFlags() = readClassFlags() private def readClassFlags() = JavaAccFlags classFlags u2 private def readMethodFlags() = JavaAccFlags methodFlags u2 |