Repository: spack/spack

Issue:
open-jdk: a sketch of the package
currently fails with 
```
checking for version string... 9-internal+0-adhoc.davydden.jdk9
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
configure: Found potential Boot JDK using /usr/libexec/java_home 
configure: Potential Boot JDK found at  did not contain bin/java; ignoring
Unable to find any JVMs matching version "1.9".
No Java runtime present, try --request to install.
configure: Found potential Boot JDK using /usr/libexec/java_home -v 1.9
configure: Potential Boot JDK found at  did not contain bin/java; ignoring
Unable to find any JVMs matching version "1.8".
No Java runtime present, try --request to install.
configure: Found potential Boot JDK using /usr/libexec/java_home -v 1.8
configure: Potential Boot JDK found at  did not contain bin/java; ignoring
Unable to find any JVMs matching version "1.7".
No Java runtime present, try --request to install.
configure: Found potential Boot JDK using /usr/libexec/java_home -v 1.7
configure: Potential Boot JDK found at  did not contain bin/java; ignoring
checking for javac... /usr/bin/javac
checking for java... /usr/bin/java
configure: Could not find a valid Boot JDK. 
configure: This might be fixed by explicitly setting --with-boot-jdk
configure: error: Cannot continue
configure exiting with result code 1
```

I would probably not pursue this further, but still could be a starting point for others, thus `up-for-grabs`


Discussion:
Thanks @davydden!
I looked into this and there is some bootstrapping required via [IcedTea](http://icedtea.classpath.org/wiki/Main_Page).
I just looked into this and the best build instructions I've found so far are at: http://hg.openjdk.java.net/jdk9/jdk9/raw-file/tip/README-builds.html

According to the instructions, in order to install Open-JDK, you need to:

> Install a Bootstrap JDK. All OpenJDK builds require access to a previously released JDK called the bootstrap JDK or boot JDK. The general rule is that the bootstrap JDK must be an instance of the previous major release of the JDK. In addition, there may be a requirement to use a release at or beyond a particular update level.
>
> Building JDK 9 requires JDK 8. JDK 9 developers should not use JDK 9 as the boot JDK, to ensure that JDK 9 dependencies are not introduced into the parts of the system that are built with JDK 8.
>
> The JDK 8 binaries can be downloaded from Oracle's JDK 8 download site. For build performance reasons it is very important that this bootstrap JDK be made available on the local disk of the machine doing the build. You should add its bin directory to the PATH environment variable. If configure has any issues finding this JDK, you may need to use the configure option --with-boot-jdk.

I'll take a look at IcedTea next.

Btw, the `get_source.sh` script just clones a bunch of subrepos. We should probably add these as resources so that it can still be installed without internet access.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/openjdk/package.py b/var/spack/repos/builtin/packages/openjdk/package.py
new file mode 100644
--- /dev/null
+++ b/var/spack/repos/builtin/packages/openjdk/package.py
@@ -0,0 +1,98 @@
+# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+import os
+
+
+class Openjdk(Package):
+    """The free and opensource java implementation"""
+
+    homepage = "https://jdk.java.net"
+    url      = "https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz"
+
+    version('11.0.1', sha256='7a6bb980b9c91c478421f865087ad2d69086a0583aeeb9e69204785e8e97dcfd')
+
+    provides('java')
+    provides('java@11', when='@11.0:11.99')
+
+    # FIXME:
+    # 1. `extends('java')` doesn't work, you need to use `extends('openjdk')`
+    # 2. Packages cannot extend multiple packages, see #987
+    # 3. Update `YamlFilesystemView.merge` to allow a Package to completely
+    #    override how it is symlinked into a view prefix. Then, spack activate
+    #    can symlink all *.jar files to `prefix.lib.ext`
+    extendable = True
+
+    @property
+    def home(self):
+        """Most of the time, ``JAVA_HOME`` is simply ``spec['java'].prefix``.
+        However, if the user is using an externally installed JDK, it may be
+        symlinked. For example, on macOS, the ``java`` executable can be found
+        in ``/usr/bin``, but ``JAVA_HOME`` is actually
+        ``/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home``.
+        Users may not know the actual installation directory and add ``/usr``
+        to their ``packages.yaml`` unknowingly. Run ``java_home`` if it exists
+        to determine exactly where it is installed. Specify which version we
+        are expecting in case multiple Java versions are installed.
+        See ``man java_home`` for more details."""
+
+        prefix = self.prefix
+        java_home = prefix.libexec.java_home
+        if os.path.exists(java_home):
+            java_home = Executable(java_home)
+            version = str(self.version.up_to(2))
+            prefix = java_home('--version', version, output=str).strip()
+            prefix = Prefix(prefix)
+
+        return prefix
+
+    @property
+    def libs(self):
+        """Depending on the version number and whether the full JDK or just
+        the JRE was installed, Java libraries can be in several locations:
+
+        * ``lib/libjvm.so``
+        * ``jre/lib/libjvm.dylib``
+
+        Search recursively to find the correct library location."""
+
+        return find_libraries(['libjvm'], root=self.home, recursive=True)
+
+    def install(self, spec, prefix):
+        install_tree('.', prefix)
+
+    def setup_environment(self, spack_env, run_env):
+        """Set JAVA_HOME."""
+
+        run_env.set('JAVA_HOME', self.home)
+
+    def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
+        """Set JAVA_HOME and CLASSPATH.
+
+        CLASSPATH contains the installation prefix for the extension and any
+        other Java extensions it depends on."""
+
+        spack_env.set('JAVA_HOME', self.home)
+
+        class_paths = []
+        for d in dependent_spec.traverse(deptype=('build', 'run', 'test')):
+            if d.package.extends(self.spec):
+                class_paths.extend(find(d.prefix, '*.jar'))
+
+        classpath = os.pathsep.join(class_paths)
+        spack_env.set('CLASSPATH', classpath)
+
+        # For runtime environment set only the path for
+        # dependent_spec and prepend it to CLASSPATH
+        if dependent_spec.package.extends(self.spec):
+            class_paths = find(dependent_spec.prefix, '*.jar')
+            classpath = os.pathsep.join(class_paths)
+            run_env.prepend_path('CLASSPATH', classpath)
+
+    def setup_dependent_package(self, module, dependent_spec):
+        """Allows spec['java'].home to work."""
+
+        self.spec.home = self.home


Test patch: