United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-1265543 The java.lang.Integer.getInteger does not work with null parameter
JDK-1265543 : The java.lang.Integer.getInteger does not work with null parameter

Details
Type:
Bug
Submit Date:
1996-08-27
Status:
Closed
Updated Date:
1997-12-11
Project Name:
JDK
Resolved Date:
1997-12-11
Component:
core-libs
OS:
solaris_2.5
Sub-Component:
java.lang
CPU:
sparc
Priority:
P3
Resolution:
Not an Issue
Affected Versions:
1.0.2
Fixed Versions:

Related Reports

Sub Tasks

Description

Name: saf@russia			Date: 08/27/96


  
This bug was found by St.Petersburg Java SQE team (by Alexander Kuzmin).

The java.lang.Integer.getInteger(String), getInteger(String,int),
getInteger(String,Integer) methods does not work properly with 
the first parameter according to the Java language specification.

The Java Language specification 
( Version 1.0,August 1996)
says the following (please see item 20.7.21, 20.7.22, 20.7.23):

getInteger(String) for simple example :
"  public static Integer getInteger(String nm) 

The first argument is treated as the name of a system property to be 
obtained as if by the method System.getProperty (??20.18.9).
The string value of this property is then interpreted as an integer 
value and an Integer object representing this value is returned. 
If there is no property of the specified name, or if the property 
does not have the correct numeric format, then null is returned. 
In other words, this method returns an Integer object equal to the
value of:

getInteger(nm, null)

 "

 The case if nm is null not implemented.   
 Function getInteger(String) does not check the situation
 with null parameter. Other functions also.

------------------------Examples of getInteger------------------------

 It is need to catch NullPointerException to control this situation.



// test IntegerGt0014: Try to read  null
   Status IntegerGt0014() throws java.io.IOException {
      Integer b1;
       try {
       b1=Integer.getInteger(null);
       } catch( NullPointerException e){
         return Status.failed("IntegerGt0014: getInteger failed"); }
           if ( (b1==null)  ) {
         return Status.passed("IntegerGt0014: OKAY");
      }
      return Status.failed("IntegerGt0014: getInteger failed");


   } 
-----------------------------------------------------------------------
    

                                    

Comments
EVALUATION


[saraiya 96/09/30] The current behavior of getInteger() seems reasonable
-- i.e. trying to get the property null ought to throw a NullPointerException.
This may be a case where the JLS is not specific enough -- I will
check with Guy.Steele.  In the meanwhile, I'm lowering it to P3.

[saraiya 97/5/13] Josh is our JLS expert -- reassigning.

The current behavior of getInteger() is correct. The spec does not claim
that getInteger() will return null given a null parameter.

michael.mccloskey@eng 1997-12-11
                                     
1997-12-11



Hardware and Software, Engineered to Work Together