Efficiency of Java Class.cast () compared to regular cast?

I am working on a generic class and I want to use Class.cast () to do some castings to avoid these nasty cast warning or @SupressWarning annotations for methods.

I think Class.cast () should be basically the same as casting. But, like all reflection methods, this may not be so. Does anyone know the exact difference between the two?

+3
source share
1 answer

I recommend using Class.cast () over @SuppressWarnings where possible.

There is no concern for performance here. If you have performance problems, the application profile, and I would be very surprised if this turned out to be a hot spot.

+3
source

All Articles