db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Bug in JPOX parser NPE in constructor (CollectionMetaData.java:96)
Date Tue, 07 Mar 2006 23:54:44 GMT

I think I've found the problem with the NPE in parsing the company  
package.jdo in which we define a <package...> <interface...>  
<property...> <collection...>.

While constructing the collection metadata, we try to get the package  
name. The top of the stack contains the property in which the  
collection element is defined. Property extends field so we look for  
the class metadata to get the package metadata. But the field  
metadata doesn't know that it can be in an interface; it only knows  
about being in a class or embedded metadata. An interface does know  
its package, so it's possible for the interface metadata to return  
the package, but an interface is an AbstractClass whereas the  
getClassMetadata method returns ClassMetadata. Possibilities: you  
could redefine getClassMetadata to return AbstractClassMetadata or  
have InterfaceMetadata inherit ClassMetadata.

Also, looking at the JPOX implementation of startElement and it  
appears that it's not supported for an element "property" to be part  
of element "class". Shouldn't there be an else if (parent instanceof  
ClassMetaData) clause here?

         // New property for this interface
         else if (qName.equals("property"))
             MetaData parent = getStack();
             if (parent instanceof InterfaceMetaData)
                 InterfaceMetaData intmd = (InterfaceMetaData)parent;
                 PropertyMetaData propmd = newPropertyObject(intmd,  
             else if (parent instanceof EmbeddedMetaData)
                 EmbeddedMetaData emd = (EmbeddedMetaData)parent;
                 PropertyMetaData propmd = newPropertyObject(emd,  

Hope this helps.


Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!

View raw message