We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Installation issue with openjdk:  "Error: NameError: name 'Prefix' is not defined"
### Steps to reproduce the issue

Latest spack develop on OS X gives:

```console
 → spack install -v hpcviewer
==> Warning: Missing a source id for openjdk@11.0.10_9
[+] /usr (external openjdk-11.0.10_9-eoscwsxi5erdz5htmnixttlxjzhogare)
==> Installing hpcviewer-2021.03-a4q2ajczhy6u5dxcdszfx3lelqbf7tmd
==> No binary for hpcviewer-2021.03-a4q2ajczhy6u5dxcdszfx3lelqbf7tmd found: installing from source
==> Warning: Missing a source id for openjdk@11.0.10_9
==> Warning: microarchitecture specific optimizations are not supported yet on mixed compiler toolchains [check apple-clang@12.0.0 for further details]
==> Error: NameError: name 'Prefix' is not defined
```

### Information on your system

* Mac OS 10.15.5
* Spack cloned today

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `var/spack/repos/builtin/packages/openjdk/package.py`
Content:
```
1 # Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
2 # Spack Project Developers. See the top-level COPYRIGHT file for details.
3 #
4 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
5 
6 import os
7 import platform
8 import re
9 
10 
11 # If you need to add a new version, please be aware that:
12 #  - versions in the following dict are automatically added to the package
13 #  - version tuple must be in the form (checksum, url)
14 #  - checksum must be sha256
15 #  - package key must be in the form '{os}-{arch}' where 'os' is in the
16 #    format returned by platform.system() and 'arch' by platform.machine()
17 
18 _versions = {
19     '11.0.9.1_1': {
20         'Linux-ppc64le': ('d94b6b46a14ab0974b1c1b89661741126d8cf8a0068b471b8f5fa286a71636b1', 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9.1%2B1/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.9.1_1.tar.gz')},
21     '11.0.8_10': {
22         'Linux-x86_64': ('6e4cead158037cb7747ca47416474d4f408c9126be5b96f9befd532e0a762b47', 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.8_10.tar.gz')},
23     '11.0.0-2020-01-01': {
24         'Linux-aarch64': ('05c7d9c90edacd853850fbb0f52f8aa482809d0452c599cb9fe0b28b3b4bf329', 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk11u-2020-01-01-06-13/OpenJDK11U-jdk_aarch64_linux_hotspot_2020-01-01-06-13.tar.gz')},
25     '11.0.2': {
26         'Linux-x86_64': ('99be79935354f5c0df1ad293620ea36d13f48ec3ea870c838f20c504c9668b57', 'https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz')},
27     '11.0.1': {
28         'Linux-x86_64': ('7a6bb980b9c91c478421f865087ad2d69086a0583aeeb9e69204785e8e97dcfd', 'https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz')},
29     '1.8.0_265-b01': {
30         'Linux-x86_64': ('1285da6278f2d38a790a21148d7e683f20de0799c44b937043830ef6b57f58c4', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u265-b01/OpenJDK8U-jdk_x64_linux_hotspot_8u265b01.tar.gz')},
31     '1.8.0_191-b12': {
32         'Linux-aarch64': ('8eee0aede947b804f9a5f49c8a38b52aace8a30a9ebd9383b7d06042fb5a237c', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u191-b12/OpenJDK8U-jdk_aarch64_linux_hotspot_8u191b12.tar.gz')},
33     '1.8.0_222-b10': {
34         'Linux-x86_64': ('20cff719c6de43f8bb58c7f59e251da7c1fa2207897c9a4768c8c669716dc819', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u222-b10_openj9-0.15.1/OpenJDK8U-jdk_x64_linux_openj9_8u222b10_openj9-0.15.1.tar.gz')},
35     '1.8.0_202-b08': {
36         'Linux-x86_64': ('533dcd8d9ca15df231a1eb392fa713a66bca85a8e76d9b4ee30975f3823636b7', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u202-b08/OpenJDK8U-jdk_x64_linux_openj9_8u202b08_openj9-0.12.0.tar.gz')},
37     '1.8.0_40-b25': {
38         'Linux-x86_64': ('79e96dce03a14271040023231a7d0ae374b755d48adf68bbdaec30294e4e2b88', 'https://download.java.net/openjdk/jdk8u40/ri/jdk_ri-8u40-b25-linux-x64-10_feb_2015.tar.gz')},
39 }
40 
41 
42 class Openjdk(Package):
43     """The free and opensource java implementation"""
44 
45     homepage = "https://jdk.java.net"
46 
47     for ver, packages in _versions.items():
48         key = "{0}-{1}".format(platform.system(), platform.machine())
49         pkg = packages.get(key)
50         if pkg:
51             version(ver, sha256=pkg[0], url=pkg[1])
52 
53     provides('java@11', when='@11.0:11.99')
54     provides('java@10', when='@10.0:10.99')
55     provides('java@9', when='@9.0:9.99')
56     provides('java@8', when='@1.8.0:1.8.999')
57 
58     conflicts('target=ppc64:', msg='openjdk is not available for ppc64 (big endian)')
59 
60     # FIXME:
61     # 1. `extends('java')` doesn't work, you need to use `extends('openjdk')`
62     # 2. Packages cannot extend multiple packages, see #987
63     # 3. Update `YamlFilesystemView.merge` to allow a Package to completely
64     #    override how it is symlinked into a view prefix. Then, spack activate
65     #    can symlink all *.jar files to `prefix.lib.ext`
66     extendable = True
67 
68     executables = ['^java$']
69 
70     @classmethod
71     def determine_version(cls, exe):
72         output = Executable(exe)('-version', output=str, error=str)
73 
74         # Make sure this is actually OpenJDK, not Oracle JDK
75         if 'openjdk' not in output:
76             return None
77 
78         match = re.search(r'\(build (\S+)\)', output)
79         return match.group(1).replace('+', '_') if match else None
80 
81     @property
82     def home(self):
83         """Most of the time, ``JAVA_HOME`` is simply ``spec['java'].prefix``.
84         However, if the user is using an externally installed JDK, it may be
85         symlinked. For example, on macOS, the ``java`` executable can be found
86         in ``/usr/bin``, but ``JAVA_HOME`` is actually
87         ``/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home``.
88         Users may not know the actual installation directory and add ``/usr``
89         to their ``packages.yaml`` unknowingly. Run ``java_home`` if it exists
90         to determine exactly where it is installed. Specify which version we
91         are expecting in case multiple Java versions are installed.
92         See ``man java_home`` for more details."""
93 
94         prefix = self.prefix
95         java_home = prefix.libexec.java_home
96         if os.path.exists(java_home):
97             java_home = Executable(java_home)
98             version = str(self.version.up_to(2))
99             prefix = java_home('--version', version, output=str).strip()
100             prefix = Prefix(prefix)
101 
102         return prefix
103 
104     @property
105     def libs(self):
106         """Depending on the version number and whether the full JDK or just
107         the JRE was installed, Java libraries can be in several locations:
108 
109         * ``lib/libjvm.so``
110         * ``jre/lib/libjvm.dylib``
111 
112         Search recursively to find the correct library location."""
113 
114         return find_libraries(['libjvm'], root=self.home, recursive=True)
115 
116     def install(self, spec, prefix):
117         install_tree('.', prefix)
118 
119     def setup_run_environment(self, env):
120         """Set JAVA_HOME."""
121 
122         env.set('JAVA_HOME', self.home)
123 
124     def setup_dependent_build_environment(self, env, dependent_spec):
125         """Set JAVA_HOME and CLASSPATH.
126 
127         CLASSPATH contains the installation prefix for the extension and any
128         other Java extensions it depends on."""
129 
130         env.set('JAVA_HOME', self.home)
131 
132         class_paths = []
133         for d in dependent_spec.traverse(deptype=('build', 'run', 'test')):
134             if d.package.extends(self.spec):
135                 class_paths.extend(find(d.prefix, '*.jar'))
136 
137         classpath = os.pathsep.join(class_paths)
138         env.set('CLASSPATH', classpath)
139 
140     def setup_dependent_run_environment(self, env, dependent_spec):
141         """Set CLASSPATH.
142 
143         CLASSPATH contains the installation prefix for the extension and any
144         other Java extensions it depends on."""
145         # For runtime environment set only the path for
146         # dependent_spec and prepend it to CLASSPATH
147         if dependent_spec.package.extends(self.spec):
148             class_paths = find(dependent_spec.prefix, '*.jar')
149             classpath = os.pathsep.join(class_paths)
150             env.prepend_path('CLASSPATH', classpath)
151 
152     def setup_dependent_package(self, module, dependent_spec):
153         """Allows spec['java'].home to work."""
154 
155         self.spec.home = self.home
156
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/var/spack/repos/builtin/packages/openjdk/package.py b/var/spack/repos/builtin/packages/openjdk/package.py
--- a/var/spack/repos/builtin/packages/openjdk/package.py
+++ b/var/spack/repos/builtin/packages/openjdk/package.py
@@ -7,6 +7,7 @@
 import platform
 import re
 
+from spack.util.prefix import Prefix
 
 # If you need to add a new version, please be aware that:
 #  - versions in the following dict are automatically added to the package

{"golden_diff": "diff --git a/var/spack/repos/builtin/packages/openjdk/package.py b/var/spack/repos/builtin/packages/openjdk/package.py\n--- a/var/spack/repos/builtin/packages/openjdk/package.py\n+++ b/var/spack/repos/builtin/packages/openjdk/package.py\n@@ -7,6 +7,7 @@\n import platform\n import re\n \n+from spack.util.prefix import Prefix\n \n # If you need to add a new version, please be aware that:\n #  - versions in the following dict are automatically added to the package\n", "issue": "Installation issue with openjdk:  \"Error: NameError: name 'Prefix' is not defined\"\n### Steps to reproduce the issue\r\n\r\nLatest spack develop on OS X gives:\r\n\r\n```console\r\n \u2192 spack install -v hpcviewer\r\n==> Warning: Missing a source id for openjdk@11.0.10_9\r\n[+] /usr (external openjdk-11.0.10_9-eoscwsxi5erdz5htmnixttlxjzhogare)\r\n==> Installing hpcviewer-2021.03-a4q2ajczhy6u5dxcdszfx3lelqbf7tmd\r\n==> No binary for hpcviewer-2021.03-a4q2ajczhy6u5dxcdszfx3lelqbf7tmd found: installing from source\r\n==> Warning: Missing a source id for openjdk@11.0.10_9\r\n==> Warning: microarchitecture specific optimizations are not supported yet on mixed compiler toolchains [check apple-clang@12.0.0 for further details]\r\n==> Error: NameError: name 'Prefix' is not defined\r\n```\r\n\r\n### Information on your system\r\n\r\n* Mac OS 10.15.5\r\n* Spack cloned today\n", "before_files": [{"content": "# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other\n# Spack Project Developers. See the top-level COPYRIGHT file for details.\n#\n# SPDX-License-Identifier: (Apache-2.0 OR MIT)\n\nimport os\nimport platform\nimport re\n\n\n# If you need to add a new version, please be aware that:\n#  - versions in the following dict are automatically added to the package\n#  - version tuple must be in the form (checksum, url)\n#  - checksum must be sha256\n#  - package key must be in the form '{os}-{arch}' where 'os' is in the\n#    format returned by platform.system() and 'arch' by platform.machine()\n\n_versions = {\n    '11.0.9.1_1': {\n        'Linux-ppc64le': ('d94b6b46a14ab0974b1c1b89661741126d8cf8a0068b471b8f5fa286a71636b1', 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9.1%2B1/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.9.1_1.tar.gz')},\n    '11.0.8_10': {\n        'Linux-x86_64': ('6e4cead158037cb7747ca47416474d4f408c9126be5b96f9befd532e0a762b47', 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.8_10.tar.gz')},\n    '11.0.0-2020-01-01': {\n        'Linux-aarch64': ('05c7d9c90edacd853850fbb0f52f8aa482809d0452c599cb9fe0b28b3b4bf329', 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk11u-2020-01-01-06-13/OpenJDK11U-jdk_aarch64_linux_hotspot_2020-01-01-06-13.tar.gz')},\n    '11.0.2': {\n        'Linux-x86_64': ('99be79935354f5c0df1ad293620ea36d13f48ec3ea870c838f20c504c9668b57', 'https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz')},\n    '11.0.1': {\n        'Linux-x86_64': ('7a6bb980b9c91c478421f865087ad2d69086a0583aeeb9e69204785e8e97dcfd', 'https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz')},\n    '1.8.0_265-b01': {\n        'Linux-x86_64': ('1285da6278f2d38a790a21148d7e683f20de0799c44b937043830ef6b57f58c4', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u265-b01/OpenJDK8U-jdk_x64_linux_hotspot_8u265b01.tar.gz')},\n    '1.8.0_191-b12': {\n        'Linux-aarch64': ('8eee0aede947b804f9a5f49c8a38b52aace8a30a9ebd9383b7d06042fb5a237c', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u191-b12/OpenJDK8U-jdk_aarch64_linux_hotspot_8u191b12.tar.gz')},\n    '1.8.0_222-b10': {\n        'Linux-x86_64': ('20cff719c6de43f8bb58c7f59e251da7c1fa2207897c9a4768c8c669716dc819', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u222-b10_openj9-0.15.1/OpenJDK8U-jdk_x64_linux_openj9_8u222b10_openj9-0.15.1.tar.gz')},\n    '1.8.0_202-b08': {\n        'Linux-x86_64': ('533dcd8d9ca15df231a1eb392fa713a66bca85a8e76d9b4ee30975f3823636b7', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u202-b08/OpenJDK8U-jdk_x64_linux_openj9_8u202b08_openj9-0.12.0.tar.gz')},\n    '1.8.0_40-b25': {\n        'Linux-x86_64': ('79e96dce03a14271040023231a7d0ae374b755d48adf68bbdaec30294e4e2b88', 'https://download.java.net/openjdk/jdk8u40/ri/jdk_ri-8u40-b25-linux-x64-10_feb_2015.tar.gz')},\n}\n\n\nclass Openjdk(Package):\n    \"\"\"The free and opensource java implementation\"\"\"\n\n    homepage = \"https://jdk.java.net\"\n\n    for ver, packages in _versions.items():\n        key = \"{0}-{1}\".format(platform.system(), platform.machine())\n        pkg = packages.get(key)\n        if pkg:\n            version(ver, sha256=pkg[0], url=pkg[1])\n\n    provides('java@11', when='@11.0:11.99')\n    provides('java@10', when='@10.0:10.99')\n    provides('java@9', when='@9.0:9.99')\n    provides('java@8', when='@1.8.0:1.8.999')\n\n    conflicts('target=ppc64:', msg='openjdk is not available for ppc64 (big endian)')\n\n    # FIXME:\n    # 1. `extends('java')` doesn't work, you need to use `extends('openjdk')`\n    # 2. Packages cannot extend multiple packages, see #987\n    # 3. Update `YamlFilesystemView.merge` to allow a Package to completely\n    #    override how it is symlinked into a view prefix. Then, spack activate\n    #    can symlink all *.jar files to `prefix.lib.ext`\n    extendable = True\n\n    executables = ['^java$']\n\n    @classmethod\n    def determine_version(cls, exe):\n        output = Executable(exe)('-version', output=str, error=str)\n\n        # Make sure this is actually OpenJDK, not Oracle JDK\n        if 'openjdk' not in output:\n            return None\n\n        match = re.search(r'\\(build (\\S+)\\)', output)\n        return match.group(1).replace('+', '_') if match else None\n\n    @property\n    def home(self):\n        \"\"\"Most of the time, ``JAVA_HOME`` is simply ``spec['java'].prefix``.\n        However, if the user is using an externally installed JDK, it may be\n        symlinked. For example, on macOS, the ``java`` executable can be found\n        in ``/usr/bin``, but ``JAVA_HOME`` is actually\n        ``/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home``.\n        Users may not know the actual installation directory and add ``/usr``\n        to their ``packages.yaml`` unknowingly. Run ``java_home`` if it exists\n        to determine exactly where it is installed. Specify which version we\n        are expecting in case multiple Java versions are installed.\n        See ``man java_home`` for more details.\"\"\"\n\n        prefix = self.prefix\n        java_home = prefix.libexec.java_home\n        if os.path.exists(java_home):\n            java_home = Executable(java_home)\n            version = str(self.version.up_to(2))\n            prefix = java_home('--version', version, output=str).strip()\n            prefix = Prefix(prefix)\n\n        return prefix\n\n    @property\n    def libs(self):\n        \"\"\"Depending on the version number and whether the full JDK or just\n        the JRE was installed, Java libraries can be in several locations:\n\n        * ``lib/libjvm.so``\n        * ``jre/lib/libjvm.dylib``\n\n        Search recursively to find the correct library location.\"\"\"\n\n        return find_libraries(['libjvm'], root=self.home, recursive=True)\n\n    def install(self, spec, prefix):\n        install_tree('.', prefix)\n\n    def setup_run_environment(self, env):\n        \"\"\"Set JAVA_HOME.\"\"\"\n\n        env.set('JAVA_HOME', self.home)\n\n    def setup_dependent_build_environment(self, env, dependent_spec):\n        \"\"\"Set JAVA_HOME and CLASSPATH.\n\n        CLASSPATH contains the installation prefix for the extension and any\n        other Java extensions it depends on.\"\"\"\n\n        env.set('JAVA_HOME', self.home)\n\n        class_paths = []\n        for d in dependent_spec.traverse(deptype=('build', 'run', 'test')):\n            if d.package.extends(self.spec):\n                class_paths.extend(find(d.prefix, '*.jar'))\n\n        classpath = os.pathsep.join(class_paths)\n        env.set('CLASSPATH', classpath)\n\n    def setup_dependent_run_environment(self, env, dependent_spec):\n        \"\"\"Set CLASSPATH.\n\n        CLASSPATH contains the installation prefix for the extension and any\n        other Java extensions it depends on.\"\"\"\n        # For runtime environment set only the path for\n        # dependent_spec and prepend it to CLASSPATH\n        if dependent_spec.package.extends(self.spec):\n            class_paths = find(dependent_spec.prefix, '*.jar')\n            classpath = os.pathsep.join(class_paths)\n            env.prepend_path('CLASSPATH', classpath)\n\n    def setup_dependent_package(self, module, dependent_spec):\n        \"\"\"Allows spec['java'].home to work.\"\"\"\n\n        self.spec.home = self.home\n", "path": "var/spack/repos/builtin/packages/openjdk/package.py"}], "after_files": [{"content": "# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other\n# Spack Project Developers. See the top-level COPYRIGHT file for details.\n#\n# SPDX-License-Identifier: (Apache-2.0 OR MIT)\n\nimport os\nimport platform\nimport re\n\nfrom spack.util.prefix import Prefix\n\n# If you need to add a new version, please be aware that:\n#  - versions in the following dict are automatically added to the package\n#  - version tuple must be in the form (checksum, url)\n#  - checksum must be sha256\n#  - package key must be in the form '{os}-{arch}' where 'os' is in the\n#    format returned by platform.system() and 'arch' by platform.machine()\n\n_versions = {\n    '11.0.9.1_1': {\n        'Linux-ppc64le': ('d94b6b46a14ab0974b1c1b89661741126d8cf8a0068b471b8f5fa286a71636b1', 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9.1%2B1/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.9.1_1.tar.gz')},\n    '11.0.8_10': {\n        'Linux-x86_64': ('6e4cead158037cb7747ca47416474d4f408c9126be5b96f9befd532e0a762b47', 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.8_10.tar.gz')},\n    '11.0.0-2020-01-01': {\n        'Linux-aarch64': ('05c7d9c90edacd853850fbb0f52f8aa482809d0452c599cb9fe0b28b3b4bf329', 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk11u-2020-01-01-06-13/OpenJDK11U-jdk_aarch64_linux_hotspot_2020-01-01-06-13.tar.gz')},\n    '11.0.2': {\n        'Linux-x86_64': ('99be79935354f5c0df1ad293620ea36d13f48ec3ea870c838f20c504c9668b57', 'https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz')},\n    '11.0.1': {\n        'Linux-x86_64': ('7a6bb980b9c91c478421f865087ad2d69086a0583aeeb9e69204785e8e97dcfd', 'https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz')},\n    '1.8.0_265-b01': {\n        'Linux-x86_64': ('1285da6278f2d38a790a21148d7e683f20de0799c44b937043830ef6b57f58c4', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u265-b01/OpenJDK8U-jdk_x64_linux_hotspot_8u265b01.tar.gz')},\n    '1.8.0_191-b12': {\n        'Linux-aarch64': ('8eee0aede947b804f9a5f49c8a38b52aace8a30a9ebd9383b7d06042fb5a237c', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u191-b12/OpenJDK8U-jdk_aarch64_linux_hotspot_8u191b12.tar.gz')},\n    '1.8.0_222-b10': {\n        'Linux-x86_64': ('20cff719c6de43f8bb58c7f59e251da7c1fa2207897c9a4768c8c669716dc819', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u222-b10_openj9-0.15.1/OpenJDK8U-jdk_x64_linux_openj9_8u222b10_openj9-0.15.1.tar.gz')},\n    '1.8.0_202-b08': {\n        'Linux-x86_64': ('533dcd8d9ca15df231a1eb392fa713a66bca85a8e76d9b4ee30975f3823636b7', 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u202-b08/OpenJDK8U-jdk_x64_linux_openj9_8u202b08_openj9-0.12.0.tar.gz')},\n    '1.8.0_40-b25': {\n        'Linux-x86_64': ('79e96dce03a14271040023231a7d0ae374b755d48adf68bbdaec30294e4e2b88', 'https://download.java.net/openjdk/jdk8u40/ri/jdk_ri-8u40-b25-linux-x64-10_feb_2015.tar.gz')},\n}\n\n\nclass Openjdk(Package):\n    \"\"\"The free and opensource java implementation\"\"\"\n\n    homepage = \"https://jdk.java.net\"\n\n    for ver, packages in _versions.items():\n        key = \"{0}-{1}\".format(platform.system(), platform.machine())\n        pkg = packages.get(key)\n        if pkg:\n            version(ver, sha256=pkg[0], url=pkg[1])\n\n    provides('java@11', when='@11.0:11.99')\n    provides('java@10', when='@10.0:10.99')\n    provides('java@9', when='@9.0:9.99')\n    provides('java@8', when='@1.8.0:1.8.999')\n\n    conflicts('target=ppc64:', msg='openjdk is not available for ppc64 (big endian)')\n\n    # FIXME:\n    # 1. `extends('java')` doesn't work, you need to use `extends('openjdk')`\n    # 2. Packages cannot extend multiple packages, see #987\n    # 3. Update `YamlFilesystemView.merge` to allow a Package to completely\n    #    override how it is symlinked into a view prefix. Then, spack activate\n    #    can symlink all *.jar files to `prefix.lib.ext`\n    extendable = True\n\n    executables = ['^java$']\n\n    @classmethod\n    def determine_version(cls, exe):\n        output = Executable(exe)('-version', output=str, error=str)\n\n        # Make sure this is actually OpenJDK, not Oracle JDK\n        if 'openjdk' not in output:\n            return None\n\n        match = re.search(r'\\(build (\\S+)\\)', output)\n        return match.group(1).replace('+', '_') if match else None\n\n    @property\n    def home(self):\n        \"\"\"Most of the time, ``JAVA_HOME`` is simply ``spec['java'].prefix``.\n        However, if the user is using an externally installed JDK, it may be\n        symlinked. For example, on macOS, the ``java`` executable can be found\n        in ``/usr/bin``, but ``JAVA_HOME`` is actually\n        ``/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home``.\n        Users may not know the actual installation directory and add ``/usr``\n        to their ``packages.yaml`` unknowingly. Run ``java_home`` if it exists\n        to determine exactly where it is installed. Specify which version we\n        are expecting in case multiple Java versions are installed.\n        See ``man java_home`` for more details.\"\"\"\n\n        prefix = self.prefix\n        java_home = prefix.libexec.java_home\n        if os.path.exists(java_home):\n            java_home = Executable(java_home)\n            version = str(self.version.up_to(2))\n            prefix = java_home('--version', version, output=str).strip()\n            prefix = Prefix(prefix)\n\n        return prefix\n\n    @property\n    def libs(self):\n        \"\"\"Depending on the version number and whether the full JDK or just\n        the JRE was installed, Java libraries can be in several locations:\n\n        * ``lib/libjvm.so``\n        * ``jre/lib/libjvm.dylib``\n\n        Search recursively to find the correct library location.\"\"\"\n\n        return find_libraries(['libjvm'], root=self.home, recursive=True)\n\n    def install(self, spec, prefix):\n        install_tree('.', prefix)\n\n    def setup_run_environment(self, env):\n        \"\"\"Set JAVA_HOME.\"\"\"\n\n        env.set('JAVA_HOME', self.home)\n\n    def setup_dependent_build_environment(self, env, dependent_spec):\n        \"\"\"Set JAVA_HOME and CLASSPATH.\n\n        CLASSPATH contains the installation prefix for the extension and any\n        other Java extensions it depends on.\"\"\"\n\n        env.set('JAVA_HOME', self.home)\n\n        class_paths = []\n        for d in dependent_spec.traverse(deptype=('build', 'run', 'test')):\n            if d.package.extends(self.spec):\n                class_paths.extend(find(d.prefix, '*.jar'))\n\n        classpath = os.pathsep.join(class_paths)\n        env.set('CLASSPATH', classpath)\n\n    def setup_dependent_run_environment(self, env, dependent_spec):\n        \"\"\"Set CLASSPATH.\n\n        CLASSPATH contains the installation prefix for the extension and any\n        other Java extensions it depends on.\"\"\"\n        # For runtime environment set only the path for\n        # dependent_spec and prepend it to CLASSPATH\n        if dependent_spec.package.extends(self.spec):\n            class_paths = find(dependent_spec.prefix, '*.jar')\n            classpath = os.pathsep.join(class_paths)\n            env.prepend_path('CLASSPATH', classpath)\n\n    def setup_dependent_package(self, module, dependent_spec):\n        \"\"\"Allows spec['java'].home to work.\"\"\"\n\n        self.spec.home = self.home\n", "path": "var/spack/repos/builtin/packages/openjdk/package.py"}]}