You need to understand generics, and how type erasure makes compile-time
and run-time type information different.
At compile time, it's a Map<String, String>, or a Map<String, byte[]>,
or Object.
At runtime, it is always Map, or (equivalently) Map<?,?>.
Casting does not change the run-time type of the object, it will still
be a Map.
A cast from Object to Map<String, byte[]> will make the Java compiler
insert a check that the run-time object is indeed a Map, but it will not
check the data elements. I.e. the runtime type is Map<?,?> - it's a Map,
but the key and values could be any type, the JVM does not know (the
information about the key and value types is "erased", that's what "type
erasure" means).
Since Java is supposed to be a safe language, the type checks happen
whenever a specific key or value is accessed.
Actually the checks will *always* happen. If you have a
Map<String,byte[]>, when writing a value the byte[] will be cast to
Object (which is zero-cost) and cast back to byte[] when your code reads
from the Map and assigns to a byte[] variable.
Conversions between String and byte[] happen if and only if you
explicitly write that in your code, there's no automatic conversion for
that.
Am 27.05.21 um 11:24 schrieb Sheena Chawla:
> <mailto:
kryo-users+...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/kryo-users/a6b11ba6-40ea-4420-9800-7c5e7fae26ccn%40googlegroups.com
> <
https://groups.google.com/d/msgid/kryo-users/a6b11ba6-40ea-4420-9800-7c5e7fae26ccn%40googlegroups.com?utm_medium=email&utm_source=footer>.