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

Bug 368746

Summary: Inner classes being processed by default
Product: z_Archived Reporter: Blaise Doughan <blaise.doughan>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
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 - Test Cases
none
MOXy - Fix
none
MOXy - Test Cases none

Description Blaise Doughan CLA 2012-01-16 12:33:20 EST
Given the following class

import javax.xml.bind.annotation.*;

@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class Root {

    public Inner inner;

    public class Inner {
        
    }

}

MOXy is currently throwing the following exception.  The exception should not be thrown as the Inner class should never have been processed:

Exception in thread "main" javax.xml.bind.JAXBException: 
Exception Description: The class forum8853855.part2.Root$Inner requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.
 - with linked exception:
[Exception [EclipseLink-50001] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The class forum8853855.part2.Root$Inner requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.]
	at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:832)
	at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:143)
	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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:331)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
	at forum8853855.part2.Demo.main(Demo.java:8)
Caused by: Exception [EclipseLink-50001] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The class forum8853855.part2.Root$Inner requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.
	at org.eclipse.persistence.exceptions.JAXBException.factoryMethodOrConstructorRequired(JAXBException.java:127)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.finalizeProperties(AnnotationsProcessor.java:739)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processClassesAndProperties(AnnotationsProcessor.java:237)
	at org.eclipse.persistence.jaxb.compiler.Generator.<init>(Generator.java:147)
	at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:829)
	... 14 more
Comment 1 Blaise Doughan CLA 2012-01-16 14:21:14 EST
Created attachment 209583 [details]
MOXy - Test Cases
Comment 2 Blaise Doughan CLA 2012-01-16 14:22:40 EST
Created attachment 209584 [details]
MOXy - Fix

Now in annotations processor only static inner classes are brought in by default.  Non-static inner classes will still be processed in a mapped field/property is of that type.
Comment 3 Blaise Doughan CLA 2012-01-16 14:24:42 EST
Created attachment 209585 [details]
MOXy - Test Cases
Comment 4 Blaise Doughan CLA 2012-01-16 15:14:35 EST
Fix checked into 2.3.3 at rev:  10692
Fix checked into trunk at rev:  10693

Code review by:  Denise Smith

Fix Details:
Now in annotations processor only static inner classes are brought in by default.  Non-static inner classes will still be processed in a mapped field/property is of that type.
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:34:47 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink