Bug 73504 - Weaving into a JAR file causes an ClassFormat exception
Summary: Weaving into a JAR file causes an ClassFormat exception
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 76355 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-09-08 19:03 EDT by Wojtek Baj CLA
Modified: 2005-09-24 05:57 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wojtek Baj CLA 2004-09-08 19:03:32 EDT
When I run ajc to weave aspects into a JAR file (ajc -injars WrapperClassJar.jar
-sourceroots . -outjar TracedWrapper.jar) I get the following exception:

C:\work\ajc_failure>ajc -injars WrapperClassJar.jar -sourceroots . -outjar
TracedWrapper.jar
trouble in:
ABORT

Exception thrown from AspectJ 1.2

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.
Invalid method signature: <missing>
Invalid method signature: <missing>
org.apache.bcel.classfile.ClassFormatException: Invalid method signature: <missing>
        at org.apache.bcel.classfile.Utility.typeOfSignature(Utility.java:1024)
        at org.apache.bcel.generic.Type.getType(Type.java:158)
        at org.aspectj.weaver.bcel.BcelWorld.makeBcelType(BcelWorld.java:155)
        at org.aspectj.weaver.bcel.BcelVar.createCopyFrom(BcelVar.java:68)
        at
org.aspectj.weaver.bcel.BcelShadow.initializeArgVars(BcelShadow.java:1095)
        at org.aspectj.weaver.bcel.BcelShadow.getArgVar(BcelShadow.java:836)
        at
org.aspectj.weaver.bcel.BcelShadow.createThisJoinPoint(BcelShadow.java:963)
        at
org.aspectj.weaver.bcel.BcelShadow.initializeThisJoinPoint(BcelShadow.java:890)
        at org.aspectj.weaver.bcel.BcelShadow.prepareForMungers(BcelShadow.java:260)
        at org.aspectj.weaver.Shadow.implement(Shadow.java:324)
        at
org.aspectj.weaver.bcel.BcelClassWeaver.implement(BcelClassWeaver.java:1145)
        at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:357)
        at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:80)
        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:724)
        at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:689)
        at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:615)
        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:563)
        at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompilerAdapter.java:239)
        at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling(AjCompilerAdapter.java:114)
        at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:376)
        at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:601)
        at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:160)
        at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:94)
        at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:102)
        at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:53)
        at org.aspectj.tools.ajc.Main.run(Main.java:280)
        at org.aspectj.tools.ajc.Main.runMain(Main.java:217)
        at org.aspectj.tools.ajc.Main.main(Main.java:79)


1 fail|abort
Comment 1 Wojtek Baj CLA 2004-09-08 20:10:43 EDT
I have added some missing classes to my batch file and the problem went away:

@echo off 
set libext=../Libraries2/external/java
set libint=../Libraries2/internal/java
set CP=-classpath
%CLASSPATH%;%libext%/xalan.jar;%libext%/junit.jar;%libint%/StatusCodes.jar
set opts=-verbose
SEt INJARS=-injars ../Libraries2/internal/java/WrapperClassJar.jar
set outjars=-outjar TracedWrapper.jar
set ajs=WrapperClasses/openharbor/tracker/CollectionBase.aj
WrapperClasses/openharbor/tracker/SetterBase.aj
set ajs=%ajs% WrapperClasses/openharbor/boa/BoaBaseCollectionTracker.aj
set ajs=%ajs% WrapperClasses/openharbor/boa/BoaBaseSetterTracker.aj
call ajc %CP% %opts% %INJARS% %AJS% %OUTJARS%
Comment 2 Robin Green CLA 2005-07-21 13:58:56 EDT
This bug (ClassFormatException when dependendencies are missing from the
classpath) is still present in the latest snapshot.
Comment 3 Adrian Colyer CLA 2005-08-26 11:11:01 EDT
needs investigation for M4...
Comment 4 Adrian Colyer CLA 2005-09-24 05:41:52 EDT
I was able to reproduce this independently in a related scenario. The error was due to us reading in string 
signatures for methods from the bytecode, trying to resolve the types (and failing), but then trying to write 
out bytecode with the <missing> type signatures before the true error had been reported. This problem 
has now been fixed, and the compiler is also much more tolerant of missing types in these situations (see 
bug 77076).

Fix commited in tree and will be available in next published build from AspectJ download page.
Comment 5 Adrian Colyer CLA 2005-09-24 05:57:44 EDT
*** Bug 76355 has been marked as a duplicate of this bug. ***