[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bcel-user
Subject:    Bug
From:       Erik Corry <erik () arbat ! com>
Date:       2004-04-05 18:47:11
Message-ID: 20040405184711.GA13892 () arbat ! com
[Download RAW message or body]

Hi

I found a bug in BCEL 5.1

It's only triggered if someone uses LDC_W with an offset of < 256.
There's no reason to do that, but Sun do it anyway in 
java/math/BigInteger.class from 1.4.2 (in rt.jar).

In LDC_W.initFromFile(ByteSequence, boolean) the the opcode is
set to LDC_W, but the length isn't changed.  This means when
I call getMethod on the MethodGen object I get the wide opcode
but only two bytes are reserved.  Chaos ensues.

This fixes it for me, I'm not sure it's the right solution:

--- bcel-5.1/src/java/org/apache/bcel/generic/LDC_W.java        2003-04-25 09:06:16.000000000 +0200
+++ ../speciale/jdfa/src/org/apache/bcel/generic/LDC_W.java     2004-04-05 20:25:38.000000000 +0200
@@ -84,5 +84,7 @@
     setIndex(bytes.readUnsignedShort());
     // Override just in case it has been changed
     opcode = org.apache.bcel.Constants.LDC_W;
+    // Even if the index is < 256 the length of LDC_W is still 3
+    length = 3;
   }
 }

-- 
Erik Corry         I'd be a Libertarian, if they weren't all a
erik@arbat.com     bunch of tax-dodging professional whiners.   - B. Breathed.

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic