Strict long type casting
Ty Young
youngty1997 at gmail.com
Tue Apr 7 00:49:25 UTC 2020
Hi all,
I'm trying to create a way of reading primitive number based struct
values(since VarHandle.get is polymorphic) by combining Java's Number
abstract class with my abstraction like so:
public abstract class MemoryNumber<E extends Number> extends Number
implements MemoryValue<E>
Which is then extended by classes like "MemoryLong".
The problem here is that with long(and only long) the type casting is
strict and fails. Attempting to call byteValue() fails on intValue().
This doesn't, for whatever reason, happen with normal on-heap long
values nor does it happen with an MemoryInt implementation either.
I tried looking in the source code of Long.class and I couldn't find
anything that I was doing differently besides using Panama, so I'm a bit
lost here. Does anyone know what's going on?
More information about the panama-dev
mailing list