Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 332330

Summary: exception processing object factory methods
Product: z_Archived Reporter: Karen Butzke <karenfbutzke>
Component: EclipselinkAssignee: Blaise Doughan <blaise.doughan>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.oxm-inbox
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
MOXy - Fix none

Description Karen Butzke CLA 2010-12-10 13:22:41 EST
Given this example MOXy hits the following exception processing the annotations. It is because of the return type of JAXBElement not having any type arguments.

     class Pea {
         @XmlElementRefs({
             @XmlElementRef(name="foo",type=JAXBElement.class)
             @XmlElementRef(name="bar",type=JAXBElement.class)
         })
         List<JAXBElement<String>> fooOrBar;
     }
 
     @XmlRegistry
     class ObjectFactory {
         @XmlElementDecl(scope=Pea.class,name="foo")
         JAXBElement createPeaFoo(String s);
 
         @XmlElementDecl(scope=Pea.class,name="bar")
         JAXBElement createPeaBar(String s);
 
         @XmlElementDecl(name="foo")
         JAXBElement createFoo(Integer i);
     }


Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processObjectFactory(AnnotationsProcessor.java:2878)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processClass(AnnotationsProcessor.java:941)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processAdditionalClasses(AnnotationsProcessor.java:919)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.postBuildTypeInfo(AnnotationsProcessor.java:543)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processClassesAndProperties(AnnotationsProcessor.java:215)
	at org.eclipse.persistence.jaxb.compiler.Generator.<init>(Generator.java:147)
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:265)
	... 7 more
Comment 1 Blaise Doughan CLA 2010-12-13 11:17:22 EST
Created attachment 185076 [details]
MOXy - Fix
Comment 2 Blaise Doughan CLA 2010-12-14 14:11:00 EST
Fix checked into trunk at rev:  8706

MINOR CHANGE:
Guard against there being no type parameter on the JAXBElement by returning Object.class.

Code reviewed by Matt MacIvor
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:10:46 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink