Currently TestNG just instantiates an object and then it uses it internally.
Now normally this is fine, but when it comes to having to use a test class instance as a key to a map internally within TestNG we loose the ability to allow the JVM to successfully GC test class objects as and when they aren't used.
The solution for this would be that TestNG starts wrapping test class instances it produces within an object container wherein it has a unique id. So that whenever we would like to use that object as the key, we could merely use the id associated with the object as the key.
A real time usecase for this can be seen in this and this discussion.