Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javadoc/BooleanConst.java
32285 views
/*1* Copyright (c) 2002, 2008, 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 458749426* @summary Constant field values for boolean Data-Types don't use true and false27* @author gafter28* @run main BooleanConst29*/3031import com.sun.javadoc.*;32import java.util.*;3334public class BooleanConst extends Doclet35{36public static void main(String[] args) {37// run javadoc on package p38if (com.sun.tools.javadoc.Main.39execute("javadoc", "BooleanConst", BooleanConst.class.getClassLoader(),40new String[] {System.getProperty("test.src", ".") + java.io.File.separatorChar + "BooleanConst.java"}) != 0)41throw new Error();42}4344public static final boolean b1 = false;45public static final boolean b2 = true;4647public static boolean start(com.sun.javadoc.RootDoc root) {48ClassDoc[] classes = root.classes();49if (classes.length != 1)50throw new Error("1 " + Arrays.asList(classes));51ClassDoc self = classes[0];52FieldDoc[] fields = self.fields();53if (fields.length != 2)54throw new Error("2 " + Arrays.asList(fields));55for (int i=0; i<fields.length; i++) {56FieldDoc f = fields[i];57if (f.name().equals("b1")) {58Object value = f.constantValue();59if (value == null || !(value instanceof Boolean) || ((Boolean)value).booleanValue())60throw new Error("4 " + value);61} else if (f.name().equals("b2")) {62Object value = f.constantValue();63if (value == null || !(value instanceof Boolean) || !((Boolean)value).booleanValue())64throw new Error("5 " + value);65} else throw new Error("3 " + f.name());66}67return true;68}69}707172