Bug 245274 - Weaving regression
Summary: Weaving regression
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.1   Edit
Hardware: PC Windows Vista
: P2 critical (vote)
Target Milestone: 1.6.2   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-26 12:27 EDT by Andrew Clement CLA
Modified: 2008-08-27 22:07 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2008-08-26 12:27:52 EDT
Reported on mailing list.

I'm using the aj5 script to perform dynamic weaving on Xalan for Java.
Things were working fine when we were using AspectJ 1.5. Recently I
upgraded to version 1.6.1 and recompiled my aspects using the newer
compiler. The runtime weaving / aspects still work most of the time,
but I have encountered an important case where AspectJ core-dumps with
ajcore files when trying to dynamically weave a certain class:

Aug 25, 2008 6:20:52 PM org.aspectj.weaver.tools.Jdk14Trace error
SEVERE: org/apache/xalan/xslt/Process
java.lang.IllegalStateException: Argh!
   at org.aspectj.apache.bcel.generic.InstructionBranch.updatePosition(InstructionBranch.java:178)
   at org.aspectj.apache.bcel.generic.BranchHandle.updatePosition(BranchHandle.java:92)
   at org.aspectj.apache.bcel.generic.InstructionList.setPositions(InstructionList.java:905)
   at org.aspectj.apache.bcel.generic.InstructionList.setPositions(InstructionList.java:826)
   at org.aspectj.apache.bcel.generic.InstructionList.getByteCode(InstructionList.java:931)
   at org.aspectj.apache.bcel.generic.MethodGen.getMethod(MethodGen.java:699)
   ...

Process is a class that has a main method. (I'm able to weave other
classes not from Xalan that have main methods just fine.) I have tried
compiling Xalan with Java 1.4 or 1.5 but it doesn't affect the result.
I haven't tried compiling with 1.6.

I still have the JAR of my aspects that were compiled with AspectJ
1.5. Using the JAR of aspects compiled with AspectJ 1.5 with the
AspectJ 1.6 runtime weaver produces the same error. Using the AspectJ
1.5 runtime weaver with the aspects compiled with AspectJ 1.5 still
works fine. (and using the AspectJ 1.5 runtime with the aspects
compiled with AspectJ 1.6 isn't possible...)

Here are links to the ajcore files (two ajcore files generated per
attempt at weaving the class):

http://www.cs.purdue.edu/homes/kjhoffma/ajcore.20080825.182052.910.txt
http://www.cs.purdue.edu/homes/kjhoffma/ajcore.20080825.182053.153.txt

The Java class file that it is having trouble weaving is also available:

http://www.cs.purdue.edu/homes/kjhoffma/Process.class

I can provide information to download the full package with JARs and
scripts to reproduce off-list. Let me know what else I can gather to
help get this issue fixed.

Thanks,
Kevin
Comment 1 Andrew Clement CLA 2008-08-26 12:42:02 EDT
The Argh! comes out because in packing a method to write it to disk we encounter a branch instruction that attempts to jump too far, we can't pack the jump destination into the instruction so we break.  Now it might be a side effect of bug 243192 so I have asked Kevin to try with the latest dev build.  if that fails, I wonder if promotion of the instruction to a wide jump is failing for some reason?
Comment 2 Andrew Clement CLA 2008-08-27 22:07:35 EDT
Ok the problem here is the failure to promote some jump instructions to wide when the jump destination can no longer be held in a short.  In the case of the failure here the jump destination is 42000 bytes away and the instruction is 167 (GOTO).  We need to promote it to GOTO_W which can handle an int sized jump.  I've attempted a fix for this and committed it.