This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Continuation of JG04 from bug #183794. In practice there are some actions which simply cannot be registered using lazy factories, and convincing the action processor to use a traditional eager registration for them is cumbersome and error-prone: you have to know to implement a special interface like ContextAwareAction and then somehow implement it without changing semantics. While my original preference was for a separate annotation for such actions, an attribute lazy=false (with default being true) in @ActionRegistration would suffice. When lazy=false, the processor would create a traditional registration rather than using an Actions factory method. Attempting to use lazy=false would result in an error when only a factory method could make sense, e.g. the class implements only ActionListener and not Action, or it has a context constructor. For compatibility, existing (implicitly lazy=true) registrations on classes which implement ContextAwareAction, Presenter.*, or DynamicMenuContent would continue to processed as eager, but a warning should be issued. (To use a lazy factory, specify lazy=true explicitly; the processor can use AnnotationMirror.getElementValues to distinguish this case. Of course such registrations will not generally work as intended, but there might be reasons to do it.)
Created attachment 113935 [details] Proposed patch Includes API and processor impl; and updates to various existing registrations to specify lazy=false (in some cases removing dummy implementations of marker interfaces which existed solely to force this style).
Please review.
Will also add apichanges.xml entry of course.
core-main #316ede293415
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/316ede293415 User: Jesse Glick <jglick@netbeans.org> Log: #206093: allow an @ActionRegistration to be explicitly marked lazy or eager.