Let JavaAgent also watch out for prematurely loaded EssentialLegacyHooks

The EssentialLegacyHooks class is now also patched, to configure legacy
environments to the specifications of the caller. Therefore, loading the
class too early causes problems.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a method to the LegacyEnvironment to apply the patches

When the caller wants to use (patched) ImageJ 1.x classes, but not start
ImageJ 1.x, nor run a macro or plugin, this method can be used to force
the patches to be applied. Further configuration of the
LegacyEnvironment is no longer possible afterwards.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add API to instantiate a new ImageJ 1.x without running main()

In some cases, we definitely want to disable command-line argument
processing, and just get a hidden (or even headless) ImageJ 1.x
instance. This method allows that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a method to check for a running ImageJ 1.x instance gently

Callers who want to run a patched ImageJ 1.x and want to verify that
there is not yet a running ImageJ 1.x instance need to be very careful
*not* to load any ImageJ 1.x classes to perform that check. In
particular, the caller *cannot* test `IJ.getInstance() != null`.

The method `LegacyEnvironment#isImageJ1Initialized(ClassLoader)`
performs such a careful check: if it returns true, there is already
a running instance. If it returns false, we can still apply patches.
If the ImageJ 1.x classes were already loaded, unpatched, this method
throws an exception.

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