-
Bug
-
Resolution: Done
-
Major
-
1.5.1
-
None
The following class and byteman rule work correctly (printing 1):
public class BmTest {
public static void main(String[] args)
public void run() { int i = 1; i = 2; // line 8 }
}
RULE example
CLASS BmTest
METHOD run()
AT LINE 8
IF TRUE
DO System.out.println($i)
ENDRULE
If the run method is made static, then it results in "Exception in thread "main" java.lang.VerifyError: (class: BmTest, method: run signature: ()V) Register 0 contains wrong type". I'm using java version "1.6.0_20", OpenJDK Runtime Environment (IcedTea6 1.9.7) (fedora-52.1.9.7.fc14-x86_64)
public class BmTest {
public static void main(String[] args) { new BmTest().run(); }
public static void run()
{ int i = 1; i = 2; // line 8 }}
The slightly more convoluted version which calls the static method from an instance method does work however:
public class BmTest {
public static void main(String[] args) { new BmTest().foo(); }
public static void run() { int i = 1; i = 2; // line 8 }
public void foo()
{ run(); }}
Calling the static method after an instance method doesn't though:
public class BmTest {
public static void main(String[] args)
public static void run()
{ int i = 1; i = 2; // line 8 }public BmTest foo()
{ return this; }}
I haven't done further testing, but it looks like it fails when the current call stack only contains static methods.