Community
Participate
Working Groups
I'm using ajdt 1.1.4 with eclipse 2.1.2 on Win/XP + j2sdk1.4.2 + Turkish Locale. When I try to build project files I'm, constantly, getting "ClassGen exception: Illegal Opcode Detected" error. I tried to use 1.1.3 version but noavail. This error is also reprodicable with command line compiler. You can use the "Hello world" example from Laddad's books to reproduce the error. PS. When I switch the locale of my machine to English everything is ok. PPS. Usually I encounter problems with locale if developer makes character case conversion (esp i, I) without specifying Locale.US but assuming that is the case. Because in turkish locale "I".toLowerCase() != "i" and also "i".toUpperCase() != "I" below the error produced by command line compiler: Illegal opcode detected. Illegal opcode detected. org.apache.bcel.generic.ClassGenException: Illegal opcode detected. at org.apache.bcel.generic.Instruction.readInstruction (Instruction.java:189) at org.apache.bcel.generic.InstructionList.<init> (InstructionList.java:193) at org.apache.bcel.generic.MethodGen.<init>(MethodGen.java:165) at org.aspectj.weaver.bcel.LazyMethodGen.<init>(LazyMethodGen.java:141) at org.aspectj.weaver.bcel.LazyClassGen.<init>(LazyClassGen.java:110) at org.aspectj.weaver.bcel.BcelObjectType.getLazyClassGen (BcelObjectType.java:248) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:359) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:335) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:261) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.weaveAndGenerateClassFile s(AjBuildManager.java:256) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild (AjBuildManager.java:164) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (AjBuildManager.java:78) at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:106) at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60) at org.aspectj.tools.ajc.Main.run(Main.java:217) at org.aspectj.tools.ajc.Main.runMain(Main.java:155) at org.aspectj.tools.ajc.Main.main(Main.java:72) 1 fail|abort, 1 warning
Moved to AspectJ project.
Okay, this sure looks like a BCEL error. Looking at org.apache.bcel.generic.Instruction.className(short) they definitely use toUpperCase(), which was very helpfully suggested as a problem call in the Turkish locale. (as a side note, BCEL is using _reflection_ to instantiate its bytecode operations! What the hell happened to programmers' brains? Because reflection is available they should use it instead of a dispatch table with EXTREMELY well-specified entries? It took _effort_ to be that lazy! I wouldn't even use eval to accomplish this task in Scheme! Okay, rant over) We may have to check in our own patched version of BCEL to handle this problem. I'm investigating whether the BCEL folks know about this problem. Leaving as P2; we should definitely fix this before 1.2. Thanks very much to Umit Vardar for the bug report. -erik
Submitted the bug to BCEL folks yesterday, and a test case (for BCEL) today: import java.io.IOException; import java.util.Locale; import org.apache.bcel.generic.Instruction; import org.apache.bcel.util.ByteSequence; public class LocaleTest { public static void main(String[] args) throws IOException { printBipush(); Locale.setDefault(new Locale("tr")); printBipush(); // this throws an exception! } static void printBipush() throws IOException { Instruction ix = Instruction.readInstruction( new ByteSequence(new byte[] { (byte)16, // bipush (byte) 3 // data for bipush })); System.err.println(ix); } } I'm going to give the BCEL folks a week to address the issue before exploring whether we need to include a patched BCEL version. I couldn't find a way to pass a locale specification to _our_ command-line compiler, so I don't have a test case for this bug checked into our tree. As a side note, the workaround for this problem is to avoid writing programs that use the bytecodes: bipush, sipush, iload*, istore*, iinc, if*, put/getstatic, put/getfield, invoke*, instanceof, multianewarray so as long as you're not using integers, bytes, shorts, or conditionals, fields, or methods, this problem won't affect you at all. *grin*.
Okay, this is now fixed, and we're now using a patched version of BCEL for our project. BCEL folks were no help, but I contributed the fix I used as a patch to their bug system. Test case also checked in.
updating target flag to indicate inclusion in 1.2 release.