RFR(XS): 8143127: InvokerBytecodeGenerator emitConst should handle Byte, Short, Character

Remi Forax forax at univ-mlv.fr
Tue Nov 17 21:13:56 UTC 2015


Hi Claes,
I fail to see how this code will not throw a CCE at runtime
  if (con instanceof Integer || con instanceof Byte || con instanceof Short || con instanceof Character) {
     emitIconstInsn((int) con); 
     ...

(int)con is translated by the compiler to ((Integer)con).intValue()

you have to write something like that
  (con instanceof Character)? (char)con: ((Number)con).intValue()

cheers,
Rémi

----- Mail original -----
> De: "Claes Redestad" <claes.redestad at oracle.com>
> À: "core-libs-dev at openjdk.java.net Libs" <core-libs-dev at openjdk.java.net>
> Envoyé: Mardi 17 Novembre 2015 17:17:50
> Objet: RFR(XS): 8143127: InvokerBytecodeGenerator emitConst should handle	Byte, Short, Character
> 
> Hi,
> 
> this small patch allows InvokerBytecodeGenerator to generate more
> compact bytecode for small byte, short and char constants:
> 
> webrev: http://cr.openjdk.java.net/~redestad/8143127/webrev.01/
> bug: https://bugs.openjdk.java.net/browse/JDK-8143127
> 
> /Claes
> 



More information about the core-libs-dev mailing list