Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352636 - Class with switch statement on enum causes error when creating JAXB Context
Summary: Class with switch statement on enum causes error when creating JAXB Context
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: 2011-07-20 14:08 EDT by Blaise Doughan CLA
Modified: 2022-06-09 10:10 EDT (History)
1 user (show)

See Also:


Attachments
MOXy - Test Cases (3.92 KB, patch)
2011-07-20 14:11 EDT, Blaise Doughan CLA
no flags Details | Diff
MOXy - Fix (668 bytes, patch)
2011-07-20 14:23 EDT, 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 Blaise Doughan CLA 2011-07-20 14:08:41 EDT
The following error is thrown:

javax.xml.bind.JAXBException
- with linked exception:
[java.lang.NullPointerException]
at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:827)
at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:138)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:142)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:129)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:93)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:83)
at org.eclipse.persistence.testing.jaxb.xmlenum.EnumSwitchTestCases.testCreateContext(EnumSwitchTestCases.java:28)
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.jaxb.javamodel.Helper.isBuiltInJavaType(Helper.java:261)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.shouldGenerateTypeInfo(AnnotationsProcessor.java:1546)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processClass(AnnotationsProcessor.java:1045)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processAdditionalClasses(AnnotationsProcessor.java:1010)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.postBuildTypeInfo(AnnotationsProcessor.java:592)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processClassesAndProperties(AnnotationsProcessor.java:233)
at org.eclipse.persistence.jaxb.compiler.Generator.<init>(Generator.java:147)
at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:824)

When creating a JAXBContext on a class that contains a switch statment on an enum such as:

public class EnumSwitchRoot {

    private Department department;

    private Department foo() {
        switch(department) {
        case SALES: {
            return Department.SALES;
        }
        case SUPPORT: {
            return Department.SUPPORT;
        }
        }
        return null;
    }

}
Comment 1 Blaise Doughan CLA 2011-07-20 14:11:37 EDT
Created attachment 200031 [details]
MOXy - Test Cases
Comment 2 Blaise Doughan CLA 2011-07-20 14:23:01 EDT
Created attachment 200032 [details]
MOXy - Fix
Comment 3 Blaise Doughan CLA 2011-07-20 15:01:18 EDT
Fix checked into 2.3.1 at rev:  9769
Fix checked into trunk at rev:  9770

Code reviewed by:  Rick Barkhouse

Fix Description:
If the class does not have a raw name, then assume it is not a domain class.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:02:23 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:10:08 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink