test/tools/javadoc/BooleanConst.java

Tue, 25 May 2010 15:54:51 -0700

author
ohair
date
Tue, 25 May 2010 15:54:51 -0700
changeset 554
9d9f26857129
parent 174
fdfed22db054
child 2525
2eb010b6cb22
permissions
-rw-r--r--

6943119: Rebrand source copyright notices
Reviewed-by: darcy

     1 /*
     2  * Copyright (c) 2002, 2008, 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  */
    24 /*
    25  * @test
    26  * @bug 4587494
    27  * @summary Constant field values for boolean Data-Types don't use true and false
    28  * @author gafter
    29  * @run main BooleanConst
    30  */
    32 import com.sun.javadoc.*;
    33 import java.util.*;
    35 public class BooleanConst extends Doclet
    36 {
    37     public static void main(String[] args) {
    38         // run javadoc on package p
    39         if (com.sun.tools.javadoc.Main.
    40             execute("javadoc", "BooleanConst", BooleanConst.class.getClassLoader(),
    41                     new String[] {System.getProperty("test.src", ".") + java.io.File.separatorChar + "BooleanConst.java"}) != 0)
    42             throw new Error();
    43     }
    45     public static final boolean b1 = false;
    46     public static final boolean b2 = true;
    48     public static boolean start(com.sun.javadoc.RootDoc root) {
    49         ClassDoc[] classes = root.classes();
    50         if (classes.length != 1)
    51             throw new Error("1 " + Arrays.asList(classes));
    52         ClassDoc self = classes[0];
    53         FieldDoc[] fields = self.fields();
    54         if (fields.length != 2)
    55             throw new Error("2 " + Arrays.asList(fields));
    56         for (int i=0; i<fields.length; i++) {
    57             FieldDoc f = fields[i];
    58             if (f.name().equals("b1")) {
    59                 Object value = f.constantValue();
    60                 if (value == null || !(value instanceof Boolean) || ((Boolean)value).booleanValue())
    61                     throw new Error("4 " + value);
    62             } else if (f.name().equals("b2")) {
    63                 Object value = f.constantValue();
    64                 if (value == null || !(value instanceof Boolean) || !((Boolean)value).booleanValue())
    65                     throw new Error("5 " + value);
    66             } else throw new Error("3 " + f.name());
    67         }
    68         return true;
    69     }
    70 }

mercurial