'. '

FriendDependencies

From APIDesign

Revision as of 06:03, 13 September 2011 by JaroslavTulach (Talk | contribs)
Jump to: navigation, search

Concept of friends is almost essential for Modularity. Not all exported APIs are stable enough, not all of them are ready for public consumption. In such case one needs to create a module, define its API, but restrict list of friends that may access it.

NetBeans Friends Support

The NetBeans Runtime Container has first class support for friends. Inside manifest one can enumerate the names of modules that may access given API. Surprisingly, this list of friends is an API of the module itself. In case you change the list, you are changing the module API and you need to properly version such change.

Recently we had to deal with a bug Template:Iz - suddenly one module was getting NoClassDefFoundError when trying to access a Lexer class from another module. The Lexer class existed since the creation of its module, so it was a mistery for all of us. How could a class not be found, if it exists for ages?

Is the installation corrupted? was our first question. No, it was not. We received the same report from multiple users. Thus we could rule out random error. Something in our shared infrastructure must get broken.

Is there are problem in initialized? is a second question to ask. Sometimes, when a class throws an exception from one of its static initializers, it becomes unavailable for the JVM. Later, if any other class references the broken one, a NoClassDefFoundError is generated at very unexpected places. However this was not the problem either. There was no other exception in the log files!

A complete mistery.


TBD describe what friend dependencies are. Talk about the sad case of bug #201021

Personal tools
buy