com.sun.tools.jdeps.PlatformClassPath.JDKArchive Java Examples

The following examples show how to use com.sun.tools.jdeps.PlatformClassPath.JDKArchive. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Analyzer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visit(Location o, Location t) {
    Archive targetArchive = findArchive(t);
    if (filter.accepts(o, archive, t, targetArchive)) {
        addDep(o, t);
        if (archive != targetArchive && !requires.contains(targetArchive)) {
            requires.add(targetArchive);
        }
    }
    if (targetArchive instanceof JDKArchive) {
        Profile p = Profile.getProfile(t.getPackageName());
        if (profile == null || (p != null && p.compareTo(profile) > 0)) {
            profile = p;
        }
    }
}
 
Example #2
Source File: JdepsTask.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the given archive is JDK archive, this method returns the profile name
 * only if -profile option is specified; it accesses a private JDK API and
 * the returned value will have "JDK internal API" prefix
 *
 * For non-JDK archives, this method returns the file name of the archive.
 */
private String toTag(String name, Archive source, Analyzer.Type type) {
    if (!isJDKArchive(source)) {
        return source.getName();
    }

    JDKArchive jdk = (JDKArchive)source;
    boolean isExported = false;
    if (type == CLASS || type == VERBOSE) {
        isExported = jdk.isExported(name);
    } else {
        isExported = jdk.isExportedPackage(name);
    }
    Profile p = getProfile(name, type);
    if (isExported) {
        // exported API
        return options.showProfile && p != null ? p.profileName() : "";
    } else {
        return "JDK internal API (" + source.getName() + ")";
    }
}
 
Example #3
Source File: Analyzer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visit(Location o, Location t) {
    Archive targetArchive = findArchive(t);
    if (filter.accepts(o, archive, t, targetArchive)) {
        addDep(o, t);
        if (archive != targetArchive && !requires.contains(targetArchive)) {
            requires.add(targetArchive);
        }
    }
    if (targetArchive instanceof JDKArchive) {
        Profile p = Profile.getProfile(t.getPackageName());
        if (profile == null || (p != null && p.compareTo(profile) > 0)) {
            profile = p;
        }
    }
}
 
Example #4
Source File: Analyzer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visit(Location o, Location t) {
    Archive targetArchive = findArchive(t);
    if (filter.accepts(o, archive, t, targetArchive)) {
        addDep(o, t);
        if (archive != targetArchive && !requires.contains(targetArchive)) {
            requires.add(targetArchive);
        }
    }
    if (targetArchive instanceof JDKArchive) {
        Profile p = Profile.getProfile(t.getPackageName());
        if (profile == null || (p != null && p.compareTo(profile) > 0)) {
            profile = p;
        }
    }
}
 
Example #5
Source File: JdepsTask.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the given archive is JDK archive, this method returns the profile name
 * only if -profile option is specified; it accesses a private JDK API and
 * the returned value will have "JDK internal API" prefix
 *
 * For non-JDK archives, this method returns the file name of the archive.
 */
private String toTag(String name, Archive source, Analyzer.Type type) {
    if (!isJDKArchive(source)) {
        return source.getName();
    }

    JDKArchive jdk = (JDKArchive)source;
    boolean isExported = false;
    if (type == CLASS || type == VERBOSE) {
        isExported = jdk.isExported(name);
    } else {
        isExported = jdk.isExportedPackage(name);
    }
    Profile p = getProfile(name, type);
    if (isExported) {
        // exported API
        return options.showProfile && p != null ? p.profileName() : "";
    } else {
        return "JDK internal API (" + source.getName() + ")";
    }
}
 
Example #6
Source File: JdepsTask.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the given archive is JDK archive, this method returns the profile name
 * only if -profile option is specified; it accesses a private JDK API and
 * the returned value will have "JDK internal API" prefix
 *
 * For non-JDK archives, this method returns the file name of the archive.
 */
private String toTag(String name, Archive source, Analyzer.Type type) {
    if (!isJDKArchive(source)) {
        return source.getName();
    }

    JDKArchive jdk = (JDKArchive)source;
    boolean isExported = false;
    if (type == CLASS || type == VERBOSE) {
        isExported = jdk.isExported(name);
    } else {
        isExported = jdk.isExportedPackage(name);
    }
    Profile p = getProfile(name, type);
    if (isExported) {
        // exported API
        return options.showProfile && p != null ? p.profileName() : "";
    } else {
        return "JDK internal API (" + source.getName() + ")";
    }
}
 
Example #7
Source File: Analyzer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visit(Location o, Location t) {
    Archive targetArchive = findArchive(t);
    if (filter.accepts(o, archive, t, targetArchive)) {
        addDep(o, t);
        if (archive != targetArchive && !requires.contains(targetArchive)) {
            requires.add(targetArchive);
        }
    }
    if (targetArchive instanceof JDKArchive) {
        Profile p = Profile.getProfile(t.getPackageName());
        if (profile == null || (p != null && p.compareTo(profile) > 0)) {
            profile = p;
        }
    }
}
 
Example #8
Source File: JdepsTask.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitDependence(String origin, Archive source,
                            String target, Archive archive, Profile profile) {
    if (options.findJDKInternals &&
            !(archive instanceof JDKArchive && profile == null)) {
        // filter dependences other than JDK internal APIs
        return;
    }
    if (options.verbose == Analyzer.Type.VERBOSE) {
        writer.format("   %-50s -> %-50s %s%n",
                      origin, target, getProfileArchiveInfo(archive, profile));
    } else {
        if (!origin.equals(pkg)) {
            pkg = origin;
            writer.format("   %s (%s)%n", origin, source.getFileName());
        }
        writer.format("      -> %-50s %s%n",
                      target, getProfileArchiveInfo(archive, profile));
    }
}
 
Example #9
Source File: JdepsTask.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the given archive is JDK archive, this method returns the profile name
 * only if -profile option is specified; it accesses a private JDK API and
 * the returned value will have "JDK internal API" prefix
 *
 * For non-JDK archives, this method returns the file name of the archive.
 */
private String toTag(String name, Archive source, Analyzer.Type type) {
    if (!isJDKArchive(source)) {
        return source.getName();
    }

    JDKArchive jdk = (JDKArchive)source;
    boolean isExported = false;
    if (type == CLASS || type == VERBOSE) {
        isExported = jdk.isExported(name);
    } else {
        isExported = jdk.isExportedPackage(name);
    }
    Profile p = getProfile(name, type);
    if (isExported) {
        // exported API
        return options.showProfile && p != null ? p.profileName() : "";
    } else {
        return "JDK internal API (" + source.getName() + ")";
    }
}
 
Example #10
Source File: JdepsTask.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the given archive is JDK archive, this method returns the profile name
 * only if -profile option is specified; it accesses a private JDK API and
 * the returned value will have "JDK internal API" prefix
 *
 * For non-JDK archives, this method returns the file name of the archive.
 */
private String toTag(String name, Archive source, Analyzer.Type type) {
    if (!isJDKArchive(source)) {
        return source.getName();
    }

    JDKArchive jdk = (JDKArchive)source;
    boolean isExported = false;
    if (type == CLASS || type == VERBOSE) {
        isExported = jdk.isExported(name);
    } else {
        isExported = jdk.isExportedPackage(name);
    }
    Profile p = getProfile(name, type);
    if (isExported) {
        // exported API
        return options.showProfile && p != null ? p.profileName() : "";
    } else {
        return "JDK internal API (" + source.getName() + ")";
    }
}
 
Example #11
Source File: Analyzer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visit(Location o, Location t) {
    Archive targetArchive = findArchive(t);
    if (filter.accepts(o, archive, t, targetArchive)) {
        addDep(o, t);
        if (archive != targetArchive && !requires.contains(targetArchive)) {
            requires.add(targetArchive);
        }
    }
    if (targetArchive instanceof JDKArchive) {
        Profile p = Profile.getProfile(t.getPackageName());
        if (profile == null || (p != null && p.compareTo(profile) > 0)) {
            profile = p;
        }
    }
}
 
Example #12
Source File: JdepsTask.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitDependence(String origin, Archive source,
                            String target, Archive archive, Profile profile) {
    if (options.findJDKInternals &&
            !(archive instanceof JDKArchive && profile == null)) {
        // filter dependences other than JDK internal APIs
        return;
    }
    if (options.verbose == Analyzer.Type.VERBOSE) {
        writer.format("   %-50s -> %-50s %s%n",
                      origin, target, getProfileArchiveInfo(archive, profile));
    } else {
        if (!origin.equals(pkg)) {
            pkg = origin;
            writer.format("   %s (%s)%n", origin, source.getFileName());
        }
        writer.format("      -> %-50s %s%n",
                      target, getProfileArchiveInfo(archive, profile));
    }
}
 
Example #13
Source File: Analyzer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void add(String origin, String target, Archive targetArchive, String pkgName) {
    SortedSet<Dep> set = deps.get(origin);
    if (set == null) {
        deps.put(origin, set = new TreeSet<>());
    }
    Profile p = targetArchive instanceof JDKArchive
                    ? Profile.getProfile(pkgName) : null;
    set.add(new Dep(target, targetArchive, p));
}
 
Example #14
Source File: Analyzer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void add(String origin, String target, Archive targetArchive, String pkgName) {
    SortedSet<Dep> set = deps.get(origin);
    if (set == null) {
        deps.put(origin, set = new TreeSet<>());
    }
    Profile p = targetArchive instanceof JDKArchive
                    ? Profile.getProfile(pkgName) : null;
    set.add(new Dep(target, targetArchive, p));
}
 
Example #15
Source File: JdepsTask.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitArchiveDependence(Archive origin, Archive target, Profile profile) {
    // add an edge with the archive's name with no tag
    // so that there is only one node for each JDK archive
    // while there may be edges to different profiles
    Edge e = addEdge(origin, target, "");
    if (target instanceof JDKArchive) {
        // add a label to print the profile
        if (profile == null) {
            e.addLabel("JDK internal API");
        } else if (options.showProfile && !options.showLabel) {
            e.addLabel(profile.toString());
        }
    }
}
 
Example #16
Source File: JdepsTask.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private boolean run() throws IOException {
    // parse classfiles and find all dependencies
    findDependencies();

    Analyzer analyzer = new Analyzer(options.verbose, new Analyzer.Filter() {
        @Override
        public boolean accepts(Location origin, Archive originArchive,
                               Location target, Archive targetArchive)
        {
            if (options.findJDKInternals) {
                // accepts target that is JDK class but not exported
                return isJDKArchive(targetArchive) &&
                          !((JDKArchive) targetArchive).isExported(target.getClassName());
            } else if (options.filterSameArchive) {
                // accepts origin and target that from different archive
                return originArchive != targetArchive;
            }
            return true;
        }
    });

    // analyze the dependencies
    analyzer.run(sourceLocations);

    // output result
    if (options.dotOutputDir != null) {
        Path dir = Paths.get(options.dotOutputDir);
        Files.createDirectories(dir);
        generateDotFiles(dir, analyzer);
    } else {
        printRawOutput(log, analyzer);
    }

    if (options.findJDKInternals && !options.nowarning) {
        showReplacements(analyzer);
    }
    return true;
}
 
Example #17
Source File: JdepsTask.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitDependence(String origin, Archive originArchive,
                            String target, Archive targetArchive) {
    writer.format("%s -> %s", originArchive.getName(), targetArchive.getPathName());
    if (options.showProfile && JDKArchive.isProfileArchive(targetArchive)) {
        writer.format(" (%s)", target);
    }
    writer.format("%n");
}
 
Example #18
Source File: JdepsTask.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitDependence(String origin, Archive originArchive,
                            String target, Archive targetArchive) {
    String targetName = type == PACKAGE ? target : targetArchive.getName();
    if (type == PACKAGE) {
        String tag = toTag(target, targetArchive, type);
        if (!tag.isEmpty())
            targetName += " (" + tag + ")";
    } else if (options.showProfile && JDKArchive.isProfileArchive(targetArchive)) {
        targetName += " (" + target + ")";
    }
    String label = getLabel(originArchive, targetArchive);
    writer.format("  %-50s -> \"%s\"%s;%n",
                  String.format("\"%s\"", origin), targetName, label);
}
 
Example #19
Source File: JdepsTask.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitDependence(String origin, Archive source,
                            String target, Archive archive, Profile profile) {
    if (options.findJDKInternals &&
            !(archive instanceof JDKArchive && profile == null)) {
        // filter dependences other than JDK internal APIs
        return;
    }
    // if -P option is specified, package name -> profile will
    // be shown and filter out multiple same edges.
    String name = getProfileArchiveInfo(archive, profile);
    writeEdge(writer, new Edge(origin, target, getProfileArchiveInfo(archive, profile)));
}
 
Example #20
Source File: JdepsTask.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the given archive is JDK archive and non-null Profile,
 * this method returns the profile name only if -profile option is specified;
 * a null profile indicates it accesses a private JDK API and this method
 * will return "JDK internal API".
 *
 * For non-JDK archives, this method returns the file name of the archive.
 */
private String getProfileArchiveInfo(Archive source, Profile profile) {
    if (options.showProfile && profile != null)
        return profile.toString();

    if (source instanceof JDKArchive) {
        return profile == null ? "JDK internal API (" + source.getFileName() + ")" : "";
    }
    return source.getFileName();
}
 
Example #21
Source File: JdepsTask.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the profile name or "JDK internal API" for JDK archive;
 * otherwise empty string.
 */
private String profileName(Archive archive, Profile profile) {
    if (archive instanceof JDKArchive) {
        return Objects.toString(profile, "JDK internal API");
    } else {
        return "";
    }
}
 
Example #22
Source File: JdepsTask.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the profile name or "JDK internal API" for JDK archive;
 * otherwise empty string.
 */
private String profileName(Archive archive, Profile profile) {
    if (archive instanceof JDKArchive) {
        return Objects.toString(profile, "JDK internal API");
    } else {
        return "";
    }
}
 
Example #23
Source File: JdepsTask.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitDependence(String origin, Archive originArchive,
                            String target, Archive targetArchive) {
    String targetName = type == PACKAGE ? target : targetArchive.getName();
    if (type == PACKAGE) {
        String tag = toTag(target, targetArchive, type);
        if (!tag.isEmpty())
            targetName += " (" + tag + ")";
    } else if (options.showProfile && JDKArchive.isProfileArchive(targetArchive)) {
        targetName += " (" + target + ")";
    }
    String label = getLabel(originArchive, targetArchive);
    writer.format("  %-50s -> \"%s\"%s;%n",
                  String.format("\"%s\"", origin), targetName, label);
}
 
Example #24
Source File: JdepsTask.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitDependence(String origin, Archive source,
                            String target, Archive archive, Profile profile) {
    if (options.findJDKInternals &&
            !(archive instanceof JDKArchive && profile == null)) {
        // filter dependences other than JDK internal APIs
        return;
    }
    // if -P option is specified, package name -> profile will
    // be shown and filter out multiple same edges.
    String name = getProfileArchiveInfo(archive, profile);
    writeEdge(writer, new Edge(origin, target, getProfileArchiveInfo(archive, profile)));
}
 
Example #25
Source File: JdepsTask.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the given archive is JDK archive and non-null Profile,
 * this method returns the profile name only if -profile option is specified;
 * a null profile indicates it accesses a private JDK API and this method
 * will return "JDK internal API".
 *
 * For non-JDK archives, this method returns the file name of the archive.
 */
private String getProfileArchiveInfo(Archive source, Profile profile) {
    if (options.showProfile && profile != null)
        return profile.toString();

    if (source instanceof JDKArchive) {
        return profile == null ? "JDK internal API (" + source.getFileName() + ")" : "";
    }
    return source.getFileName();
}
 
Example #26
Source File: JdepsTask.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitArchiveDependence(Archive origin, Archive target, Profile profile) {
    // add an edge with the archive's name with no tag
    // so that there is only one node for each JDK archive
    // while there may be edges to different profiles
    Edge e = addEdge(origin, target, "");
    if (target instanceof JDKArchive) {
        // add a label to print the profile
        if (profile == null) {
            e.addLabel("JDK internal API");
        } else if (options.showProfile && !options.showLabel) {
            e.addLabel(profile.toString());
        }
    }
}
 
Example #27
Source File: JdepsTask.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitDependence(String origin, Archive originArchive,
                            String target, Archive targetArchive) {
    writer.format("%s -> %s", originArchive.getName(), targetArchive.getPathName());
    if (options.showProfile && JDKArchive.isProfileArchive(targetArchive)) {
        writer.format(" (%s)", target);
    }
    writer.format("%n");
}
 
Example #28
Source File: JdepsTask.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitDependence(String origin, Archive originArchive,
                            String target, Archive targetArchive) {
    writer.format("%s -> %s", originArchive.getName(), targetArchive.getPathName());
    if (options.showProfile && JDKArchive.isProfileArchive(targetArchive)) {
        writer.format(" (%s)", target);
    }
    writer.format("%n");
}
 
Example #29
Source File: JdepsTask.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitDependence(String origin, Archive originArchive,
                            String target, Archive targetArchive) {
    String targetName = type == PACKAGE ? target : targetArchive.getName();
    if (type == PACKAGE) {
        String tag = toTag(target, targetArchive, type);
        if (!tag.isEmpty())
            targetName += " (" + tag + ")";
    } else if (options.showProfile && JDKArchive.isProfileArchive(targetArchive)) {
        targetName += " (" + target + ")";
    }
    String label = getLabel(originArchive, targetArchive);
    writer.format("  %-50s -> \"%s\"%s;%n",
                  String.format("\"%s\"", origin), targetName, label);
}
 
Example #30
Source File: JdepsTask.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private boolean run() throws IOException {
    // parse classfiles and find all dependencies
    findDependencies();

    Analyzer analyzer = new Analyzer(options.verbose, new Analyzer.Filter() {
        @Override
        public boolean accepts(Location origin, Archive originArchive,
                               Location target, Archive targetArchive)
        {
            if (options.findJDKInternals) {
                // accepts target that is JDK class but not exported
                return isJDKArchive(targetArchive) &&
                          !((JDKArchive) targetArchive).isExported(target.getClassName());
            } else if (options.filterSameArchive) {
                // accepts origin and target that from different archive
                return originArchive != targetArchive;
            }
            return true;
        }
    });

    // analyze the dependencies
    analyzer.run(sourceLocations);

    // output result
    if (options.dotOutputDir != null) {
        Path dir = Paths.get(options.dotOutputDir);
        Files.createDirectories(dir);
        generateDotFiles(dir, analyzer);
    } else {
        printRawOutput(log, analyzer);
    }

    if (options.findJDKInternals && !options.nowarning) {
        showReplacements(analyzer);
    }
    return true;
}