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