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

Janko Heilgeist updated OPENJPA-383:
------------------------------------

    Attachment: enh_overloading_unittest.patch

Unit-test that fails with release 1.0.0 and the current SVN version.

As the bug is related to some undeterministic behavior the unittest is not 
guaranteed to fail. The version with generics reliably failed on my computer. 
The alternative with a simple interface should fail to, if this bug is indeed 
related to OPENJPA-251 and OPENJPA-329, but it did not fail on my computer.

I did forget to mention in the bug-report, that the error only occurs, if the 
access-type is PROPERTY (whether due to putting the annotations on the getter 
or the access-type="PROPERTY" attribute in the orm.xml). This unit-test uses 
FIELD and PROPERTY access to test both cases.

> Enhancement may cause corruption of classes using method overloading
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-383
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-383
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.0.0, 1.0.1, 1.1.0
>         Environment: Java 1.5.0_12, Java 1.6.0_02
>            Reporter: Janko Heilgeist
>         Attachments: enh_overloading_unittest.patch
>
>
> As already reported on the developers mailing-list, the enhancement of 
> classes that use method overloading may corrupt these classes. An example:
> public interface GenericEntity<PK extends Serializable> {
>         PK getEntityId();
>         void setEntityId(PK entityId);
> }
> public interface LongObjIdEntity extends GenericEntity<Long> {
>         Long getEntityId();
>         void setEntityId(Long entityId);
> }
> @Entity
> public class SomeEntity implements LongObjIdEntity {
>         private Long entityId;
>         @Id
>         @GeneratedValue
>         public Long getEntityId() { return entityId; }
>         public void setEntityId(Long entityId) { this.entityId = entityId; }
> }
> After enhancement of the class SomeEntity, calls to 
> SomeEntity.class.getDeclaredFields() may fail with an VerifyError due to a 
> "Wrong return type in function" getEntityId. This is a serious error because 
> getDeclaredFields() is called for example during the deserialization of 
> objects from an ObjectInputStream (which prohibits e.g. usage of such an 
> enhanced entity as argument to an EJB-function) and even in the PCEnhancer 
> class itself, which will fail when analyizing a previously enhanced class.
> The cause of this error is in my opinion related to bugs OPENJPA-251 and 
> OPENJPA-329. Reflection on the class returns two versions of the 
> getEntityId()-function: "Serializable getEntityId()" and "Long 
> getEntityId()". The enhancer uses a version of the function 
> getDeclaredMethod() of the serp-library, that does not guarantee which of 
> these methods is returned, if only the name of the function and its 
> parameter-types are specified. If the wrong method is picked, the enhanced 
> class is no longer usable.

-- 
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