src/share/classes/com/sun/tools/classfile/Dependency.java

Fri, 28 Dec 2012 22:25:21 -0800

author
mchung
date
Fri, 28 Dec 2012 22:25:21 -0800
changeset 1472
0c244701188e
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8003562: Provide a CLI tool to analyze class dependencies
Reviewed-by: jjg, alanb, ulfzibis, erikj

jjg@451 1 /*
ohair@554 2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
jjg@451 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@451 4 *
jjg@451 5 * This code is free software; you can redistribute it and/or modify it
jjg@451 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
jjg@451 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
jjg@451 10 *
jjg@451 11 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@451 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@451 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@451 14 * version 2 for more details (a copy is included in the LICENSE file that
jjg@451 15 * accompanied this code).
jjg@451 16 *
jjg@451 17 * You should have received a copy of the GNU General Public License version
jjg@451 18 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@451 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@451 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
jjg@451 24 */
jjg@451 25
jjg@451 26 package com.sun.tools.classfile;
jjg@451 27
jjg@451 28
jjg@451 29 /**
jjg@451 30 * A directed relationship between two {@link Dependency.Location Location}s.
jjg@451 31 * Subtypes of {@code Dependency} may provide additional detail about the dependency.
jjg@451 32 *
jjg@451 33 * @see Dependency.Finder
jjg@451 34 * @see Dependency.Filter
jjg@451 35 * @see Dependencies
jjg@451 36 */
jjg@451 37 public interface Dependency {
jjg@451 38 /**
jjg@451 39 * A filter used to select dependencies of interest, and to discard others.
jjg@451 40 */
jjg@451 41 public interface Filter {
jjg@451 42 /**
jjg@451 43 * Return true if the dependency is of interest.
jjg@451 44 * @param dependency the dependency to be considered
jjg@451 45 * @return true if and only if the dependency is of interest.
jjg@451 46 */
jjg@451 47 boolean accepts(Dependency dependency);
jjg@451 48 }
jjg@451 49
jjg@451 50 /**
jjg@451 51 * An interface for finding the immediate dependencies of a given class file.
jjg@451 52 */
jjg@451 53 public interface Finder {
jjg@451 54 /**
jjg@451 55 * Find the immediate dependencies of a given class file.
jjg@451 56 * @param classfile the class file to be examined
jjg@452 57 * @return the dependencies located in the given class file.
jjg@451 58 */
jjg@451 59 public Iterable<? extends Dependency> findDependencies(ClassFile classfile);
jjg@451 60 }
jjg@451 61
jjg@451 62
jjg@451 63 /**
jjg@451 64 * A location somewhere within a class. Subtypes of {@code Location}
jjg@451 65 * may be used to provide additional detail about the location.
jjg@451 66 */
jjg@451 67 public interface Location {
jjg@451 68 /**
jjg@451 69 * Get the name of the class containing the location.
jjg@451 70 * This name will be used to locate the class file for transitive
jjg@451 71 * dependency analysis.
jjg@451 72 * @return the name of the class containing the location.
jjg@451 73 */
mchung@1472 74 String getName();
mchung@1472 75
mchung@1472 76 /**
mchung@1472 77 * Get the fully-qualified name of the class containing the location.
mchung@1472 78 * @return the fully-qualified name of the class containing the location.
mchung@1472 79 */
jjg@451 80 String getClassName();
mchung@1472 81
mchung@1472 82 /**
mchung@1472 83 * Get the package name of the class containing the location.
mchung@1472 84 * @return the package name of the class containing the location.
mchung@1472 85 */
mchung@1472 86 String getPackageName();
jjg@451 87 }
jjg@451 88
jjg@451 89
jjg@451 90 /**
jjg@451 91 * Get the location that has the dependency.
jjg@451 92 * @return the location that has the dependency.
jjg@451 93 */
jjg@451 94 Location getOrigin();
jjg@451 95
jjg@451 96 /**
jjg@451 97 * Get the location that is being depended upon.
jjg@451 98 * @return the location that is being depended upon.
jjg@451 99 */
jjg@451 100 Location getTarget();
jjg@451 101 }
jjg@451 102

mercurial