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

Bug 335783

Summary: NullPointerException when -XaddSerialVersionUID added
Product: [Tools] AspectJ Reporter: Abraham Nevado <info>
Component: LTWeavingAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: aclement, info
Version: unspecified   
Target Milestone: 1.6.11   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
TestCase
aclement: iplog+
Patch aclement: iplog+

Description Abraham Nevado CLA 2011-01-30 06:02:48 EST
Build Identifier: 1.6.10

Whenever -XaddSerialVersionUID is added in order to avoid serialization/marshalling issues NullPointerException is risen from AspectJ when accessing thisJoinPointStaticPart.

After reviewing the woven class, you perceive that SJPs are never initialized, and only serialVersionUID is filled at ajc$preClinit method.

The problem is located at:


private void addAjcInitializers() {
		if (tjpFields.size() == 0 && !serialVersionUIDRequiresInitialization) {
			return;
		}
		InstructionList[] il = null;

		if (tjpFields.size() > 0) {
			il = initializeAllTjps();
		}

		if (serialVersionUIDRequiresInitialization) {
			if (il == null) {
				il = new InstructionList[1];
			}
			il[0] = new InstructionList();
			il[0].append(InstructionFactory.PUSH(getConstantPool(), calculatedSerialVersionUID));
			il[0].append(getFactory().createFieldAccess(getClassName(), "serialVersionUID", BasicType.LONG, Constants.PUTSTATIC));
		}

As you can see the instructionList is overwritten when serialVersionUID is added and thus SJPs deleted and never injected.

Next message I will upload reprocase + patch.

Thanks and regards.

Reproducible: Always

Steps to Reproduce:
1.add -XaddSerialVersionUID to the aop.xml 
2.use thisJoinPointStaticPart at any place
3.NPE is got
Comment 1 Abraham Nevado CLA 2011-01-30 06:18:45 EST
Created attachment 187918 [details]
TestCase
Comment 2 Abraham Nevado CLA 2011-01-30 06:21:02 EST
Created attachment 187919 [details]
Patch
Comment 3 Andrew Clement CLA 2011-01-31 15:35:58 EST
Applied tests patch - moved tests from 1.6.10 area to 1.6.11

Applied code patch - unfortunately broke existing tests as it didn't allow for the case where there are no tjp fields (il==null going into the new logic, triggers an NPE).  Guarded for that case.

All committed.  Thanks for the contribution!