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

Bug 336099

Summary: Inheritance - @XmlValue and abstract superclass
Product: z_Archived Reporter: Zdenek Farana <zdenek.farana>
Component: EclipselinkAssignee: Blaise Doughan <blaise.doughan>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: eclipselink.oxm-inbox, karenfbutzke
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 344752    
Attachments:
Description Flags
Test Case
none
MOXy - Test Cases
none
MOXy - Test Cases
none
MOXy - Fix
none
MOXy - Test Cases
none
MOXy - Fix none

Description Zdenek Farana CLA 2011-02-02 11:44:34 EST
Build Identifier: 2.3.0-SNAPSHOT (20110202.060516-27)

The class is in a package with @XmlAccessorType(XmlAccessType.NONE)

If the class with an abstract superclass (which is not annotated at all) has a field annotated with @XmlValue, the following exception happens during marshalling:

org.eclipse.persistence.exceptions.JAXBException Exception Description: The property or field s can not be annotated with XmlValue since it is a subclass of another XML-bound class.

I think it's a rare situation, but I'm working on the legacy code and there is such special case.

Reproducible: Always

Steps to Reproduce:
See the attached test case.
Comment 1 Zdenek Farana CLA 2011-02-02 11:45:11 EST
Created attachment 188165 [details]
Test Case
Comment 2 Karen Butzke CLA 2011-02-03 14:04:01 EST
Blaise,
Is this a case where MOXy supports this, but the JAXB spec does not? In section 8.9.10.2:
The containing class must not extend another class (other than java.lang.Object).


Though in section 8.7.1.2 I see:

if the class, subClass, derives from another XML-bound class, baseClass
directly or indirectly (other than java.lang.Object), then the subClass
must not contain a mapped property or field annotated with @XmlValue
annotation.


These 2 seems to be in conflict or maybe you can explain to me what is meant here. One says it must not extend another class the other says it can't extend another *XML-bound* class.
Comment 3 Blaise Doughan CLA 2011-02-04 11:35:37 EST
Karen,

The test case should not work as is.  But there is still a bug because if the Ancestor class is marked @XmlTransient then it is no longer an XML-bound class:


package moxy.test;

import javax.xml.bind.annotation.XmlTransient;

@XmlTransient
public abstract class Ancestor {
    public static String CORRECT_MARSHALLED_FOO = "<Foo><s>test</s></Foo>";
    public static String CORRECT_MARSHALLED_FOO_XMLVALUE = "<Foo>test</Foo>";

    private String foo2;

    public String getFoo2() {
        return foo2;
    }
}
Comment 4 Zdenek Farana CLA 2011-02-07 07:26:06 EST
(In reply to comment #3)
> Karen,
> 
> The test case should not work as is.  But there is still a bug because if the
> Ancestor class is marked @XmlTransient then it is no longer an XML-bound class:
> 

I thought when the package was marked with @XmlAccessorType(XmlAccessType.NONE), then none of the classes without explicit JAXB annotations were XML bound.
Comment 5 Blaise Doughan CLA 2011-05-03 13:40:00 EDT
Created attachment 194616 [details]
MOXy - Test Cases
Comment 6 Blaise Doughan CLA 2011-05-03 15:00:52 EDT
Created attachment 194628 [details]
MOXy - Test Cases
Comment 7 Blaise Doughan CLA 2011-05-03 15:01:19 EDT
Created attachment 194629 [details]
MOXy - Fix
Comment 8 Blaise Doughan CLA 2011-05-04 12:30:29 EDT
Created attachment 194737 [details]
MOXy - Test Cases
Comment 9 Blaise Doughan CLA 2011-05-04 12:32:03 EDT
Created attachment 194738 [details]
MOXy - Fix

Instead of checking to see if there is a parent class, check to see if a parent class has a field/property mapped to something other than an attribute.
Comment 10 Blaise Doughan CLA 2011-05-04 15:55:24 EDT
Fix checked into trunk at rev: 9308

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