Bug 240551 - Compile error: BCException thrown: malformed org.aspectj.weaver.PointcutDeclaration attribute when compiling after change in inpath
Summary: Compile error: BCException thrown: malformed org.aspectj.weaver.PointcutDecla...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.1rc1   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-11 19:35 EDT by Andrew Eisenberg CLA
Modified: 2008-07-14 00:23 EDT (History)
1 user (show)

See Also:


Attachments
Example prokect (22.54 KB, application/octet-stream)
2008-07-11 19:36 EDT, Andrew Eisenberg CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Eisenberg CLA 2008-07-11 19:35:43 EDT
I am getting the following BCException when I add or remove something from the project's inpath.  I am using the latest version from cvs branch AJDT 1.5 (and the associated version of AspectJ).  

To reproduce:
1. import the attached project to Eclipse
2. select "AspectJ Build > Inpath"
3. Click "Add Library"
4. Select JUnit, "Next" "Finish"
5. Click "OK"

The build path is updated and the following exception occurs:

Compile error: BCException thrown: malformed org.aspectj.weaver.PointcutDeclaration attribute (length:42)org.aspectj.weaver.BCException: unknown kind: 40when batch building BuildConfig[/Users/andrew/Eclipse/Installations/Eclipse3.3.2/Eclipse.app/Contents/MacOS/Tracing Example] #Files=12
when batch building BuildConfig[/Users/andrew/Eclipse/Installations/Eclipse3.3.2/Eclipse.app/Contents/MacOS/Tracing Example] #Files=12

org.aspectj.weaver.BCException: malformed org.aspectj.weaver.PointcutDeclaration attribute (length:42)org.aspectj.weaver.BCException: unknown kind: 40
when batch building BuildConfig[/Users/andrew/Eclipse/Installations/Eclipse3.3.2/Eclipse.app/Contents/MacOS/Tracing Example] #Files=12
when batch building BuildConfig[/Users/andrew/Eclipse/Installations/Eclipse3.3.2/Eclipse.app/Contents/MacOS/Tracing Example] #Files=12
at org.aspectj.weaver.AjAttribute.read(AjAttribute.java:127)
at org.aspectj.weaver.bcel.BcelAttributes.readAjAttributes(BcelAttributes.java:106)
at org.aspectj.weaver.bcel.BcelObjectType.ensureAspectJAttributesUnpacked(BcelObjectType.java:333)
at org.aspectj.weaver.bcel.BcelObjectType.<init>(BcelObjectType.java:151)
at org.aspectj.weaver.bcel.BcelWorld.buildBcelDelegate(BcelWorld.java:299)
at org.aspectj.weaver.bcel.BcelWorld.addSourceObjectType(BcelWorld.java:361)
at org.aspectj.weaver.bcel.BcelWeaver.addAspectsFromJarFile(BcelWeaver.java:259)
at org.aspectj.weaver.bcel.BcelWeaver.addLibraryJarFile(BcelWeaver.java:234)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.initBcelWorld(AjBuildManager.java:808)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:248)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:184)
at org.aspectj.ajde.core.internal.AjdeCoreBuildManager.doBuild(AjdeCoreBuildManager.java:95)
at org.aspectj.ajde.core.AjCompiler.buildFresh(AjCompiler.java:127)
at org.eclipse.ajdt.core.builder.AJBuilder.build(AJBuilder.java:212)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:624)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:166)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:197)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:246)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:249)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:214)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:353)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:494)
at org.eclipse.core.internal.resources.Project.build(Project.java:75)
at org.eclipse.ajdt.internal.ui.preferences.PreferencePageBuilder$1.run(PreferencePageBuilder.aj:490)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
Comment 1 Andrew Eisenberg CLA 2008-07-11 19:36:44 EDT
Created attachment 107249 [details]
Example prokect

Import the attached project to reproduce the error.
Comment 2 Andrew Eisenberg CLA 2008-07-11 19:48:35 EDT
Playing around with this some more.  I did a clean and removed everything from Java build path and the in path.  No I can't reproduce the error.  It seems like before the project had gotten into a bad state that was preventing the build from completing.
Comment 3 Andrew Eisenberg CLA 2008-07-11 20:00:42 EDT
OK.  Here's the problem.  I had put tracing.jar (in the attached project) on the inpath.  tracing.jar contains the compiled versions of most of the classes in the project.  That leads to two sets of classes with the same byte code being on the inpath as well as on the build path.

It seems like this should be appropriately handled by the compiler, but I'm not sure what the correct behavior should be.  When I try putting the same classes on the Java build path in a Java project using the Java compiler I get error messages like "The type XXX is already defined." for each duplicate type.  When I try the same in an aspectj project, there are no errors. 

In other words:

1. add duplicate types on inpath and build path to aspectj compiler and aspectj bug
2. duplicate types on java build path in aspectj is OK
3. duplicate types on java build path in Java will not compile
Comment 4 Andrew Clement CLA 2008-07-12 21:04:54 EDT
That exception usually means an incompatible difference between the version of AspectJ used to build the aspect and the version of AspectJ used to process the aspect.

I've looked in tracing.jar and it has been built using a dev build of AspectJ1.5.0 (before 1.5.0 final - possibly AspectJ1.5.0M3) according to the attributes in the class file (unfortunately it was at a time when we did not include the build timestamp in the version).  Can I ask what you used to build it or where you got it from?  Is it from an old sample?

I rebuilt the jar with the same level of compiler as in AJDT1.5.3 dev builds, then I put the jar on the inpath and the project compiles OK.  so I need to discover exactly what version of AspectJ was used to build the tracing.jar you were using, there were a number of bug fixes in 1.5.0 final and since then that address issues with the serialized form, but any released version of AspectJ should be able to produce .class files that any later released version of AspectJ can read.


Comment 5 Andrew Eisenberg CLA 2008-07-13 17:39:01 EDT
I don't know which version of AspectJ was used to compile it, but it was probably an old one.  This project is one I grabbed from the cvs repository to do some testing.
Comment 6 Andrew Clement CLA 2008-07-13 20:09:04 EDT
where in the CVS repository?  AJDT or AspectJ?  It is possible those files only had a refresh during 1.5 development and that 1.5 level had a serialization bug in it.  I would say we rebuild with the latest and fix up wherever this project is - probably should never have built this with a non-final release of AJ.


I guess that would leave us with the problem of duplicate classes on the build path ?  In comment #3:

> OK.  Here's the problem.  I had put tracing.jar (in the attached project) on
> the inpath.  tracing.jar contains the compiled versions of most of the classes
> in the project.  That leads to two sets of classes with the same byte code
> being on the inpath as well as on the build path.

Where are the duplicates - do you mean the source folder that gets compiled to bytecode and the jar on the inpath which contains the same bytecode?  Or is there another copy of the same bytecode somewhere else on the build path?


Comment 7 Andrew Eisenberg CLA 2008-07-14 00:17:27 EDT
(In reply to comment #6)
> where in the CVS repository?  AJDT or AspectJ?  

The project is "Tracing Example" from AJDT UI test project.  

Actually, now that I am looking at this further, I get the BCException when the tracing.jar is the ONLY thing on the classpath.  Perhaps as you suggest, the best thing to do is to recreate and try again...

...and indeed.  I recreated the jar using AspectJ that is included with AJDT1.5.  And the exception no longer occurs.

It seems that the problem is that I was using a jar created by an older version of AspectJ and therefore it could not be rewoven with a more current version of AspectJ.
Comment 8 Andrew Eisenberg CLA 2008-07-14 00:23:36 EDT
I'll recreate the jar and send a patch.