The disadvantages of wrapper classes are few. One caveat is that wrapper classes are not suited for use in callback frameworks, wherein objects pass self references to other objects for subsequent invocations (“callbacks”). Because a wrapped object doesn’t know of its wrapper, it passes a reference to itself (this) and callbacks elude the wrapper.
Can someone explain what this means with an example perhaps. It is written in Effective Java but I did not completely understand it.
Aucun commentaire:
Enregistrer un commentaire