docs: private static void setJavaRequirements(File esa, EsaResourceWritable resource) throws RepositoryException {
  
          Map<String, String> bundleRequirements = new HashMap<String, String>();
          Path zipfile = esa.toPath();
          Map<String, VersionRange> matchingEnvs = new LinkedHashMap<String, VersionRange>();
  
          matchingEnvs.put("Java 6", JAVA_6_RANGE);
          matchingEnvs.put("Java 7", JAVA_7_RANGE);
          matchingEnvs.put("Java 8", JAVA_8_RANGE);
          matchingEnvs.put("Java 9", JAVA_9_RANGE);
          matchingEnvs.put("Java 10", JAVA_10_RANGE);
          matchingEnvs.put("Java 11", JAVA_11_RANGE);
  
          StringBuilder message = new StringBuilder();
  
          // Map of Path of an esa or jar, to its Require-Capability string
          Map<Path, String> requiresMap = new HashMap<Path, String>();
  
          // build a set of capabilities of each of manifests in the bundles and the subsystem
          // manifest in the feature
          try (final FileSystem zipSystem = FileSystems.newFileSystem(zipfile, null)) {
  
              // get the paths of each bundle jar in the root directory of the esa
              Iterable<Path> roots = zipSystem.getRootDirectories();
              BundleFinder finder = new EsaParser.BundleFinder(zipSystem);
              for (Path root : roots) {
                  // Bundles should be in the root of the zip, so depth is 1
                  Files.walkFileTree(root, new HashSet<FileVisitOption>(), 1, finder);
              }
  
              // Go through each bundle jar in the root of the esa and add their require
              // capabilites to the map
              for (Path bundle : finder.bundles) {
                  addBundleManifestRequireCapability(zipSystem, bundle, requiresMap);
              }
  
              // now add the require capabilities of the esa subsystem manifest
              addSubsystemManifestRequireCapability(esa, requiresMap);
          } catch (IOException e) {
              // Any IOException means that the version info isn't reliable, so only thing to do is ditch out.
              throw new RepositoryArchiveIOException(e.getMessage(), esa, e);
          }
  
          // Loop through the set of requires capabilities
          Set<Entry<Path, String>> entries = requiresMap.entrySet();
          for (Entry<Path, String> entry : entries) {
              Path path = entry.getKey();
  
              // Get the GenericMetadata
              List<GenericMetadata> requirementMetadata = ManifestHeaderProcessor.parseRequirementString(entry.getValue());
              GenericMetadata eeVersionMetadata = null;
              for (GenericMetadata metaData : requirementMetadata) {
                  if (metaData.getNamespace().equals(OSGI_EE_NAMESPACE_ID)) {
                      eeVersionMetadata = metaData;
                      break;
                  }
              }
  
              if (eeVersionMetadata == null) {
                  // No version requirements, go to the next bundle
                  continue;
              }
  
              Map<String, String> dirs = eeVersionMetadata.getDirectives();
              for (String key : dirs.keySet()) {
  
                  if (!key.equals("filter")) {
                      continue;
                  }
  
                  Map<String, String> filter = null;
                  filter = ManifestHeaderProcessor.parseFilter(dirs.get(key));
  
                  // The interesting filter should contain osgi.ee=JavaSE and version=XX
                  if (!(filter.containsKey(OSGI_EE_NAMESPACE_ID) && filter.get(OSGI_EE_NAMESPACE_ID).equals(JAVA_FILTER_KEY)
                        && filter.containsKey(VERSION_FILTER_KEY))) {
                      continue; // Uninteresting filter
                  }
  
                  // Store the raw filter to add to the resource later.
                  bundleRequirements.put(path.getFileName().toString(), dirs.get(key));
  
                  VersionRange range = ManifestHeaderProcessor.parseVersionRange(filter.get(VERSION_FILTER_KEY));
                  Iterator<Entry<String, VersionRange>> iterator = matchingEnvs.entrySet().iterator();
                  while (iterator.hasNext()) {
                      Entry<String, VersionRange> capability = iterator.next();
                      VersionRange intersection = capability.getValue().intersect(range);
                      if (intersection == null) {
                          // Store what caused this env to be removed, for error message later
                          message.append("Manifest from " + path.getFileName() + " with range " + range + " caused env for "
                                         + capability.getKey() + " to be removed. ");
                          iterator.remove();
                      }
                  }
  
                  // Assume there is only one Java version filter, so stop looking
                  break;
              }
          }
  
          if (matchingEnvs.size() == 0) {
              throw new RepositoryException("ESA " + resource.getName() +
                                            " is invalid as no Java execution environment matches all the bundle requirements: "
                                            + message);
          }
  
          ArrayList<String> rawRequirements = new ArrayList<String>();
          for (String key : bundleRequirements.keySet()) {
              rawRequirements.add(key + ": " + bundleRequirements.get(key));
          }
          if (rawRequirements.size() == 0) {
              rawRequirements = null;
          }
  
          // The only thing that really matter is the minimum Java level required for this
          // esa, as later Java levels provide earlier envs. Hence for now, the max is
          // always set to null
          // Need to get the first entry in the matchingEnvs map (it is a linked and hence ordered map),
          // hence the silliness below.
          Version min = matchingEnvs.entrySet().iterator().next().getValue().getMaximumVersion();
          resource.setJavaSEVersionRequirements(min.toString(), null, rawRequirements);
  
      }