langtools/test/tools/javadoc/CompletionError.java
changeset 44806 d6bdff2ad6f2
parent 36778 e04318f39f92
equal deleted inserted replaced
44692:7f959abfee57 44806:d6bdff2ad6f2
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    25  * @test
    25  * @test
    26  * @bug 8135307
    26  * @bug 8135307
    27  * @summary Check that CompletionFailures for missing classes are not incorrectly passed to
    27  * @summary Check that CompletionFailures for missing classes are not incorrectly passed to
    28  *          the javadoc API clients.
    28  *          the javadoc API clients.
    29  * @library /tools/lib
    29  * @library /tools/lib
    30  * @modules jdk.javadoc com.sun.tools.javac.api
    30  * @modules jdk.compiler/com.sun.tools.javac.api
       
    31  *          jdk.compiler/com.sun.tools.javac.main
    31  *          jdk.jdeps/com.sun.tools.javap
    32  *          jdk.jdeps/com.sun.tools.javap
       
    33  * @build toolbox.JavacTask toolbox.ToolBox
    32  * @run main CompletionError
    34  * @run main CompletionError
    33  */
    35  */
    34 
    36 
    35 import java.io.File;
    37 import java.io.File;
    36 
    38 
    37 import com.sun.javadoc.*;
    39 import com.sun.javadoc.*;
    38 import com.sun.tools.javadoc.Main;
    40 import com.sun.tools.javadoc.Main;
       
    41 
       
    42 import toolbox.JavacTask;
       
    43 import toolbox.ToolBox;
    39 
    44 
    40 public class CompletionError extends Doclet
    45 public class CompletionError extends Doclet
    41 {
    46 {
    42     private static final String template =
    47     private static final String template =
    43             "public class CompletionErrorAuxiliary #extends CompletionErrorMissing# #implements CompletionErrorIntfMissing# {" +
    48             "public class CompletionErrorAuxiliary #extends CompletionErrorMissing# #implements CompletionErrorIntfMissing# {" +
    46             "   #public void tm(CompletionErrorMissing m) {}#" +
    51             "   #public void tm(CompletionErrorMissing m) {}#" +
    47             "   #public void tm() throws CompletionErrorExcMissing {}#" +
    52             "   #public void tm() throws CompletionErrorExcMissing {}#" +
    48             "   #public <T extends CompletionErrorMissing> void tm() {}#" +
    53             "   #public <T extends CompletionErrorMissing> void tm() {}#" +
    49             "   public String toString() { return null; }" +
    54             "   public String toString() { return null; }" +
    50             "}";
    55             "}";
       
    56 
       
    57     private static final String testSrc = System.getProperty("test.src");
       
    58     private static final String testClassPath = System.getProperty("test.class.path");
    51 
    59 
    52     public static void main(String[] args) throws Exception {
    60     public static void main(String[] args) throws Exception {
    53         String[] templateParts = template.split("#");
    61         String[] templateParts = template.split("#");
    54         int sources = templateParts.length / 2;
    62         int sources = templateParts.length / 2;
    55         for (int source = 0; source < sources; source++) {
    63         for (int source = 0; source < sources; source++) {
    73                   .run()
    81                   .run()
    74                   .writeAll();
    82                   .writeAll();
    75                 tb.deleteFiles("CompletionErrorMissing.class", "CompletionErrorIntfMissing.class", "CompletionErrorExcMissing.class");
    83                 tb.deleteFiles("CompletionErrorMissing.class", "CompletionErrorIntfMissing.class", "CompletionErrorExcMissing.class");
    76                 // run javadoc:
    84                 // run javadoc:
    77                 if (Main.execute("javadoc", "CompletionError", CompletionError.class.getClassLoader(),
    85                 if (Main.execute("javadoc", "CompletionError", CompletionError.class.getClassLoader(),
    78                                  "-classpath", ".",
    86                                  "-classpath", "." + File.pathSeparator + testClassPath,
    79                                  System.getProperty("test.src", ".") + File.separatorChar + "CompletionError.java") != 0)
    87                                  new File(testSrc, "CompletionError.java").getPath()) != 0)
    80                     throw new Error();
    88                     throw new Error();
    81             }
    89             }
    82         }
    90         }
    83     }
    91     }
    84 
    92