8153532: Add @throws NPE javadoc to UIManager.setLookAndFeel(String) method description

Reviewed-by: prr, serb, kaddepalli
This commit is contained in:
Pankaj Bansal 2018-04-16 15:22:56 +05:30
parent e91400d46b
commit 3459dc11fd
2 changed files with 57 additions and 4 deletions
src/java.desktop/share/classes/javax/swing
test/jdk/javax/swing/UIManager

@ -606,15 +606,16 @@ public class UIManager implements Serializable
*
* @param className a string specifying the name of the class that implements
* the look and feel
* @exception ClassNotFoundException if the <code>LookAndFeel</code>
* @throws ClassNotFoundException if the <code>LookAndFeel</code>
* class could not be found
* @exception InstantiationException if a new instance of the class
* @throws InstantiationException if a new instance of the class
* couldn't be created
* @exception IllegalAccessException if the class or initializer isn't accessible
* @exception UnsupportedLookAndFeelException if
* @throws IllegalAccessException if the class or initializer isn't accessible
* @throws UnsupportedLookAndFeelException if
* <code>lnf.isSupportedLookAndFeel()</code> is false
* @throws ClassCastException if {@code className} does not identify
* a class that extends {@code LookAndFeel}
* @throws NullPointerException if {@code className} is {@code null}
*/
@SuppressWarnings("deprecation")
public static void setLookAndFeel(String className)

@ -0,0 +1,52 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8153532
* @summary Verifies that SetLookAndFeel(String) throws NPE when className is
* null
* @run main UIManagerSetLookAndFeelNPETest
*/
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class UIManagerSetLookAndFeelNPETest {
public static void main(String[] args)
throws ClassNotFoundException, UnsupportedLookAndFeelException,
InstantiationException, IllegalAccessException
{
boolean NPEThrown = false;
try {
UIManager.setLookAndFeel((String)null);
} catch (NullPointerException e) {
NPEThrown = true;
}
if (!NPEThrown) {
throw new RuntimeException("A NullPointerException is expected " +
"from setLookAndFeel(String), if the className is null");
}
}
}