Class discovery in Java

In Smalltalk (a.k.a OOP’s Latin), it takes a single call to get all the classes that inherit from class X:

X subclasses

It sounds like a bit of an exotic task, but actually it’s a single-liner for a plug-ins mechanism. Just load a class that extends “MyPlugIn” into the Smalltalk image and Voila! Your plug-in is loaded.

I thought that this mechanism is missing from Java (a.k.a Smalltalk-wannabe), until I found out that the good fellows from the Apache foundation did that too, and named it commons-discovery. The equivalent Java command is a bit more complicated: