Bug 260506 - Bad weaver state exception
Summary: Bad weaver state exception
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.3   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 1.6.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-09 03:24 EST by mansu CLA
Modified: 2009-01-12 21:19 EST (History)
1 user (show)

See Also:


Attachments
core (7.62 KB, text/plain)
2009-01-09 03:24 EST, mansu CLA
no flags Details
The aspectj file I was weaving with. (2.29 KB, application/octet-stream)
2009-01-09 03:26 EST, mansu CLA
no flags Details
the class file for the aspect (7.75 KB, application/java-vm)
2009-01-09 14:40 EST, mansu CLA
no flags Details
the aspectj file iif that helps (2.28 KB, application/octet-stream)
2009-01-09 14:40 EST, mansu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description mansu CLA 2009-01-09 03:24:26 EST
Created attachment 122070 [details]
core

I was trying to weave files from a project with the version 1.6.1rc1. Got a bad weaver state exception. I downloaded the 1.6.3 and my code fails with the same exception. Please look at the attachment below.

I am running java 1.6 on linux.

% java -version 
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Server VM (build 10.0-b23, mixed mode)
Comment 1 mansu CLA 2009-01-09 03:26:01 EST
Created attachment 122071 [details]
The aspectj file I was weaving with.
Comment 2 Andrew Clement CLA 2009-01-09 12:29:48 EST
This is usually the sign of a mismatch between the compiler/weaver used to build the code and the weaver used to process the code sometime later.  However, AspectJ 1.6.3 should be able to cope with anything created by older compiler/weavers.

Did you build the code in AJDT at all, or always on the command line?

> I was trying to weave files from a project with the version 1.6.1rc1. Got a
> bad weaver state exception.

What level of AspectJ or AJDT was used to build the files in the originating project?

If you are only using the one aspect, can you please attach the .class file for it rather than the source, so I can inspect it internally.
Comment 3 mansu CLA 2009-01-09 14:38:45 EST
Hi Andy,

I am using the default levels. I am using the following commands to compile the programs the code from the command line. I use rake, and the tasks execute as below. I always build this code from the command line.

---- 
Compiling Java files 
javac    -cp /home/suman/installs/libs/java/jyaml-1.3.jar:/u/suman/installs/libs/java/log4j-1.2.15.jar:/u/suman/installs/aspectj1.6//lib/aspectjrt.jar:/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/bin -d '/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/bin' /home/suman/exercise/steve_rnr/ytrace/ytrace/analysis/src/java/edu/brown/cs/ytrace/utils/*.java
javac    -cp /home/suman/installs/libs/java/jyaml-1.3.jar:/u/suman/installs/libs/java/log4j-1.2.15.jar:/u/suman/installs/aspectj1.6//lib/aspectjrt.jar:/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/bin -d '/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/bin' /home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/src/java/edu/brown/cs/ytrace/tracing/*.java
Note: /home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/src/java/edu/brown/cs/ytrace/tracing/YTraceTraceLogger.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
cleaning old aspect files
Compile aspectj files...
ajc    -classpath /u/suman/installs/aspectj1.6//lib/aspectjrt.jar:/home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc:/home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/java::/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/bin:/home/suman/installs/libs/java/jyaml-1.3.jar:/u/suman/installs/libs/java/log4j-1.2.15.jar:/u/suman/installs/aspectj1.6//lib/aspectjrt.jar:/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/bin:. -d /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace//tracing//build/aspects /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace//tracing//build/aspects_src/*.*
done
Weaving binaries
ajc    -classpath /u/suman/installs/aspectj1.6//lib/aspectjrt.jar:/home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace//tracing//build/aspects:/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/bin:/home/suman/installs/libs/java/jyaml-1.3.jar:/u/suman/installs/libs/java/log4j-1.2.15.jar:/u/suman/installs/aspectj1.6//lib/aspectjrt.jar:/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/bin:.  -aspectpath /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace//tracing//build/aspects -inpath /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc:/home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/java: -d /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace//tracing//build//tracing; 
ABORT
	
Exception thrown from AspectJ 1.6.3

This might be logged as a bug already -- find current bugs at
  http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler

Bugs for exceptions thrown have titles File:line from the top stack, 
e.g., "SomeFile.java:243"

If you don't find the exception below in a bug, please add a new bug
at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ
To make the bug a priority, please include a test program
that can reproduce this exception.
bad WeaverState.Kind: -115.  File was :<Unknown>::0

when batch building BuildConfig[null] #Files=0
bad WeaverState.Kind: -115.  File was :<Unknown>::0
java.lang.RuntimeException: bad WeaverState.Kind: -115.  File was :<Unknown>::0
	at org.aspectj.weaver.WeaverStateInfo.read(WeaverStateInfo.java:133)
	at org.aspectj.weaver.AjAttribute.read(AjAttribute.java:100)
	at org.aspectj.weaver.bcel.Utility.readAjAttributes(Utility.java:101)
	at org.aspectj.weaver.bcel.BcelObjectType.ensureAspectJAttributesUnpacked(BcelObjectType.java:357)
	at org.aspectj.weaver.bcel.BcelObjectType.<init>(BcelObjectType.java:148)
	at org.aspectj.weaver.bcel.BcelWorld.buildBcelDelegate(BcelWorld.java:363)
	at org.aspectj.weaver.bcel.BcelWorld.addSourceObjectType(BcelWorld.java:430)
	at org.aspectj.weaver.bcel.BcelWeaver.addClassFile(BcelWeaver.java:444)
	at org.aspectj.weaver.bcel.BcelWeaver.addClassFile(BcelWeaver.java:460)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.initBcelWorld(AjBuildManager.java:851)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:242)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:179)
	at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
	at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
	at org.aspectj.tools.ajc.Main.run(Main.java:352)
	at org.aspectj.tools.ajc.Main.runMain(Main.java:233)
	at org.aspectj.tools.ajc.Main.main(Main.java:84)

Jan 9, 2009 2:32:51 PM org.aspectj.weaver.tools.Jdk14Trace info
INFO: Dumping to /home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/./ajcore.20090109.143251.122.txt

1 fail|abort
rake aborted!
Command failed with status (255): [ajc    -classpath /u/suman/installs/aspect...]
/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/tracing_rake.rb:60
(See full trace by running task with --trace)
-------------------------

Unless i missed something (or unless something changed between 1.6.0_07 and 1.6.0_07.b06), my default java is Java 1.6. I am using the same javac to compile the source code for the project, to compile the aspects and to weave them. 

Also, I will attach the class file also. Let me know if there is more I can do.

-S-
Comment 4 mansu CLA 2009-01-09 14:40:06 EST
Created attachment 122154 [details]
the class file for the aspect
Comment 5 mansu CLA 2009-01-09 14:40:35 EST
Created attachment 122155 [details]
the aspectj file iif that helps
Comment 6 mansu CLA 2009-01-09 15:08:41 EST
I can reproduce the error when I recompile with -1.6 compatibility level turned on too.
Comment 7 Andrew Clement CLA 2009-01-12 18:01:05 EST
Unfortunately the key piece of information is missing from the exception:

bad WeaverState.Kind: -115.  File was :<Unknown>::0
java.lang.RuntimeException: bad WeaverState.Kind: -115.  File was :<Unknown>::0

The unknown file name is what would tell us which file contained an invalid attribute.  Without that, we don't know if it is your aspect or the .class file for an aspect that you are consuming through another path.  If there is an aspect on one of those paths that was built by a previous dev build of AspectJ, it may well lead to this problem.

The .class file you attached shows:

org.aspectj.weaver.WeaverVersion: length = 0xC
 00 06 00 00 00 00 01 1E 64 FFFFFFD5 58 30

indicating the code was built by a version 6 weaver (which can be AspectJ1.6.1 or later).  But the timestamp data "00 00 01 1E 64 FFFFFFD5 58 30" shows it was built by AspectJ 1.6.3.  Given that there is nothing unusual in your pointcuts - parameter annotation matching, that kind of thing - I am suspecting it is another aspect you are picking up from somewhere.

I even did a binary weave feeding in your aspect and the weaver loaded it fine.

Are you knowingly getting an aspect from anywhere else on one of your paths?

Are you able to just do a full source compile rather than a binary weave - that may preserve the file name for inclusion in the weaverstate message.


Comment 8 mansu CLA 2009-01-12 21:14:10 EST
Hi andy,

Thanks for the clarification. Most likely I am picking up another aspect from somewhere else and I had a really complicated class path too. Now I deleted the whole aspects and recompiled it afresh. It works fine now.

Also, is there a way to know which aspect is being woven into the file currently being woven. I didn't see that information in the verbose mode also. I think printing that information will be really helpful for bugs like these. 

Also, in the verbose mode is there a way to see what pointcuts were woven into the code? For example, I want to see that line 5 in File XYZ.java was instrumented because of pointcut X in aspect XYZ_Aspect.aj. This is similar info provided by the eclipse plugin.

--------------------

ajc -verbose -1.6  -classpath /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace//tracing//build/aspects:/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/bin:/home/suman/installs/libs/java/jyaml-1.3.jar:/u/suman/installs/libs/java/log4j-1.2.15.jar:/u/suman/installs/aspectj1.6//lib/aspectjrt.jar:/home/suman/exercise/steve_rnr/ytrace/ytrace/tracing/bin:.  -aspectpath /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace//tracing//build/aspects -inpath /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc:/home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/java: -d /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace//tracing//build//tracing; 
directory classpath entry does not exist: /usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/sunrsasign.jar
	
zipfile classpath entry does not exist: /usr/lib/jvm/java-6-sun-1.6.0.07/jre/classes
	
Pipelining compilation
	
weaver operating in reweavable mode.  Need to verify any required types exist.
	
processing reweavable type TracingAspect: /TracingAspect.aj
	
woven aspect TracingAspect (from /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace/tracing/build/tracing/TracingAspect.class)
	
woven aspect TracingAspect (from /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace/tracing/build/aspects/TracingAspect.class)
	
woven class edu.brown.cs.cs032.crawler.CrawlerFactory (from /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace/tracing/build/tracing/edu/brown/cs/cs032/crawler/CrawlerFactory.class)
	
woven class edu.brown.cs.cs032.crawler.url.UrlRobots$Waiter (from /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace/tracing/build/tracing/edu/brown/cs/cs032/crawler/url/UrlRobots$Waiter.class)
	
woven class edu.brown.cs.cs032.crawler.CrawlerUrl (from /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/java/edu/brown/cs/cs032/crawler/CrawlerUrl.class)
	
woven class edu.brown.cs.cs032.crawler.crawl.CrawlTidyParser (from /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace/tracing/build/tracing/edu/brown/cs/cs032/crawler/crawl/CrawlTidyParser.class)
	
woven class edu.brown.cs.cs032.crawler.url.UrlManager (from /home/suman/exercise/steve_rnr/ytrace/ytrace_examples/crawler/javasrc/edu/brown/cs/cs032/crawler/ytrace/tracing/build/tracing/edu/brown/cs/cs032/crawler/url/UrlManager.class)


---------------------


Thanks a lot for your time. 

Thanks,
-S-
Comment 9 mansu CLA 2009-01-12 21:19:44 EST
Sorry, I got the option I asked for.

-showWeaveInfo.

Thanks,
-S-