[ 
https://issues.apache.org/jira/browse/OPENJPA-1912?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mark Struberg updated OPENJPA-1912:
-----------------------------------

    Attachment: OPENJPA-1912-test.patch

This unit test demontstrates the problem. I get the following output:

java.lang.IllegalAccessError: tried to access field 
org.apache.openjpa.enhance.EnhancedSuperClass.id from class 
org.apache.openjpa.enhance.EnhancedSubClass
        at 
org.apache.openjpa.enhance.EnhancedSubClass.writeExternal(EnhancedSubClass.java)
        at 
java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1421)
        at 
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1390)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
        at 
org.apache.openjpa.enhance.TestClassHierarchyEnhancement.serializeObject(TestClassHierarchyEnhancement.java:58)
        at 
org.apache.openjpa.enhance.TestClassHierarchyEnhancement.testSerialize(TestClassHierarchyEnhancement.java:50)
        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 junit.framework.TestCase.runTest(TestCase.java:154)
        at 
org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runTest(AbstractPersistenceTestCase.java:573)


> enhancer generates invalid code if fetch-groups is activated
> ------------------------------------------------------------
>
>                 Key: OPENJPA-1912
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1912
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: Enhance
>    Affects Versions: 2.0.0, 2.0.1, 2.1.0
>            Reporter: Mark Struberg
>            Priority: Critical
>         Attachments: OPENJPA-1912-test.patch
>
>
> If openjpa.DetachState =fetch-groups is used, the enhancer will add a 
> 'implements Externalizable' + writeExternal + readExternal.
> The problem is, that writeExternal and readExternal will also try to 
> externalize the private members of any given superclass. Thus we get a 
> runtime Exception that we are not allowed to access those fields.
> Example:
> @Entity
> public abstract class AbstractGroup {
>    ...
>     @Temporal(TemporalType.TIMESTAMP)
>     @TrackChanges
>     private Date applicationBegin;
>  ...
> }
> and 
> @Entity
> public class Group extends AbstractGroup {
> ...
> }
> will result in the following code (decompiled with jad):
>     public void writeExternal(ObjectOutput objectoutput)
>         throws IOException
>     {
>         pcWriteUnmanaged(objectoutput);
>         if(pcStateManager != null)
>         {
>             if(pcStateManager.writeDetached(objectoutput))
>                 return;
>         } else
>         {
>             objectoutput.writeObject(pcGetDetachedState());
>             objectoutput.writeObject(null);
>         }
>         objectoutput.writeObject(applicationBegin);
>         objectoutput.writeObject(applicationEnd);
>         objectoutput.writeObject(applicationLocked);
>         objectoutput.writeObject(approvalRequired);
>  ...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to