United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4948761 REGRESSION 1.5: Introspector.getBeanInfo throws NPE if a primitive type is pass
JDK-4948761 : REGRESSION 1.5: Introspector.getBeanInfo throws NPE if a primitive type is pass

Details
Type:
Bug
Submit Date:
2003-11-04
Status:
Resolved
Updated Date:
2004-11-03
Project Name:
JDK
Resolved Date:
2003-11-27
Component:
client-libs
OS:
solaris_9,linux,windows_xp,windows_2000
Sub-Component:
java.beans
CPU:
x86,sparc
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.2_06,5.0
Fixed Versions:
1.4.2_06 (06)

Related Reports
Backport:
Duplicate:
Duplicate:
Duplicate:
Relates:

Sub Tasks

Description
###@###.### 2003-11-04

J2SE Version (please include all output from java -version flag):
  java version "1.5.0-beta"
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b26)
  Java HotSpot(TM) Client VM (build 1.5.0-beta-b26, mixed mode)

Does this problem occur on J2SE 1.4 or 1.4.1 or 1.4.2?  Yes / No (pick one)
 No, works fine with 1.4.2 and 1.5 build 14.

Operating System Configuration Information (be specific):
 Windows XP SP1

Hardware Configuration Information (be specific):
 512 Mb RAM, 1.3 Ghz processor

Bug Description:
  java.beans.Introspector.getBeanInfo(class) throws a NullPointerException if a    primitive type is passed in.

Steps to Reproduce (be specific):

import java.beans.*;

public class BeanIntroTest
{
        public static void main(String[] args) throws Exception
        {
                BeanInfo beanInfo = Introspector.getBeanInfo(short.class);      
                System.out.println("Found "+beanInfo.getPropertyDescriptors().length+" properties");
        }
}


The above will output "Found 0 properties" in 1.4.2, but will throw a NullPointerException in 1.5.
###@###.### 10/8/04 14:04 GMT

                                    

Comments
EVALUATION

Exception in thread "main" java.lang.NullPointerException
        at java.beans.Introspector.getTargetPropertyInfo(Introspector.java:591)
        at java.beans.Introspector.getBeanInfo(Introspector.java:380)
        at java.beans.Introspector.getBeanInfo(Introspector.java:152)
        at PrimitiveTest.main(PrimitiveTest.java:10)

In 1.4.2, the data structure which holds the properties was created when the Introspector instance was created. In 1.5.0, this structure is lazily created. Since primitive types does not have any properties, this data structure is never created but it is referenced in getTargetPropertyInfo().

Not a difficult fix. Commit to tiger

###@###.### 2003-11-11
                                     
2003-11-11
SUGGESTED FIX

check properties == null in getTargetPropertyInfo before allocating property descriptors array.
###@###.### 2003-11-11
                                     
2003-11-11
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
1.4.2_06
tiger-beta

FIXED IN:
1.4.2_06
tiger-beta

INTEGRATED IN:
1.4.2_06
tiger-b30
tiger-beta


                                     
2004-09-29



Hardware and Software, Engineered to Work Together