src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Archive.java
author serb
Sat, 09 Jun 2018 13:33:35 -0700
changeset 50647 a98ff7c2103d
parent 47216 71c04702a3d5
child 52649 e00cf18e2593
permissions -rw-r--r--
6608234: SwingWorker.get throws CancellationException Reviewed-by: psadhukhan, kaddepalli, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
     1
/*
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
     2
 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
     4
 *
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    10
 *
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    15
 * accompanied this code).
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    16
 *
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    20
 *
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    23
 * questions.
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    24
 */
34752
9c262a013456 8145342: Some copyright notices are inconsistently and ill formatted
vasya
parents: 30846
diff changeset
    25
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    26
package com.sun.tools.jdeps;
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    27
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    28
import com.sun.tools.classfile.Dependency.Location;
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
    29
38530
8e89d567748c 8157391: jdeps left JarFile open
mchung
parents: 38524
diff changeset
    30
import java.io.Closeable;
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
    31
import java.io.IOException;
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 25874
diff changeset
    32
import java.io.UncheckedIOException;
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    33
import java.net.URI;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    34
import java.nio.file.Files;
21046
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16290
diff changeset
    35
import java.nio.file.Path;
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    36
import java.nio.file.Paths;
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    37
import java.util.HashSet;
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    38
import java.util.Map;
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    39
import java.util.Objects;
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    40
import java.util.Set;
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
    41
import java.util.concurrent.ConcurrentHashMap;
38524
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
    42
import java.util.stream.Stream;
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    43
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    44
/**
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    45
 * Represents the source of the class files.
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    46
 */
38530
8e89d567748c 8157391: jdeps left JarFile open
mchung
parents: 38524
diff changeset
    47
public class Archive implements Closeable {
41164
69167c89e68f 8153654: Update jdeps to be multi-release jar aware
sdrach
parents: 38530
diff changeset
    48
    public static Archive getInstance(Path p, Runtime.Version version) {
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 25874
diff changeset
    49
        try {
41164
69167c89e68f 8153654: Update jdeps to be multi-release jar aware
sdrach
parents: 38530
diff changeset
    50
            return new Archive(p, ClassFileReader.newInstance(p, version));
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 25874
diff changeset
    51
        } catch (IOException e) {
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 25874
diff changeset
    52
            throw new UncheckedIOException(e);
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents: 25874
diff changeset
    53
        }
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
    54
    }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
    55
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    56
    private final URI location;
21046
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16290
diff changeset
    57
    private final Path path;
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    58
    private final String filename;
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    59
    private final ClassFileReader reader;
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    60
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
    61
    protected Map<Location, Set<Location>> deps = new ConcurrentHashMap<>();
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents: 15030
diff changeset
    62
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
    63
    protected Archive(String name) {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    64
        this(name, null, null);
25874
83c19f00452c 8054834: Modular Source Code
chegar
parents: 25442
diff changeset
    65
    }
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    66
    protected Archive(String name, URI location, ClassFileReader reader) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    67
        this.location = location;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    68
        this.path = location != null ? Paths.get(location) : null;
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    69
        this.filename = name;
25874
83c19f00452c 8054834: Modular Source Code
chegar
parents: 25442
diff changeset
    70
        this.reader = reader;
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    71
    }
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
    72
    protected Archive(Path p, ClassFileReader reader) {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    73
        this.location = null;
21046
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16290
diff changeset
    74
        this.path = p;
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16290
diff changeset
    75
        this.filename = path.getFileName().toString();
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    76
        this.reader = reader;
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    77
    }
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    78
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    79
    public ClassFileReader reader() {
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    80
        return reader;
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    81
    }
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    82
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
    83
    public String getName() {
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    84
        return filename;
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    85
    }
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    86
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    87
    public Module getModule() {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    88
        return Module.UNNAMED_MODULE;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    89
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
    90
38524
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
    91
    public boolean contains(String entry) {
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
    92
        return reader.entries().contains(entry);
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
    93
    }
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
    94
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents: 15030
diff changeset
    95
    public void addClass(Location origin) {
28706
a724585645ce 8068937: jdeps shows "not found" if target class has no reference other than its own package
mchung
parents: 27579
diff changeset
    96
        deps.computeIfAbsent(origin, _k -> new HashSet<>());
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
    97
    }
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
    98
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents: 15030
diff changeset
    99
    public void addClass(Location origin, Location target) {
28706
a724585645ce 8068937: jdeps shows "not found" if target class has no reference other than its own package
mchung
parents: 27579
diff changeset
   100
        deps.computeIfAbsent(origin, _k -> new HashSet<>()).add(target);
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   101
    }
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   102
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   103
    public Set<Location> getClasses() {
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   104
        return deps.keySet();
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   105
    }
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   106
38524
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
   107
    public Stream<Location> getDependencies() {
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
   108
        return deps.values().stream()
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
   109
                   .flatMap(Set::stream);
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
   110
    }
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
   111
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
   112
    public boolean hasDependences() {
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
   113
        return getDependencies().count() > 0;
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
   114
    }
badd925c1d2f 8156680: jdeps implementation refresh
mchung
parents: 36526
diff changeset
   115
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   116
    public void visitDependences(Visitor v) {
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents: 15030
diff changeset
   117
        for (Map.Entry<Location,Set<Location>> e: deps.entrySet()) {
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents: 15030
diff changeset
   118
            for (Location target : e.getValue()) {
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents: 15030
diff changeset
   119
                v.visit(e.getKey(), target);
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   120
            }
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   121
        }
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   122
    }
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   123
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   124
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   125
     * Tests if any class has been parsed.
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   126
     */
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
   127
    public boolean isEmpty() {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
   128
        return getClasses().isEmpty();
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
   129
    }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22448
diff changeset
   130
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   131
    public String getPathName() {
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   132
        return path != null ? path.toString() : filename;
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   133
    }
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   134
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   135
    @Override
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   136
    public int hashCode() {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   137
        return Objects.hash(this.filename, this.path);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   138
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   139
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   140
    @Override
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   141
    public boolean equals(Object o) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   142
        if (o instanceof Archive) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   143
            Archive other = (Archive)o;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   144
            if (path == other.path || isSameLocation(this, other))
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   145
                return true;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   146
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   147
        return false;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   148
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   149
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   150
    @Override
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   151
    public String toString() {
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   152
        return filename;
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   153
    }
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   154
28706
a724585645ce 8068937: jdeps shows "not found" if target class has no reference other than its own package
mchung
parents: 27579
diff changeset
   155
    public Path path() {
a724585645ce 8068937: jdeps shows "not found" if target class has no reference other than its own package
mchung
parents: 27579
diff changeset
   156
        return path;
a724585645ce 8068937: jdeps shows "not found" if target class has no reference other than its own package
mchung
parents: 27579
diff changeset
   157
    }
a724585645ce 8068937: jdeps shows "not found" if target class has no reference other than its own package
mchung
parents: 27579
diff changeset
   158
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   159
    public static boolean isSameLocation(Archive archive, Archive other) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   160
        if (archive.path == null || other.path == null)
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   161
            return false;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   162
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   163
        if (archive.location != null && other.location != null &&
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   164
                archive.location.equals(other.location)) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   165
            return true;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   166
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   167
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   168
        if (archive.isJrt() || other.isJrt()) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   169
            return false;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   170
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   171
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   172
        try {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   173
            return Files.isSameFile(archive.path, other.path);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   174
        } catch (IOException e) {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   175
            throw new UncheckedIOException(e);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   176
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   177
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   178
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   179
    private boolean isJrt() {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   180
        return location != null && location.getScheme().equals("jrt");
3b41f1c69604 8142968: Module System implementation
alanb
parents: 34752
diff changeset
   181
    }
38530
8e89d567748c 8157391: jdeps left JarFile open
mchung
parents: 38524
diff changeset
   182
8e89d567748c 8157391: jdeps left JarFile open
mchung
parents: 38524
diff changeset
   183
    @Override
8e89d567748c 8157391: jdeps left JarFile open
mchung
parents: 38524
diff changeset
   184
    public void close() throws IOException {
8e89d567748c 8157391: jdeps left JarFile open
mchung
parents: 38524
diff changeset
   185
        if (reader != null)
8e89d567748c 8157391: jdeps left JarFile open
mchung
parents: 38524
diff changeset
   186
            reader.close();
8e89d567748c 8157391: jdeps left JarFile open
mchung
parents: 38524
diff changeset
   187
    }
8e89d567748c 8157391: jdeps left JarFile open
mchung
parents: 38524
diff changeset
   188
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents: 15030
diff changeset
   189
    interface Visitor {
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents: 15030
diff changeset
   190
        void visit(Location origin, Location target);
15030
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   191
    }
2d8dec41f029 8003562: Provide a CLI tool to analyze class dependencies
mchung
parents:
diff changeset
   192
}