rootvector2 commented on PR #505:
URL: https://github.com/apache/commons-bcel/pull/505#issuecomment-4753203627

   Thanks for merging. I went through those six and they're all reading signed 
operands, not u2 indices, so `readShort()` is correct there:
   
   - `BranchInstruction.initFromFile`, plus the goto/if branch cases in 
`Utility.codeToString` and `CodeHTML` read branch offsets, which are signed by 
definition (a backward branch is negative).
   - `SIPUSH.initFromFile` and the `T_SHORT` operand case read the `sipush` 
immediate, a signed short that's sign-extended to int.
   - `IINC` reads the increment `const`, also signed and sign-extended.
   
   Where those same disassembly paths read an actual index they already use 
`readUnsignedShort()` (multianewarray's index, the wide `iinc` local index), so 
reading them unsigned would actually break negative offsets/immediates. 
`ConstantDynamic` was the one outlier because both its fields are u2 
constant-pool indices. I found it by grepping the constant-pool parsers 
specifically rather than the operand readers, which is why those didn't come up.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to