Forums Register Login

My serialization class - warning

+Pie Number of slices to send: Send
Hi,
I wrote class to write and read serialization objects. I used generalized types but i had one warning whose i don't understand.
Code:


Using:


Program works correctly but in line 8 my Eclipse says: "Type safety: Unchecked cast from Object to T". What does this mean ?
+Pie Number of slices to send: Send
Because of type erasure, the generic type is no longer available at runtime. That means that the JVM cannot check at that point if the cast is valid. If the object is not a T then you will get a ClassCastException, only at a different point in your code. It will be harder to trace back the cause to the unsafe cast.
They weren't very bright, but they were very, very big. Ad contrast:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1368 times.
Similar Threads
Why not its ClassCastException?
Serializable and Thread
please explain the output
Loading POJO object without loading library first
is static variables serialized?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:19:32.