We're in a situation where we have a class "Base", which has a final toString() method.
We also have a final class "Sub" which extends "Base".
There's a requirement to do a change that's very specific and only applies to a miniscule subset of functionality, but can get pretty intrusive if done "properly".
The easiest way to achieve the change would be to override the toString method on a single instance of the "Sub" class. Creating a new single instance of Sub with the overriden toString() is also an option.
Is this possible to do? Any advice on how to do this?
Base.toString()method declaredfinal. If there is a good reason for that, then you shouldn't try to override it. Perhaps could you provide a sample of code so we can understand better what is at stake here ?toString()method? Also worth reading: What is the XY problem?