Bug 335783 - NullPointerException when -XaddSerialVersionUID added
Summary: NullPointerException when -XaddSerialVersionUID added
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: LTWeaving (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P2 major (vote)
Target Milestone: 1.6.11   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-30 06:02 EST by Abraham Nevado CLA
Modified: 2012-04-03 14:21 EDT (History)
2 users (show)

See Also:


Attachments
TestCase (4.53 KB, text/plain)
2011-01-30 06:18 EST, Abraham Nevado CLA
aclement: iplog+
Details
Patch (1.53 KB, patch)
2011-01-30 06:21 EST, Abraham Nevado CLA
aclement: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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!