Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332330 - exception processing object factory methods
Summary: exception processing object factory methods
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Blaise Doughan CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-10 13:22 EST by Karen Butzke CLA
Modified: 2022-06-09 10:10 EDT (History)
1 user (show)

See Also:


Attachments
MOXy - Fix (1.14 KB, patch)
2010-12-13 11:17 EST, Blaise Doughan CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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