langtools/test/jdk/javadoc/tool/sourceOnly/p/SourceOnly.java
changeset 40310 a979695d72a1
parent 35426 374342e56a56
child 40508 74ef30d16fb9
equal deleted inserted replaced
40309:4c9d829b21ea 40310:a979695d72a1
     1 /*
     1 /*
     2  * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2002, 2016, 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.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 package p;
    24 package p;
    25 
    25 
       
    26 import java.util.Arrays;
    26 import java.util.Collections;
    27 import java.util.Collections;
       
    28 import java.util.Locale;
    27 import java.util.Set;
    29 import java.util.Set;
    28 
    30 
    29 import javax.lang.model.SourceVersion;
    31 import javax.lang.model.SourceVersion;
    30 
    32 
    31 import jdk.javadoc.doclet.Doclet;
    33 import jdk.javadoc.doclet.Doclet;
    32 import jdk.javadoc.doclet.DocletEnvironment;
    34 import jdk.javadoc.doclet.DocletEnvironment;
       
    35 import jdk.javadoc.doclet.Reporter;
    33 
    36 
    34 /** Test that when running javadoc on a package, we only get
    37 /** Test that when running javadoc on a package, we only get
    35  *  documentation for those classes for which source was provided.
    38  *  documentation for those classes for which source was provided.
    36  */
    39  */
    37 public class SourceOnly implements Doclet {
    40 public class SourceOnly implements Doclet {
    38     public static void main(String[] args) {
    41     NonSource dependency; // force a compilation error if not on classpath.
    39         // run javadoc on package p
    42     @Override
    40         int result = jdk.javadoc.internal.tool.Main.
    43     public boolean run(DocletEnvironment root) {
    41             execute("javadoc", "p.SourceOnly", SourceOnly.class.getClassLoader(), new String[] {"p"});
       
    42         if (result != 0)
       
    43             throw new Error();
       
    44     }
       
    45 
       
    46     public boolean start(DocletEnvironment root) {
       
    47         if (root.getIncludedClasses().size() != 1)
    44         if (root.getIncludedClasses().size() != 1)
    48             throw new Error("wrong set of classes documented: " + java.util.Arrays.asList(root.getIncludedClasses()));
    45             throw new Error("wrong set of classes documented: " +
       
    46                     Arrays.asList(root.getIncludedClasses()));
    49         return true;
    47         return true;
    50     }
    48     }
    51 
    49 
    52     @Override
    50     @Override
    53     public String getName() {
    51     public String getName() {
    61 
    59 
    62     @Override
    60     @Override
    63     public SourceVersion getSupportedSourceVersion() {
    61     public SourceVersion getSupportedSourceVersion() {
    64         return SourceVersion.latest();
    62         return SourceVersion.latest();
    65     }
    63     }
       
    64 
       
    65     @Override
       
    66     public void init(Locale locale, Reporter reporter) {
       
    67         // do nothing
       
    68     }
    66 }
    69 }