Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 144123

Summary: WorkbenchPartAction calls overridable method in constructor
Product: [Tools] GEF Reporter: C. Lamont Gilbert <clg-business>
Component: GEF-Legacy GEF (MVC)Assignee: gef-inbox <gef-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: enhancement    
Priority: P3    
Version: 3.1.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description C. Lamont Gilbert CLA 2006-05-28 08:11:39 EDT
The class WorkbenchPartAction calls the overridable method init() during its construction.  This is bad practice as this can invoke behaviors on subclasses before the super class has finished construction.  Which is exactly what happened to me and produced my Null Pointer Exception.  Fortunately, NPEs are easy to track down.

If there are methods that must be called to put the object in a workable state, then a factory may be in order.
Comment 1 C. Lamont Gilbert CLA 2006-06-01 15:14:23 EDT
I changed this to an enhancement.  I don't mind if one closes it.  I was trolling through my old reports and noticed that I had reported a few other instances of this practice which seems to be ubiquitous throughout GEF/Eclipse.

Its a problem that I think should be fixed, but if its not going to be addressed then its just not going to be...
Comment 2 C. Lamont Gilbert CLA 2006-06-16 13:48:28 EDT
Im going to close this.  Ill try to refrain from reporting these types of things no matter how much I dislike it.

By its very nature, everytime the method is called it will be calling behavior from an object that is not done constructing.

On the other hand, the method is named init and you can see where its called from easily enough.