Bug 45441 - IncompatibleClassChangeError at runtime when compiling with -1.4 option
Summary: IncompatibleClassChangeError at runtime when compiling with -1.4 option
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Windows XP
: P2 critical (vote)
Target Milestone: 1.2   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-23 09:54 EDT by Adrian Colyer CLA
Modified: 2004-02-01 18:20 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Colyer CLA 2003-10-23 09:54:07 EDT
So we finally figured what changed between 3.0M3 and 3.0M4: the Java Compiler 
options changed to having 1.4 compliance as the default for generated class 
files. (We found this out through the circuitous route of inspecting the class 
file attributes of an M4 compile vs a working command-line one.

The optimisation to swizzle JoinPoint for JoinPointStaticPart fails when ajc is 
passed the -1.4 option, resulting in an IncompatibleClassChangeError at runtime.

Test case about to be checked into ajcTestsFailing.... and then we'll see if we 
can fix it!
Comment 1 Jim Hugunin CLA 2003-10-23 12:54:45 EDT
Fixed in tree.  Once the cause was isolated, the fix was relatively easy

The required change was to use the setActualReceiverType method on the 
MessageSend node to inform it of the new receiver type so the correct code 
would be generated in 1.4 mode.  3 other caches of this same type are also 
updated to try to insulate us from future trouble.
Comment 2 avid_grasshopper CLA 2004-02-01 01:06:24 EST
What do you mean by fixed? Does it mean that it will be OK if we tell the
compiler to generate 1.4 class files? I just tried running some very simple code: 

public class Test {
   public Test() {
	  this(5);
	  System.out.println("Hello()");   
   }
   
   public Test(int x) {
	  System.out.println("Hello(" + x + ")");
   }
   
   public static void main(String[] args ) {
	  new Test();
   }
}


public aspect HelloAspect {
	before() : call( Test.new(..) ) {
		//System.out.println(thisJoinPoint.getSignature());
		
	   System.out.println( "call-before");
	}
   
	before() : execution(Test.new(..)) {
	   System.out.println( "execution-before");
	}
}


And it gives me this: 

java.lang.IncompatibleClassChangeError
	at HelloAspect.ajc$before$HelloAspect$1a3(HelloAspect.java:16)
	at Test.main(Test.java)
Exception in thread "main" 

What gives? I'm using eclipse 3.0M6, AJDT 1.1.4 and AJDT/UI 0.6.4. J2SE version
is 1.4.2_02. I tried both: generating 1.4 and 1.3 (rebuild after each change),
both didn't work. Only by setting the source compability to 1.3, and checking
the default class compat below that, did it work.
Comment 3 Jim Hugunin CLA 2004-02-01 18:20:26 EST
Fixed in tree means that this bug has been fixed in the latest version of the 
compiler in cvs.  This fix will be incorporated in the 1.2 build.  If you want 
access to this fix you need to either wait for the official 1.2 builds or 
build the compiler yourself from the sources.

As you've noticed, the workaround until then is to use the 1.3 source and 
class compatibility rules that were the default before 3.0M3.