Move installHooks(LegacyHooks) from CodeHacker to LegacyInjector

The installHooks() method is really meant to run long, long, long time
after the code patching happened. Therefore, the CodeHacker class is
actually not the best place to put that method (but we did, in order to
be certain to insert the hooks into the correct class loader).

While at it, get rid of the setLegacyService() method: we do not set
the legacy service at all any longer, just the legacy hooks: it is their
task to connect everything to the correct legacy service.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Patch in the _hooks field in the LegacyInjector class

The CodeHacker is not supposed to know anything about ImageJ 1.x, just
about code patching.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Move the preinit() logic from DefaultLegacyService into LegacyInjector

This is another change in the overall project to separate better between
legacy code patching and the legacy service.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
CodeHacker: refactor the code printing the JavaAgent hint

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Allow LegacyInjector.preinit() to be called multiple times

The subsequent calls will simply verify that all was patched alright and
then return.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Always start with a fresh ClassPool when patching ImageJ 1.x

That way, we will be able to patch multiple ImageJ 1.x 'instances' in
different ClassLoaders with the same LegacyInjector instance.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Deprecate DefaultLegacyService's preinit() in favor of LegacyInjector's

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a class loader specifically for loading a patched ImageJ 1.x

This class loader will only find the ImageJ 1.x classes, plus
LegacyHooks and EssentialLegacyHooks. It will also patch the ImageJ
1.x classes appropriately and install an EssentialLegacyHooks instance.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
WIP: Add a "legacy environment", i.e. encapsulated ImageJ 1.x instances

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
WIP: Add a test for calling a fresh headless ImageJ 1.x

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Start a new projects: ij1-patcher

This project will not depend on ImageJ2, but ij-legacy will rely on
ij1-patcher to provide an appropriately patched ImageJ 1.x.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Extract utilities from SciJava-common into ij1-patcher

To be as useful as possible, the ij1-patcher project can have only
javassist as a dependency (and that only because there is simply no other
way to patch ImageJ 1.x efficiently).

Therefore, let's provide SciJava-common' utility functions required by the
classes we want to move into ij1-patcher.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Move some classes from ij-legacy into the new ij1-patcher

This change moves a self-contained set of classes related to
runtime-patching ImageJ 1.x from ij-legacy into ij1-patcher.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
TODOs