src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Archive.java
changeset 52649 e00cf18e2593
parent 47216 71c04702a3d5
equal deleted inserted replaced
52648:12956ca371c2 52649:e00cf18e2593
    35 import java.nio.file.Path;
    35 import java.nio.file.Path;
    36 import java.nio.file.Paths;
    36 import java.nio.file.Paths;
    37 import java.util.HashSet;
    37 import java.util.HashSet;
    38 import java.util.Map;
    38 import java.util.Map;
    39 import java.util.Objects;
    39 import java.util.Objects;
       
    40 import java.util.Optional;
    40 import java.util.Set;
    41 import java.util.Set;
    41 import java.util.concurrent.ConcurrentHashMap;
    42 import java.util.concurrent.ConcurrentHashMap;
    42 import java.util.stream.Stream;
    43 import java.util.stream.Stream;
       
    44 
       
    45 import static com.sun.tools.jdeps.Module.trace;
    43 
    46 
    44 /**
    47 /**
    45  * Represents the source of the class files.
    48  * Represents the source of the class files.
    46  */
    49  */
    47 public class Archive implements Closeable {
    50 public class Archive implements Closeable {
   130 
   133 
   131     public String getPathName() {
   134     public String getPathName() {
   132         return path != null ? path.toString() : filename;
   135         return path != null ? path.toString() : filename;
   133     }
   136     }
   134 
   137 
       
   138     public Optional<Path> path() {
       
   139         return Optional.ofNullable(path);
       
   140     }
       
   141 
   135     @Override
   142     @Override
   136     public int hashCode() {
   143     public int hashCode() {
   137         return Objects.hash(this.filename, this.path);
   144         return Objects.hash(this.filename, this.path);
   138     }
   145     }
   139 
   146 
   150     @Override
   157     @Override
   151     public String toString() {
   158     public String toString() {
   152         return filename;
   159         return filename;
   153     }
   160     }
   154 
   161 
   155     public Path path() {
       
   156         return path;
       
   157     }
       
   158 
   162 
   159     public static boolean isSameLocation(Archive archive, Archive other) {
   163     public static boolean isSameLocation(Archive archive, Archive other) {
   160         if (archive.path == null || other.path == null)
   164         if (archive.path == null || other.path == null)
   161             return false;
   165             return false;
   162 
   166 
   180         return location != null && location.getScheme().equals("jrt");
   184         return location != null && location.getScheme().equals("jrt");
   181     }
   185     }
   182 
   186 
   183     @Override
   187     @Override
   184     public void close() throws IOException {
   188     public void close() throws IOException {
       
   189         trace("closing %s %n", getPathName());
   185         if (reader != null)
   190         if (reader != null)
   186             reader.close();
   191             reader.close();
   187     }
   192     }
   188 
   193 
   189     interface Visitor {
   194     interface Visitor {