Fix tyop

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ij-legacy: Avoid linking directly into ImageJ 1.x

It was a mistake to assume that we have direct access to all the ImageJ
1.x classes and to assume as a consequence that we could just import
them left and right and not care about clean separation between ImageJ
1.x classes and ImageJ 2.x classes.

Now this comes back to bite us: in the current form, we would never be
able to interact with more than one ImageJ 1.x 'context' encapsulated in
its own class loader.

So what we will have to do now is undo the damage and introduce the
clean separation (which is pretty painful by now).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
LegacyTestUtils: we use CodeHacker directly now

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Be very careful to re-set the context class loader after legacy tests

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a better infrastructure for legacy hooks

We will add extension points in the next few commits that make sure that
the current legacy hooks (installed into ij.IJ._hooks) are called at the
appropriate time.

To avoid having to check ij.IJ._hooks for null all the time, the
EssentialLegacyHooks class is a fall-back, to be installed whenever
there are no other legacy hooks available.

This starts the process of disentangling the LegacyService from the
extension points inserted into ImageJ 1.x.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Implement legacy hooks for ImageJ2

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
LegacyInjector: add constructor with explicit headless mode

Rather than relying on the GraphicsEnvironment to know whether we want to
have a headless environment or not, let's have an explicit way to specify
that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Do not require a CodeHacker for injectHooks()

Let's try to avoid using the CodeHacker directly...

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Make LegacyJavaAgentIT less implementation-dependent

We are about to switch around a few things, in particular the assumption
that there is always a LegacyService available.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Remove obsolete patches for ij.macro.Functions

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Move IJFunctions into the LegacyInjector/LegacyHooks

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Move ImageJFunctions into LegacyInjector/LegacyHooks

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Move ImagePlusFunctions into LegacyInjector/LegacyHooks

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Move ImageWindowFunctions into LegacyInjector/LegacyHooks

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Move PluginClassLoaderFunctions into LegacyInjector/LegacyHooks

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Switch to Modern Mode: get the LegacyService through the Context

ImageJ 1.x should not know about any ImageJ2 classes explicitly...

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add an extension point for ij.IJ#runPlugIn()

Earlier, we overrode runPlugIn() to return the context and the legacy
service if the user asked for that class name.

However, since we want to keep the class loader in which ImageJ 1.x lives
free of ImageJ2 classes, we cannot do it that way any longer.

Instead, we add an extension point in the legacy hooks; that way, the
hooks can decide what they want to offer and what not.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Do not use $isLegacyMode() any longer

It is a method in the legacy hooks now. This will allow us to remove
the explicit LegacyService reference in ij.IJ.

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