I am developing a software game in which players will have access to an abstract class and extend it to control the behavior of the robot. Since this is a software game, I try to protect my gaming infrastructure so that players do not mess around with the game, and not just the class that I give them; for this I do most of my final classes, but now I canโt make fun of them in my unit tests (mockito + testNG).
So, I was wondering how can I get around this? there is a way, perhaps, to leave the classes not final for testing, and then somehow automatically โ final -izeโ them at a later stage of the build cycle (I use maven in case it is relevant for the answer). I do not want to add another external library or change my mocking library.
If this is not possible, then the second question: does the final class really be safe? I saw several libraries that could remove the final classifier from bytecode, which makes me think that maybe then final useless if it can be removed from an already compiled class
java maven unit-testing mockito mocking
Hilikus
source share