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 5012972 27 * @summary ClassDoc.getImportedClasses should return a class even if 28 * it's not in the classpath. 29 * @modules jdk.javadoc 30 */ 31 32 import com.sun.javadoc.*; 33 34 35 public class MissingImport extends Doclet { 36 37 public static void main(String[] args) { 38 String thisFile = "" + 39 new java.io.File(System.getProperty("test.src", "."), 40 "I.java"); 41 42 if (com.sun.tools.javadoc.Main.execute( 43 "javadoc", 44 "MissingImport", 45 MissingImport.class.getClassLoader(), 46 new String[] {thisFile}) != 0) 47 throw new Error("Javadoc encountered warnings or errors."); 48 } 49 50 /* 51 * The world's simplest doclet. 52 */ 53 public static boolean start(RootDoc root) { 54 ClassDoc c = root.classNamed("I"); 55 ClassDoc[] imps = c.importedClasses(); 56 if (imps.length == 0 || 57 !imps[0].qualifiedName().equals("bo.o.o.o.Gus")) { 58 throw new Error("Import bo.o.o.o.Gus not found"); 59 } 60 return true; 61 } 62 } | 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 5012972 27 * @summary ClassDoc.getImportedClasses should return a class even if 28 * it's not in the classpath. 29 * @ignore API modifications, testing deprecated APIs. 30 * @modules jdk.javadoc 31 */ 32 33 import java.util.Collections; 34 import java.util.Set; 35 import javax.lang.model.SourceVersion; 36 import jdk.javadoc.doclet.Doclet; 37 import jdk.javadoc.doclet.Doclet.Option; 38 import jdk.javadoc.doclet.DocletEnvironment; 39 40 41 public class MissingImport implements Doclet { 42 43 public static void main(String[] args) { 44 String thisFile = "" + 45 new java.io.File(System.getProperty("test.src", "."), 46 "I.java"); 47 String[] toolargs = { 48 "-doclet", "MissingImport", 49 "-docletpath", System.getProperty("test.classes", "."), 50 thisFile 51 }; 52 if (com.sun.tools.javadoc.Main.execute(toolargs) != 0) 53 throw new Error("Javadoc encountered warnings or errors."); 54 } 55 56 /* 57 * The world's simplest doclet. 58 */ 59 public static boolean run(DocletEnvironment root) { 60 ClassDoc c = root.classNamed("I"); 61 ClassDoc[] imps = c.importedClasses(); 62 if (imps.length == 0 || 63 !imps[0].qualifiedName().equals("bo.o.o.o.Gus")) { 64 throw new Error("Import bo.o.o.o.Gus not found"); 65 } 66 return true; 67 } 68 69 @Override 70 public String getName() { 71 return "Test"; 72 } 73 74 @Override 75 public Set<Option> getSupportedOptions() { 76 return Collections.emptySet(); 77 } 78 79 @Override 80 public SourceVersion getSupportedSourceVersion() { 81 return SourceVersion.latest(); 82 } 83 } |