Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324408 - Annotations are silently skipped when field also has an annotation with RetentionPolicy.CLASS
Summary: Annotations are silently skipped when field also has an annotation with Reten...
Status: RESOLVED DUPLICATE of bug 304602
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P2 major with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: asm
Keywords:
: 330650 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-03 08:47 EDT by Hans Harz CLA
Modified: 2022-06-09 10:27 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans Harz CLA 2010-09-03 08:47:29 EDT
Build Identifier: 2.1.1.v20100817-r8050

Symptoms:
- When creating an entity manager for the first time for the persistence unit multiple Descriptor Exceptions are thrown:
-- DatabaseSessionImpl throws an IndexOutOfBoundsException in initializeDescriptors() (caused by ObjectBuilder.getPrimaryKeyClassifications())
-- ClassDescriptor.getTable() throws a Descriptor Exception
- In each case the exception description is:
  The table [<Name of the table the @ManyToMany relation maps to>] is not present in this descriptor

Reason:
- org.eclipse.persistence.internal.libraries.asm.ClassReader of the embedded ASM library silently fails to load the eclipselink annotations from the persistent field in method accept(ClassVisitor, Attribute[], boolean) when the field is annotated with an annotation that has RetentionPolicy.CLASS

Workaround:
- Do not annotate persistent fields in Entity classes with annotations invisible at runtime (that is: have RetentionPolicy.CLASS)

We notice that the version of ASM embedded in EclipseLink seems to be much older than the official version of ASM at http://asm.ow2.org/

Note:
- We could never reproduce the behavior when running the code from within Eclipse. Only when running it from an ant script.
- We set severity to major, because this bug is very hard to track down.


Reproducible: Always

Steps to Reproduce:
- Create a persistent class with a  @ManyToMany mapping. Define this mapping via annotations.
- Add an additional annotation with RetentionPolicy.CLASS to the field that holds the many-to-many mapping (for example the FindBugs @GuardedBy annotation).
Comment 1 Hans Harz CLA 2010-09-10 10:58:24 EDT
See also Bug 324862 https://bugs.eclipse.org/bugs/show_bug.cgi?id=324862. Which contains a patch that probably will also fix this problem.
Comment 2 Tom Ware CLA 2010-09-20 09:09:22 EDT
Setting target and priority.  See the following page for details of the
meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 3 Missing name Mising name CLA 2010-10-07 11:25:23 EDT
This can happen with any additional attributes on  a member, we encountered it with aspectj method line number attributes.  

MetadataAsmFactory.addAnnotations is assuming the runtime annotations are going to be the first Attribute, but they can appear anywhere in the list.  It needs to run through all the Attributes and add any RuntimeVisibleAnnotations that appear

This issue is a duplicate of 304602, just manifesting itself in a different situation.
Comment 4 Andrew Rustleund CLA 2010-10-07 11:37:22 EDT
Also see bug id 324862. This appears to be the same issue. I am posting our version of the fix there.
Comment 5 Guy Pelletier CLA 2010-11-23 14:03:07 EST
*** Bug 330650 has been marked as a duplicate of this bug. ***
Comment 6 Guy Pelletier CLA 2010-12-29 15:53:14 EST
Duplicate bug which has now been resolved.

*** This bug has been marked as a duplicate of bug 304602 ***
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:27:05 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink