@Override
 public PathFilter filter() {
   ModuleInfo infos = resolve();
   if (infos == null || infos.getFilter() == null) return null;
   try {
     return PathFilterParser.parse(infos.getFilter());
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
  public List<ArtifactResult> dependencies() throws RepositoryException {
    List<ModuleInfo> infos = BytecodeUtils.readModuleInformation(name(), artifact());
    if (infos.isEmpty()) return Collections.emptyList();

    final List<ArtifactResult> results = new ArrayList<ArtifactResult>();
    for (ModuleInfo mi : infos) {
      results.add(
          new LazyArtifactResult(
              mi.getName(),
              mi.getVersion(),
              mi.isOptional()
                  ? ImportType.OPTIONAL
                  : (mi.isExport() ? ImportType.EXPORT : ImportType.UNDEFINED)));
    }
    return results;
  }
  @Override
  public List<ArtifactResult> dependencies() throws RepositoryException {
    ModuleInfo infos = resolve();
    // TODO -- perhaps null is not valid?
    if (infos == null || infos.getDependencies().isEmpty()) return Collections.emptyList();

    final List<ArtifactResult> results = new ArrayList<ArtifactResult>();
    for (ModuleDependencyInfo mi : getOrderedDependencies(infos)) {
      results.add(
          new LazyArtifactResult(
              manager,
              mi.getNamespace(),
              mi.getName(),
              mi.getVersion(),
              mi.isOptional()
                  ? ImportType.OPTIONAL
                  : (mi.isExport() ? ImportType.EXPORT : ImportType.UNDEFINED)));
    }
    return results;
  }
 /**
  * {@code ModuleInfo} has dependencies as a {@code Set} (actually a {@code HashSet}), but {@link
  * #dependencies()} needs to return a list. The order matter much except when several dependencies
  * can't be found. That happens, in particular, when trying to run a module compiled with a more
  * recent (but still BC) version of Ceylon. So for consistency on that case we will already return
  * ceylon.language first.
  */
 private List<ModuleDependencyInfo> getOrderedDependencies(ModuleInfo infos) {
   List<ModuleDependencyInfo> dependencies =
       new ArrayList<ModuleDependencyInfo>(infos.getDependencies());
   for (int index = 0; index < dependencies.size(); index++) {
     ModuleDependencyInfo dep = dependencies.get(index);
     if ("ceylon.language".equals(dep.getName())) {
       if (index != 0) {
         dependencies.remove(index);
         dependencies.add(0, dep);
       }
       break;
     }
   }
   return dependencies;
 }