langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java
author mchung
Thu, 17 Jul 2014 10:17:58 -0700
changeset 25692 39537fdca12c
parent 25442 755ff386d1ac
permissions -rw-r--r--
8050804: (jdeps) Recommend supported API to replace use of JDK internal API Reviewed-by: dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
     1
/*
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
     2
 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
     4
 *
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    10
 *
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    15
 * accompanied this code).
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    16
 *
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    20
 *
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    23
 * questions.
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    24
 */
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    25
package com.sun.tools.jdeps;
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    26
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    27
import java.util.Comparator;
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    28
import java.util.HashMap;
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    29
import java.util.HashSet;
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    30
import java.util.List;
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    31
import java.util.Map;
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
    32
import java.util.Objects;
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    33
import java.util.Set;
25692
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
    34
import java.util.stream.Collectors;
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
    35
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
    36
import com.sun.tools.classfile.Dependency.Location;
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
    37
import com.sun.tools.jdeps.PlatformClassPath.JDKArchive;
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    38
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    39
/**
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    40
 * Dependency Analyzer.
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    41
 */
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    42
public class Analyzer {
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    43
    /**
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    44
     * Type of the dependency analysis.  Appropriate level of data
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    45
     * will be stored.
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    46
     */
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    47
    public enum Type {
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    48
        SUMMARY,
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    49
        PACKAGE,
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    50
        CLASS,
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    51
        VERBOSE
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 21503
diff changeset
    52
    }
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    53
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    54
    /**
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    55
     * Filter to be applied when analyzing the dependencies from the given archives.
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    56
     * Only the accepted dependencies are recorded.
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    57
     */
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    58
    interface Filter {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    59
        boolean accepts(Location origin, Archive originArchive, Location target, Archive targetArchive);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    60
    }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    61
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    62
    private final Type type;
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    63
    private final Filter filter;
21046
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16550
diff changeset
    64
    private final Map<Archive, ArchiveDeps> results = new HashMap<>();
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
    65
    private final Map<Location, Archive> map = new HashMap<>();
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    66
    private final Archive NOT_FOUND
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    67
        = new Archive(JdepsTask.getMessage("artifact.not.found"));
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    68
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    69
    /**
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    70
     * Constructs an Analyzer instance.
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    71
     *
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    72
     * @param type Type of the dependency analysis
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    73
     * @param filter
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    74
     */
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    75
    public Analyzer(Type type, Filter filter) {
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    76
        this.type = type;
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    77
        this.filter = filter;
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    78
    }
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    79
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    80
    /**
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    81
     * Performs the dependency analysis on the given archives.
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    82
     */
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
    83
    public void run(List<Archive> archives) {
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
    84
        // build a map from Location to Archive
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    85
        buildLocationArchiveMap(archives);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    86
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    87
        // traverse and analyze all dependencies
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    88
        for (Archive archive : archives) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    89
            ArchiveDeps deps = new ArchiveDeps(archive, type);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    90
            archive.visitDependences(deps);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    91
            results.put(archive, deps);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    92
        }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    93
    }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    94
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    95
    private void buildLocationArchiveMap(List<Archive> archives) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
    96
        // build a map from Location to Archive
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
    97
        for (Archive archive: archives) {
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
    98
            for (Location l: archive.getClasses()) {
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
    99
                if (!map.containsKey(l)) {
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   100
                    map.put(l, archive);
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   101
                } else {
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   102
                    // duplicated class warning?
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   103
                }
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   104
            }
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   105
        }
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   106
    }
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   107
21046
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16550
diff changeset
   108
    public boolean hasDependences(Archive archive) {
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16550
diff changeset
   109
        if (results.containsKey(archive)) {
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   110
            return results.get(archive).dependencies().size() > 0;
21046
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16550
diff changeset
   111
        }
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16550
diff changeset
   112
        return false;
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16550
diff changeset
   113
    }
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16550
diff changeset
   114
25692
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
   115
    public Set<String> dependences(Archive source) {
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
   116
        ArchiveDeps result = results.get(source);
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
   117
        return result.dependencies().stream()
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
   118
                     .map(Dep::target)
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
   119
                     .collect(Collectors.toSet());
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
   120
    }
39537fdca12c 8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents: 25442
diff changeset
   121
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   122
    public interface Visitor {
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   123
        /**
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   124
         * Visits a recorded dependency from origin to target which can be
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   125
         * a fully-qualified classname, a package name, a module or
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   126
         * archive name depending on the Analyzer's type.
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   127
         */
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   128
        public void visitDependence(String origin, Archive originArchive,
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   129
                                    String target, Archive targetArchive);
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   130
    }
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   131
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   132
    /**
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   133
     * Visit the dependencies of the given source.
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   134
     * If the requested level is SUMMARY, it will visit the required archives list.
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   135
     */
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   136
    public void visitDependences(Archive source, Visitor v, Type level) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   137
        if (level == Type.SUMMARY) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   138
            final ArchiveDeps result = results.get(source);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   139
            result.requires().stream()
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   140
                  .sorted(Comparator.comparing(Archive::getName))
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   141
                  .forEach(archive -> {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   142
                      Profile profile = result.getTargetProfile(archive);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   143
                      v.visitDependence(source.getName(), source,
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   144
                                        profile != null ? profile.profileName() : archive.getName(), archive);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   145
                  });
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   146
        } else {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   147
            ArchiveDeps result = results.get(source);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   148
            if (level != type) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   149
                // requesting different level of analysis
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   150
                result = new ArchiveDeps(source, level);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   151
                source.visitDependences(result);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   152
            }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   153
            result.dependencies().stream()
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   154
                  .sorted(Comparator.comparing(Dep::origin)
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   155
                                    .thenComparing(Dep::target))
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   156
                  .forEach(d -> v.visitDependence(d.origin(), d.originArchive(), d.target(), d.targetArchive()));
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   157
        }
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   158
    }
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   159
21046
ebf16a1a6328 8015912: jdeps support to output in dot file format
mchung
parents: 16550
diff changeset
   160
    public void visitDependences(Archive source, Visitor v) {
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   161
        visitDependences(source, v, type);
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   162
    }
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   163
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   164
    /**
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   165
     * ArchiveDeps contains the dependencies for an Archive that can have one or
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   166
     * more classes.
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   167
     */
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   168
    class ArchiveDeps implements Archive.Visitor {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   169
        protected final Archive archive;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   170
        protected final Set<Archive> requires;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   171
        protected final Set<Dep> deps;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   172
        protected final Type level;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   173
        private Profile profile;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   174
        ArchiveDeps(Archive archive, Type level) {
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   175
            this.archive = archive;
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   176
            this.deps = new HashSet<>();
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   177
            this.requires = new HashSet<>();
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   178
            this.level = level;
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   179
        }
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   180
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   181
        Set<Dep> dependencies() {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   182
            return deps;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   183
        }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   184
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   185
        Set<Archive> requires() {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   186
            return requires;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   187
        }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   188
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   189
        Profile getTargetProfile(Archive target) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   190
            return JDKArchive.isProfileArchive(target) ? profile : null;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   191
        }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   192
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   193
        Archive findArchive(Location t) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   194
            Archive target = archive.getClasses().contains(t) ? archive : map.get(t);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   195
            if (target == null) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   196
                map.put(t, target = NOT_FOUND);
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   197
            }
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   198
            return target;
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   199
        }
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   200
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   201
        // return classname or package name depedning on the level
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   202
        private String getLocationName(Location o) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   203
            if (level == Type.CLASS || level == Type.VERBOSE) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   204
                return o.getClassName();
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   205
            } else {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   206
                String pkg = o.getPackageName();
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   207
                return pkg.isEmpty() ? "<unnamed>" : pkg;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   208
            }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   209
        }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   210
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   211
        @Override
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   212
        public void visit(Location o, Location t) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   213
            Archive targetArchive = findArchive(t);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   214
            if (filter.accepts(o, archive, t, targetArchive)) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   215
                addDep(o, t);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   216
                if (!requires.contains(targetArchive)) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   217
                    requires.add(targetArchive);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   218
                }
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   219
            }
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   220
            if (targetArchive instanceof JDKArchive) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   221
                Profile p = Profile.getProfile(t.getPackageName());
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   222
                if (profile == null || (p != null && p.compareTo(profile) > 0)) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   223
                    profile = p;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   224
                }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   225
            }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   226
        }
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   227
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   228
        private Dep curDep;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   229
        protected Dep addDep(Location o, Location t) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   230
            String origin = getLocationName(o);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   231
            String target = getLocationName(t);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   232
            Archive targetArchive = findArchive(t);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   233
            if (curDep != null &&
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   234
                    curDep.origin().equals(origin) &&
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   235
                    curDep.originArchive() == archive &&
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   236
                    curDep.target().equals(target) &&
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   237
                    curDep.targetArchive() == targetArchive) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   238
                return curDep;
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   239
            }
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   240
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   241
            Dep e = new Dep(origin, archive, target, targetArchive);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   242
            if (deps.contains(e)) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   243
                for (Dep e1 : deps) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   244
                    if (e.equals(e1)) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   245
                        curDep = e1;
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   246
                    }
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   247
                }
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   248
            } else {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   249
                deps.add(e);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   250
                curDep = e;
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   251
            }
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   252
            return curDep;
16550
f20e2521f3df 8005428: Update jdeps to read the same profile information as by javac
mchung
parents: 16290
diff changeset
   253
        }
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   254
    }
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   255
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   256
    /*
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   257
     * Class-level or package-level dependency
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   258
     */
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   259
    class Dep {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   260
        final String origin;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   261
        final Archive originArchive;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   262
        final String target;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   263
        final Archive targetArchive;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   264
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   265
        Dep(String origin, Archive originArchive, String target, Archive targetArchive) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   266
            this.origin = origin;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   267
            this.originArchive = originArchive;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   268
            this.target = target;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   269
            this.targetArchive = targetArchive;
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   270
        }
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   271
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   272
        String origin() {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   273
            return origin;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   274
        }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   275
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   276
        Archive originArchive() {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   277
            return originArchive;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   278
        }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   279
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   280
        String target() {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   281
            return target;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   282
        }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   283
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   284
        Archive targetArchive() {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   285
            return targetArchive;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   286
        }
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   287
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   288
        @Override
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   289
        @SuppressWarnings("unchecked")
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   290
        public boolean equals(Object o) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   291
            if (o instanceof Dep) {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   292
                Dep d = (Dep) o;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   293
                return this.origin.equals(d.origin) &&
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   294
                        this.originArchive == d.originArchive &&
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   295
                        this.target.equals(d.target) &&
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   296
                        this.targetArchive == d.targetArchive;
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   297
            }
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   298
            return false;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   299
        }
21503
45fc62482cae 8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents: 21046
diff changeset
   300
25442
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   301
        @Override
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   302
        public int hashCode() {
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   303
            int hash = 7;
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   304
            hash = 67*hash + Objects.hashCode(this.origin)
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   305
                           + Objects.hashCode(this.originArchive)
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   306
                           + Objects.hashCode(this.target)
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   307
                           + Objects.hashCode(this.targetArchive);
755ff386d1ac 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents: 22163
diff changeset
   308
            return hash;
16290
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   309
        }
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   310
    }
b0b4f52de7ea 8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff changeset
   311
}