FileUtils: add routine to convert URL to File

The routine only works for file: and jar:file: URLs; other protocols
will throw IllegalArgumentException.
Fix ClassUtils#getLocation method

1) It now returns a URL instead of a File. The rationale is that
sometimes a class comes from a resource other than a file, but that
resource can always be expressed as a URL, as given by both:
  c.getResource(c.getName() + ".class")
and
  c.getProtectionDomain().getCodeSource().getLocation()

2) We first try the protection-domain-based route to obtaining the
class's base location, since it works within the OSGi framework.
Conversely, when used within OSGi, the getResource route does not
provide a sensible URL from which a file can be derived, but rather
gives a URL starting with "bundleresource://".
Merge branch 'osgi-resources'

This branch fixes problems with ClassUtils#getLocation when running with
the OSGi framework. The issue was essentially that calling
Class#getResource typically returns a URL of type 'bundleresource:/'
rather than 'jar:file:' or 'file:'. The workaround is to obtain the
containing JAR file through a different means:

  Class#getProtectionDomain().getCodeSource().getLocation()

While this approach can fail in theory (if the security manager does not
allow it due to insufficient permissions), in practice it seems to work
well.

As part of this fix, the CLassUtils#getLocation methods now
return a URL, which must be converted to a File in a separate step by
calling FileUtils#urlToFile(URL).

The practical consequence of this bugfix is that the ImageJ context's
version should now be set properly from the bundled POM file, even when
running within the OSGi framework (and hopefully other frameworks).
AppUtils: add getMainClass method

This enables querying of the class whose main method launched the
application. It is not perfect, but seems to work in practice.
AppUtils: be smarter about null baseSubdirectory

The getBaseDirectory(File, String) method allows specification of a
baseSubdirectory hint indicating the expected subdirectory structure
beneath which the class should be found. However, in some cases, we
cannot know what to expect, and so pass null for this hint.

Previously, a null hint was equivalent to the empty string; that is,
getBaseDirectory would return the containing directory directly, rather
than any ancestor directory. Unfortunately, that is not really the
correct behavior when querying any ImageJ class, since they all belong
to some submodule or other of the multi-module Maven project structure.

Hence, this change adds a heuristic that scans upward for Maven POMs.
Once a directory is found without a POM, it is assumed that the previous
directory is the toplevel one with respect to the ImageJ project
structure. This enables certain invocations to be more effective; e.g.:

  AppUtils.getBaseDirectory(AppUtils.getMainClass())

Previously, the above code would erroneously return some subfolder of
the ImageJ project structure. But since we pass a null hint,
getBaseDirectory now takes the liberty of searching for the true
base directory rather than a subdirectory thereof, using the heuristic
described above.

Of course, the heuristic will fail if a developer places a pom.xml file
in the parent directory of the ImageJ working copy. (And it can in fact
be useful to do that, to create a synthetic multi-module build that
includes ImageJ along with other projects.) But for most use cases the
heuristic is sufficient. If anyone complains, one potential solution
would be to actually parse the pom.xml files looking for values that
match the toplevel ImageJ POM.
AppUtils: generalize getBaseDirectory() logic

The getBaseDirectory() method now delegates to:

  getBaseDirectory(getMainClass())

in cases where searching from imagej.util.AppUtils fails.

This will happen, e.g., when running using "mvn exec:exec" from the
command line, since the imagej.util.AppUtils class will be contained in
a JAR file deep within ~/.m2/repository.

This change allows the base directory to be detected in more cases,
since it no longer assumes the main class is imagej.Main from ij-app.
Updater: fix ImageJ base directory detection

This change partially reverts commit
226a9f56cf9f1eb7dd41e6b73ea3898470a9d089.

With the preceding improvements to AppUtils.getBaseDirectory(), the
no-args signature is now robust enough to be called in this situation.

The rationale is that explicitly asking for the base directory with
respect to imagej.updater.util.Util.class will fail in the case where
that class is contained in a JAR file in the Maven local repository
cache. This is in fact the case when launching ImageJ via Maven
("mvn exec:exec" from the app subdirectory). Unfortunately, if the
Updater's Util class fails to detect the ImageJ base directory, its
static initializer throws an NPE, which means the class does not load.
This wreaks all sorts of havoc, and ImageJ fails to start up properly.
Updater: fix minor style issues and warnings
Merge branch 'master' into drawn-tools