[nbdev] Re: Static initialization blocks evil?

  • From: Jesse Glick < >
  • To:
  • Subject: [nbdev] Re: Static initialization blocks evil?
  • Date: Tue, 24 Jan 2012 04:37:05 -0500
  • Organization: Oracle Corp. / NetBeans

On 01/24/2012 03:42 AM, Emilian Bold wrote:
FoldViewFactory.register() was never called!

The expected call chain seems to be FoldHierarchy.class loaded -> static 
initialization block -> ensureApiAccessorRegistered() -> 
ApiPackageAccessor.register
-> FoldViewFactory.register().

This just looks silly. EditorViewFactory.factories() should use Lookup.getDefault().lookupAll(EditorViewFactory.Factory.class), and FoldViewFactory.FoldFactory and its ilk (HighlightsViewFactory.HighlightsFactory, TestHighlightsViewFactory.FactoryImpl) should be registered using @ServiceProvider. (Which would also obviate the need for the int importance() attribute, since @SP.position could be used.)

There are safe and correct reasons to use static initializers (such as ApiPackageAccessor.register, which works around the lack of a module-scoped access keyword in Java). FoldViewFactory.register() simply is not one of them.

Please file a bug report in the editor component blocking #121357. EditorViewFactory is not a public API (only used outside the module via impl dep in editor.fold) so it should not be a problem to change how it is used.



[nbdev] Static initialization blocks evil?

Emilian Bold 01/24/2012

[nbdev] Re: Static initialization blocks evil?

Jesse Glick 01/24/2012

[nbdev] Re: Static initialization blocks evil?

Emilian Bold 01/24/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 25 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20150226.965aeb8). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close