Path: blob/master/test/langtools/jdk/javadoc/tool/LangVers.java
40957 views
/*1* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 490976726* @summary Verify that omitting Doclet.languageVersion() hides 1.5 language27* features from the doclet.28* @ignore API, re-evaluate, unsure of this test.29* @modules jdk.javadoc30*/3132import java.util.Collections;33import java.util.List;34import java.util.Set;3536import javax.lang.model.SourceVersion;3738import jdk.javadoc.doclet.Doclet;39import jdk.javadoc.doclet.DocletEnvironment;4041public class LangVers implements Doclet {4243public static void main(String[] args) {44String thisFile = "" +45new java.io.File(System.getProperty("test.src", "."),46"LangVers.java");4748String[] toolargs = {49"-doclet", "LangVers",50"-docletpath", System.getProperty("test.classes", "."),51};52if (jdk.javadoc.internal.tool.Main.execute(toolargs) != 0)53throw new Error("Javadoc encountered warnings or errors.");54}5556public boolean run(DocletEnvironment root) {57ClassDoc fishdoc = root.classNamed("LangVers.Fish");58System.out.println(fishdoc);59if (fishdoc.isEnum()) {60throw new Error("Enums are not hidden.");61}6263for (MethodDoc meth : fishdoc.methods()) {64System.out.println(meth);65if (meth.flatSignature().indexOf('<') >= 0) {66throw new Error("Type parameters are not hidden.");67}68}6970return true;71}7273public enum Fish {74One, Two, Red, Blue;7576public void enroll(List<? super Fish> school) {77school.add(this);78}79}8081@Override82public String getName() {83return "Test";84}8586@Override87public Set<Option> getSupportedOptions() {88return Collections.emptySet();89}9091@Override92public SourceVersion getSupportedSourceVersion() {93return SourceVersion.latest();94}95}969798