test/tools/jdeps/APIDeps.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8015912 8029216 8048063 8050804
  27  * @summary Test -apionly and -jdkinternals options
  28  * @modules java.base/sun.misc
  29  *          java.management
  30  *          jdk.jdeps/com.sun.tools.classfile
  31  *          jdk.jdeps/com.sun.tools.jdeps
  32  * @build m.Bar m.Foo m.Gee b.B c.C c.I d.D e.E f.F g.G
  33  * @run main APIDeps
  34  */
  35 
  36 import java.io.File;
  37 import java.io.IOException;
  38 import java.io.PrintWriter;
  39 import java.io.StringWriter;
  40 import java.nio.file.Path;
  41 import java.nio.file.Paths;
  42 import java.util.*;
  43 import java.util.regex.*;
  44 
  45 public class APIDeps {
  46     public static void main(String... args) throws Exception {
  47         int errors = 0;
  48         errors += new APIDeps().run();


  55         String testDirBasename = testDir.toPath().getFileName().toString();
  56         File mDir = new File(testDir, "m");
  57         // all dependencies
  58         test(new File(mDir, "Bar.class"),
  59              new String[] {"java.lang.Object", "java.lang.String",
  60                            "java.util.Set", "java.util.HashSet",
  61                            "java.lang.management.ManagementFactory",
  62                            "java.lang.management.RuntimeMXBean",
  63                            "b.B", "c.C", "d.D", "f.F", "g.G"},
  64              new String[] {"compact1", "compact3", testDirBasename},
  65              new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"});
  66         test(new File(mDir, "Foo.class"),
  67              new String[] {"c.I", "e.E", "f.F"},
  68              new String[] {testDirBasename},
  69              new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-P"});
  70         test(new File(mDir, "Foo.class"),
  71              new String[] {"c.I", "e.E", "f.F", "m.Bar"},
  72              new String[] {testDirBasename},
  73              new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-filter:none", "-P"});
  74         test(new File(mDir, "Gee.class"),
  75              new String[] {"g.G", "sun.misc.Lock", "com.sun.tools.classfile.ClassFile",
  76                            "com.sun.management.ThreadMXBean", "com.sun.source.tree.BinaryTree"},
  77              new String[] {testDirBasename, "JDK internal API", "compact3", ""},
  78              new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"});
  79 
  80         // -jdkinternals
  81         test(new File(mDir, "Gee.class"),
  82              new String[] {"sun.misc.Lock", "com.sun.tools.classfile.ClassFile"},
  83              new String[] {"JDK internal API"},
  84              new String[] {"-jdkinternals"});
  85         // -jdkinternals parses all classes on -classpath and the input arguments
  86         test(new File(mDir, "Gee.class"),
  87              new String[] {"com.sun.tools.jdeps.Main", "com.sun.tools.classfile.ClassFile",
  88                            "sun.misc.Lock", "sun.misc.Unsafe"},
  89              new String[] {"JDK internal API"},
  90              new String[] {"-classpath", testDir.getPath(), "-jdkinternals"});
  91 
  92         // parse only APIs
  93         test(mDir,
  94              new String[] {"java.lang.Object", "java.lang.String",
  95                            "java.util.Set",
  96                            "c.C", "d.D", "c.I", "e.E"},
  97              new String[] {"compact1", testDirBasename},
  98              new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-P", "-apionly"});
  99 
 100         test(mDir,
 101              new String[] {"java.lang.Object", "java.lang.String",
 102                            "java.util.Set",
 103                            "c.C", "d.D", "c.I", "e.E", "m.Bar"},
 104              new String[] {"compact1", testDirBasename, mDir.getName()},
 105              new String[] {"-classpath", testDir.getPath(), "-verbose", "-P", "-apionly"});
 106         return errors;
 107     }
 108 




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8015912 8029216 8048063 8050804
  27  * @summary Test -apionly and -jdkinternals options
  28  * @modules java.base/sun.security.x509
  29  *          java.management
  30  *          jdk.jdeps/com.sun.tools.classfile
  31  *          jdk.jdeps/com.sun.tools.jdeps
  32  * @build m.Bar m.Foo m.Gee b.B c.C c.I d.D e.E f.F g.G
  33  * @run main APIDeps
  34  */
  35 
  36 import java.io.File;
  37 import java.io.IOException;
  38 import java.io.PrintWriter;
  39 import java.io.StringWriter;
  40 import java.nio.file.Path;
  41 import java.nio.file.Paths;
  42 import java.util.*;
  43 import java.util.regex.*;
  44 
  45 public class APIDeps {
  46     public static void main(String... args) throws Exception {
  47         int errors = 0;
  48         errors += new APIDeps().run();


  55         String testDirBasename = testDir.toPath().getFileName().toString();
  56         File mDir = new File(testDir, "m");
  57         // all dependencies
  58         test(new File(mDir, "Bar.class"),
  59              new String[] {"java.lang.Object", "java.lang.String",
  60                            "java.util.Set", "java.util.HashSet",
  61                            "java.lang.management.ManagementFactory",
  62                            "java.lang.management.RuntimeMXBean",
  63                            "b.B", "c.C", "d.D", "f.F", "g.G"},
  64              new String[] {"compact1", "compact3", testDirBasename},
  65              new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"});
  66         test(new File(mDir, "Foo.class"),
  67              new String[] {"c.I", "e.E", "f.F"},
  68              new String[] {testDirBasename},
  69              new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-P"});
  70         test(new File(mDir, "Foo.class"),
  71              new String[] {"c.I", "e.E", "f.F", "m.Bar"},
  72              new String[] {testDirBasename},
  73              new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-filter:none", "-P"});
  74         test(new File(mDir, "Gee.class"),
  75              new String[] {"g.G", "sun.security.x509.X509CertInfo", "com.sun.tools.classfile.ClassFile",
  76                            "com.sun.management.ThreadMXBean", "com.sun.source.tree.BinaryTree"},
  77              new String[] {testDirBasename, "JDK internal API", "compact3", ""},
  78              new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"});
  79 
  80         // -jdkinternals
  81         test(new File(mDir, "Gee.class"),
  82              new String[] {"sun.security.x509.X509CertInfo", "com.sun.tools.classfile.ClassFile"},
  83              new String[] {"JDK internal API"},
  84              new String[] {"-jdkinternals"});
  85         // -jdkinternals parses all classes on -classpath and the input arguments
  86         test(new File(mDir, "Gee.class"),
  87              new String[] {"com.sun.tools.jdeps.Main", "com.sun.tools.classfile.ClassFile",
  88                            "sun.security.x509.X509CertInfo", "sun.misc.Unsafe"},
  89              new String[] {"JDK internal API"},
  90              new String[] {"-classpath", testDir.getPath(), "-jdkinternals"});
  91 
  92         // parse only APIs
  93         test(mDir,
  94              new String[] {"java.lang.Object", "java.lang.String",
  95                            "java.util.Set",
  96                            "c.C", "d.D", "c.I", "e.E"},
  97              new String[] {"compact1", testDirBasename},
  98              new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-P", "-apionly"});
  99 
 100         test(mDir,
 101              new String[] {"java.lang.Object", "java.lang.String",
 102                            "java.util.Set",
 103                            "c.C", "d.D", "c.I", "e.E", "m.Bar"},
 104              new String[] {"compact1", testDirBasename, mDir.getName()},
 105              new String[] {"-classpath", testDir.getPath(), "-verbose", "-P", "-apionly"});
 106         return errors;
 107     }
 108