Bug 534755 - Intermittent issue that causes java.lang.ClassFormatError: Duplicate field name&signature in class file
Summary: Intermittent issue that causes java.lang.ClassFormatError: Duplicate field na...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Library (show other bugs)
Version: 1.9.0   Edit
Hardware: PC Windows 10
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-16 08:17 EDT by Michael Western CLA
Modified: 2021-05-18 09:46 EDT (History)
2 users (show)

See Also:


Attachments
Patch where the WeakHashMap in World.java has been replaced with HashMap (1.94 MB, application/java-archive)
2021-05-17 09:53 EDT, Gabor Szalkai CLA
no flags Details
Patch file where the WeakHashMap in World.java has been replaced with HashMap (88.86 KB, patch)
2021-05-18 09:46 EDT, Gabor Szalkai CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Western CLA 2018-05-16 08:17:23 EDT
We have an intermittent issue that results in an exception  of type java.lang.ClassFormatError: Duplicate field name&signature in class file.

We are using the aspectj-maven-plugin to weave our dependencies, but I've investigated the issue and found there is a bug in the core aspect J library.

Having debugged the issue I have found that when types are ejected from the expendableMap in org.aspectj.weaver.World then the duplicate field error tends to occur.

As a workaround for now I have patched org.aspectj.weaver.World to use a regular HashMap (which prevents the issue from occurring):

final Map<String, ResolvedType> expendableMap = Collections
                .synchronizedMap(new HashMap<String, ResolvedType>());

I can provide further information on request.
Comment 1 Andrew Clement CLA 2018-05-18 19:48:59 EDT
Hi Michael - I'd like to get to the root of the problem rather than tweak the expendableMap like that. Can you tell what is being duplicated in what type and how your aspects relate to that?  (If I can recreate it I can fix it pretty quick but if you can't share code with me I understand). We can switch over to my email if it is easier to share that way
Comment 2 Michael Western CLA 2018-05-23 04:21:34 EDT
Yes, definitely - the HashMap approach was just a workaround used by us to avoid this issue.

I'm going to put some examples and log traces together and send you them in email.

Thanks.
Comment 3 Andrew Clement CLA 2018-05-23 20:03:27 EDT
sounds great!
Comment 4 Gabor Szalkai CLA 2021-05-14 10:07:22 EDT
Hi!

I'd like to enquiry whether you got an email, @AndrewClement, and you could find out whether it's a valid issue, it it's already fixed.

Can it be related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=565336 and therefore already solved?

Thanks a lot!
Comment 5 Andrew Clement CLA 2021-05-14 18:52:30 EDT
@Gabor I don't think I got an email but it was a while ago. You may be right with that issue you linked to - have you tried a 1.9.7 AspectJ snapshot to see if it is addressed? There are some 1.9.7 snapshots here that include the latest JDT:

https://aspectj.dev/maven/org/aspectj/
Comment 6 Gabor Szalkai CLA 2021-05-17 05:17:29 EDT
Thanks for the quick response. Due to time constraints I have to publish the changes we made, but in the mean time I will try to reproduce the issue. The problem is that it was an intermittent problem, and the problematic file does not exist any more. Thus making sure the issue is gone will need some time, but I will update this ticket when I am done.
Comment 7 Gabor Szalkai CLA 2021-05-17 09:53:10 EDT
Created attachment 286397 [details]
Patch where the WeakHashMap in World.java has been replaced with HashMap

Hi Andrew,

I'm uploading the version with our changes. Although, I know you won't accept this as it's rather a workaround, but would it be enough to comply with the legal requirements, or could you please guide where I have to publish our version?

Much appreciated!
Comment 8 Gabor Szalkai CLA 2021-05-18 09:46:36 EDT
Created attachment 286411 [details]
Patch file where the WeakHashMap in World.java has been replaced with HashMap