toStringTest.java revision 0
342N/A/*
342N/A * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
342N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
342N/A *
342N/A * This code is free software; you can redistribute it and/or modify it
342N/A * under the terms of the GNU General Public License version 2 only, as
342N/A * published by the Free Software Foundation.
342N/A *
342N/A * This code is distributed in the hope that it will be useful, but WITHOUT
342N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
342N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
342N/A * version 2 for more details (a copy is included in the LICENSE file that
342N/A * accompanied this code).
342N/A *
342N/A * You should have received a copy of the GNU General Public License version
342N/A * 2 along with this work; if not, write to the Free Software Foundation,
342N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
342N/A *
342N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
342N/A * CA 95054 USA or visit www.sun.com if you need additional information or
342N/A * have any questions.
342N/A */
342N/A
342N/A/**
342N/A * @test
342N/A * @bug 4394937
342N/A * @summary tests the toString method of reflect.Modifier
342N/A */
342N/A
342N/Aimport java.lang.reflect.*;
342N/A
342N/Apublic class toStringTest {
342N/A
342N/A static void testString(int test, String expected) {
342N/A if(!Modifier.toString(test).equals(expected))
342N/A throw new RuntimeException(test +
342N/A " yields incorrect toString result");
342N/A }
342N/A
342N/A public static void main(String [] argv) {
342N/A int allMods = Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
342N/A Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL |
342N/A Modifier.TRANSIENT | Modifier.VOLATILE | Modifier.SYNCHRONIZED |
342N/A Modifier.NATIVE | Modifier.STRICT | Modifier.INTERFACE;
342N/A
342N/A String allModsString = "public protected private abstract static " +
342N/A "final transient volatile synchronized native strictfp interface";
342N/A
342N/A /* zero should have an empty string */
342N/A testString(0, "");
342N/A
342N/A /* test to make sure all modifiers print out in the proper order */
342N/A testString(allMods, allModsString);
342N/A
342N/A /* verify no extraneous modifiers are printed */
342N/A testString(~0, allModsString);
342N/A }
342N/A}
342N/A