I am reading Effective Java and it has the following sentence.

The disadvantages of wrapper classes are few. One caveat is that wrapper classes are not suited for use in callback frameworks, wherein objects pass selfreferences to other objects for subsequent invocations (“callbacks”).

Now what is a callback framework ? Can you point me to an example of call back framework ?

  • This sentence seems to be a bit out of context. Could you tell us in which section this sentence appears ?
    – barjak
    Nov 2, 2011 at 10:05
  • Additionally: "Why are wrapper classes not suited for use in callback frameworks?" Nov 3, 2011 at 7:45
  • 1
    @barjak this is from Chapter 4 (Classes and Interfaces), page 85. books.google.com/… Nov 3, 2011 at 11:42
  • Ok, so the term "wrapper class" here refers to a class that uses composition instead of inheritance. And the caveat that is discussed in this paragraph happens when the "wrapped" class implements a callback interface and registers himself as a callback object. Personnaly, I think it's a bad style for a class to implement callback interfaces, anyway. So the caveat goes away...
    – barjak
    Nov 3, 2011 at 14:17
  • If you mean the frameworks having callback classes , here is the list of frameworks having that - javasearch.buggybread.com/home.php?keyword=callback Feb 15, 2016 at 20:36

2 Answers 2


Most GUI frameworks, and, SAX (Streaming XML) XML parsers use callbacks.

The basic pattern is that you pass an instance of a handler class (or sometimes just a method reference) when you initialize another class. When a specific event occurs the "handler" class is called to deal with the event.

This is typically how you get your code to run when a button on a GUI is pressed.


many gui frameworks are callback frameworks (functions are called as events happen)

any time you have to provide handlers for events you are using a callback framework

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.