1/* 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. 4 * 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 7 * published by the Free Software Foundation. 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 4670772 6328529 27 * @summary Completion failures should be ignored in javadoc. 28 * @author gafter 29 * @modules jdk.javadoc/jdk.javadoc.internal.tool 30 */ 31 32 33import java.io.PrintWriter; 34import java.util.*; 35 36import javax.lang.model.SourceVersion; 37import javax.lang.model.element.TypeElement; 38import javax.lang.model.util.ElementFilter; 39 40import jdk.javadoc.doclet.Doclet; 41import jdk.javadoc.doclet.DocletEnvironment; 42import jdk.javadoc.doclet.Reporter; 43 44public class CompletionFailure implements Doclet { 45 public static void main(String[] args) { 46 String[] toolargs = { 47 "-doclet", "CompletionFailure", 48 "-docletpath", System.getProperty("test.classes", "."), 49 "pkg" 50 }; 51 // run javadoc on package pkg 52 if (jdk.javadoc.internal.tool.Main.execute(toolargs, 53 new PrintWriter(System.err)) != 0) 54 throw new Error(); 55 } 56 57 public boolean run(DocletEnvironment root) { 58 Set<TypeElement> classes = ElementFilter.typesIn(root.getIncludedElements()); 59 if (classes.size() != 1) 60 throw new Error("1 " + Arrays.asList(classes)); 61 return true; 62 } 63 64 @Override 65 public String getName() { 66 return "Test"; 67 } 68 69 @Override 70 public Set<Option> getSupportedOptions() { 71 return Collections.emptySet(); 72 } 73 74 @Override 75 public SourceVersion getSupportedSourceVersion() { 76 return SourceVersion.latest(); 77 } 78 79 @Override 80 public void init(Locale locale, Reporter reporter) { 81 // do nothing 82 } 83} 84