Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4625722
Votes 0
Synopsis java.util.logging.Level(null, int[, String]) doesn't throw NPE
Category java:classes_util_logging
Reported Against merlin-rc1 , tiger-beta
Release Fixed 1.5(tiger)
State 10-Fix Delivered, Verified, bug
Priority: 4-Low
Related Bugs
Submit Date 18-JAN-2002
Description


JDK1.4rc91 constuctor

protected java.util.logging.Level(String name,
                                  int value,
                                  String resourceBundleName)

does not throw NullPointerException if 'name' == null.

Level(String, int) has the same problem.

Package level spec for java.util.logging says:
----------
Null Pointers

In general, unless otherwise noted in the javadoc, methods and
contructors will throw NullPointerException if passed a null
argument.

The one broad exception to this rule is that the logging
convenience methods in the Logger class (the log, logp, log, severe,
warning, config, fine, finer, and finest methods) will accept null
values for all arguments except for the initial Level argument (if
any).

Consturctor spec says:
----------
protected Level(String name,
                int value,
                String resourceBundleName)

Create a named Level with a given integer value and a given localization resource name.

Parameters:
  name - the name of the Level, for example "SEVERE".
  value - an integer value for the level.
  resourceBundleName - name of a resource bundle to use in localizing
                       the given name (may be null). 

Demo test:
----------
import java.util.logging.*;

public class Test extends Level {

    public Test(String name, int value) {
        super(name, value);
    }

    public Test(String name, int value, String resourceBundleName) {
        super(name, value, resourceBundleName);
    }

    public static void main(String[] args) {
        try {
            new Test(null, 1, "");
            System.out.println("No NPE.");
        } catch (NullPointerException e) {
            System.out.println( "NPE." );
        }
    }

}

Demo output:
----------
[archer] ~/tmp
% /set/jdk-builds/JDK1.4.0rc-b91/solaris/bin/java Test
No NPE.
        
======================================================================
 xxxxx@xxxxx  2004-09-14
Work Around
N/A
Evaluation
^C

 xxxxx@xxxxx  2002-05-28

The analysis is correct
 xxxxx@xxxxx  2003-07-23

New specification through CCC is
/**
     * Create a named Level with a given integer value and a
     * given localization resource name.
     * <p>
     * @param name  the name of the Level, for example "SEVERE".
     * @param value an integer value for the level.
     * @param resourceBundleName name of a resource bundle to use in
     *    localizing the given name (may be null).
     * @throws NullPointerException if the name is null
     */
    protected Level(String name, int value, String resourceBundleName) {

 xxxxx@xxxxx  2003-09-09
Comments
  
  Include a link with my name & email   

Submitted On 06-MAR-2007
dldabhade
add link


Submitted On 16-APR-2007
vvpokharkar
Add Link



PLEASE NOTE: JDK6 is formerly known as Project Mustang