bcel-info Mailing List for Byte Code Engineering Library
Brought to you by:
dahm
You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
|
Feb
|
Mar
(2) |
Apr
(4) |
May
(2) |
Jun
(1) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2003 |
Jan
|
Feb
(1) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Abdullah O. Al-Z. <ao...@cs...> - 2011-05-12 13:54:41
|
Hi all, The broken link pointed to an abandoned web-page. The address of the corresponding alive web-page is (http://user.cs.tu-berlin.de/~tolk/vmlanguages.html) .. [just replace *grunge* with *user*]. Thanks Angela, On 5/12/2011 2:15 AM, Angela Hill wrote: > Hey , > > I found a broken link on http://bcel.sourceforge.net/documentation.html and > since I was researching computer science and needed the page, I found an > updated article online. > > The broken link to "Programming Languages for Java Virtual Machine" is > http://grunge.cs.tu-berlin.de/~tolk/vmlanguages.html and I found an article > on the front page of http://www.onlinecomputersciencedegree.com/ if you > wanted to fix it. Click the tab "Java Virtual Machine" to get to the > article. > > Figure I'd send you an email because others may need that link for the same > reasons! > > Thanks! > > > Angela Hill > ang...@gm... > > The purpose of computing is insight, not numbers. - R. Hamming > > > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > _______________________________________________ > BCEL-info mailing list > BCE...@li... > https://lists.sourceforge.net/lists/listinfo/bcel-info |
|
From: Angela H. <ang...@gm...> - 2011-05-12 00:18:18
|
Hey , I found a broken link on http://bcel.sourceforge.net/documentation.html and since I was researching computer science and needed the page, I found an updated article online. The broken link to "Programming Languages for Java Virtual Machine" is http://grunge.cs.tu-berlin.de/~tolk/vmlanguages.html and I found an article on the front page of http://www.onlinecomputersciencedegree.com/ if you wanted to fix it. Click the tab "Java Virtual Machine" to get to the article. Figure I'd send you an email because others may need that link for the same reasons! Thanks! Angela Hill ang...@gm... The purpose of computing is insight, not numbers. - R. Hamming |
|
From: John Li <jc...@ci...> - 2009-03-12 18:54:52
|
We have product we need to upgrade JDK we use to compile and run the product from JDK 1.4 to JDK 1.6. Our product uses BCEL. Does BCEL support JDK 1.6? How about JDK 1.5? What version of JDK is used to compile BCEL? Thanks. |
|
From: soumaya m. <sou...@ya...> - 2005-09-29 14:44:58
|
Hi, How can I pop some thing from the stack without knowing its type. please give me an example where you insert an instruction in an existing code that load the top value of the stack without knowing its type. thank you. --------------------------------- Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez le ici ! |
|
From: <fa...@vo...> - 2005-04-13 07:51:26
|
Hello,
I want to create a class from 2 different classes.
I begin just to create a classe from an existing classe using ClassGen and MethodGen
and copying its fields and its methods in the ClassGen.
When I add method to the ClassGen, the constant pool don't correspond.
References used in the added method are not the good one in the constant pool.
How can I make the constant pool right?
You can see above the instructions list for the method and the constant pool
for the class C1:
package p3;
class A {
int a1;
A() {
a1 = 1;
}
public void paint(){
}
}
-------------------------------------------
Methods ...
void <init>()
list inst : <init>
0: aload_0[42](1)
1: invokespecial[183](3) 11
4: aload_0[42](1)
5: iconst_1[4](1)
6: putfield[181](3) 13
9: return[177](1)
public void paint()
list inst : paint
0: return[177](1)
constant pool ...
1)CONSTANT_Utf8[1]("AB")
2)CONSTANT_Class[7](name_index = 1)
3)CONSTANT_Utf8[1]("java/lang/Object")
4)CONSTANT_Class[7](name_index = 3)
5)CONSTANT_Utf8[1]("a1")
6)CONSTANT_Utf8[1]("I")
7)CONSTANT_NameAndType[12](name_index = 5, signature_index = 6)
8)CONSTANT_Fieldref[9](class_index = 2, name_and_type_index = 7)
9)CONSTANT_Utf8[1]("<init>")
10)CONSTANT_Utf8[1]("()V")
11)CONSTANT_NameAndType[12](name_index = 9, signature_index = 10)
12)CONSTANT_Methodref[10](class_index = 2, name_and_type_index = 11)
13)CONSTANT_Utf8[1]("this")
14)CONSTANT_Utf8[1]("Lp3/A;")
15)CONSTANT_Utf8[1]("LocalVariableTable")
16)CONSTANT_Utf8[1]("LineNumberTable")
17)CONSTANT_Utf8[1]("Code")
18)CONSTANT_Utf8[1]("paint")
19)CONSTANT_NameAndType[12](name_index = 18, signature_index = 10)
20)CONSTANT_Methodref[10](class_index = 2, name_and_type_index = 19)
---------------------------------------
When I decompile the class that I create, instead of the method m1 there is this comment:
// JavaClassFileOutputException: get_constant: invalid tag
Some help will be great appreciate!
Here is my code:
c1 is a java.lang.Class
public void integre() {
String nomGen = "tests/bin/gen/"
+ C1.getName()
+ "_.class";
JavaClass clazz1 = Repository.lookupClass(c1.getCl().getName());
ClassGen cg1 = new ClassGen(clazz1);
ConstantPoolGen cp1 = cg1.getConstantPool();
String nom = C1.getName() + "_.class";
ClassGen _cg = new ClassGen(nom,
"java.lang.Object",
null,
Constants.ACC_PUBLIC,
null);
ConstantPoolGen _cp = _cg.getConstantPool();
System.out.println("Fields ... ");
Field[] tfields = cg1.getFields();
for (int i = 0; i < tfields.length; i++) {
FieldGen fg = new FieldGen(tfields[i], _cp);
_cg.addField(fg.getField());
_cp.addFieldref(_cg.getClassName(),fg.getName(),fg.getSignature());
_cp.addNameAndType(fg.getName(), fg.getSignature());
}
System.out.println("Methods ... ");
Method[] methods = cg1.getMethods();
for (int j=0; j< methods.length; j++) {
MethodGen m = new MethodGen(methods[j],
_cg.getClassName(),
_cp);
_cp.addMethodref(m);
_cp.addNameAndType(m.getName(), m.getSignature());
_cg.addMethod(m.getMethod());
}
JavaClass c3 = _cg.getJavaClass();
c3.setConstantPool(_cp.getFinalConstantPool());
try {
c3.dump(nomGen);
} catch(java.io.IOException e) { System.err.println(e); }
}
------------------------------------------
Faites un voeu et puis Voila ! www.voila.fr
|
|
From: <fa...@vo...> - 2005-04-11 14:40:36
|
Hello,
I try to create a class from 2 different classes.
So I copy fields and methos of both in a ClassGen.
But I 've a problem with methods which use a field in the body
for example:
class A{
int a1;
A(){}
void m1(){
a1 = 2;
}
When I decompile the class that I create, instead of the method m1 there is this comment:
// JavaClassFileOutputException: get_constant: invalid tag
Some help will be great appreciate!
Here is my code:
c1 and c2 are 2 java.lang.Class
String nomGen = "tests/bin/gen/"
+ c1.getShortName()
+ c2.getShortName()
+ ".class";
JavaClass clazz1 = Repository.lookupClass(c1.getName());
JavaClass clazz2 = Repository.lookupClass(c2.getName());
String nom = c1.getShortName() + C2.getShortName();
ClassGen classGen = new ClassGen(clazz1);
classGen.setClassName(nom);
ConstantPoolGen cp = classGen.getConstantPool();
Field[] tfields = clazz2.getFields();
for (int i = 0; i < tfields.length; i++) {
FieldGen fg = new FieldGen(tfields[i], cp);
classGen.addField(fg.getField());
}
Method[] tmeth = clazz2.getMethods();
for (int j = 0; j < tmeth.length; j++) {
MethodGen mg = new MethodGen(tmeth[j], classGen.getClassName(), cp);
classGen.getConstantPool().addNameAndType(mg.getName(), mg.getSignature());
classGen.addMethod(mg.getMethod());
}
try {
classGen.getJavaClass().dump(nomGen);
} catch(java.io.IOException e) { System.err.println(e); }
------------------------------------------
Faites un voeu et puis Voila ! www.voila.fr
|
|
From: Derek M. <d.j...@sm...> - 2003-12-01 11:55:23
|
I am currently undertaking a project to animate java=20
programs by analysing bytecode method calls and attribute updates. I=20
have been studying the BCEL API as a means of implementing my design. I=20
am however having difficulty understanding results when running the=20
program on the latest JDK virtual machine. I wonder if anyone could help =
clarify this.
I have been experimenting with the helloify.java program which I can=20
get working in most cases but I get the following error when executing=20
it on the java program which i have included below.
"Exception in thread "main" java.lang.VerifyError: (class:=20
ComplexNumber_hello, method: add signature:=20
(LComplexNumber;)LComplexNumber;) Incompatible type for getting or=20
setting field"
My java program simply creates two complexNumber objects and adds them=20
together. This compiles and runs successfully on "Java(TM) 2 Runtime=20
Environment, Standard Edition (build 1.4.2_02-b03), Java HotSpot(TM)=20
Client VM (build 1.4.2_02-b03, mixed mode)". The=20
ComplexNumber_hello.class file produces the error above and I cannot=20
understand why. It seems to happen when trying to return the sum of the=20
two complex numbers. I have tried to rectify this problem with no=20
success. When using the Kaffe JVM supplied with RedHat Linux 7.2 I get=20
no errors when running ComplexNumber_hello or ComplexNumber classes. Is=20
this an issue with the latest JVM or am I missing something important?
Thanks.
/*
* Class ComplexNumber specify Complex Number object and
* associated functions
*
*/
class ComplexNumber {
// Private data fields for the complex number:
// realPart + imagPart * i
private double realPart;
private double imagPart;
=20
=20
/**
* initializes the
* the complex number to be zero.
*/
ComplexNumber() {
realPart =3D 0;
imagPart =3D 0;
}
/**
* Constructor that allows the real and imaginary
* parts of the complex number to be initialized
* to arbitrary values.
*/
ComplexNumber(double realPart, double imagPart) {
this.realPart =3D realPart;
this.imagPart =3D imagPart;
}
/**
* Set the value of a complex number by specifying its
* real and imaginary parts.
*/
public void setValue(double realPart, double imagPart) {
this.realPart =3D realPart;
this.imagPart =3D imagPart;
}
/**
* Return a new complex number with its value equal
* to the sum of the invoking ComplexNumber and
* the Complex Number argument.
*/
public ComplexNumber add(ComplexNumber theNum) {
return new ComplexNumber(realPart + theNum.realPart,
imagPart + theNum.imagPart);
} =20
/**
* Convert the complex number into a string representation.
* The string representation is realPart + imagPart i.
*/
public String toString() {
// If the imagPart is >=3D 0 print out a + b i
if (imagPart >=3D 0) {
return realPart + " + " + imagPart + " i";
}
// If the imagPart is < 0 print out a - b i
else {
return realPart + " - " + (-imagPart) + " i";
}
}
=20
//***********************************************************************=
**
// Test the above methods
=20
public static void main(String args[]) {
=20
// Create 3 complex number objects and initialize
ComplexNumber A =3D new ComplexNumber();
ComplexNumber B =3D new ComplexNumber();
ComplexNumber result =3D new ComplexNumber();
System.out.println("Testing ComplexNumber.java...");
=20
A.setValue(5,1);
B.setValue(2,3);
=20
// Test the add method
result =3D A.add(B); =20
=20
// output the result
System.out.println(A.toString() + " + " + B.toString() + " =20
=3D " + result.toString());
=20
}
}
|
|
From: Derek M. <d.j...@sm...> - 2003-12-01 11:46:11
|
I am currently undertaking a project to animate java=20
programs by analysing bytecode method calls and attribute updates. I=20
have been studying the BCEL API as a means of implementing my design. I=20
am however having difficulty understanding results when running the=20
program on the latest JDK virtual machine. I wonder if anyone could help =
clarify this.
I have been experimenting with the helloify.java program which I can=20
get working in most cases but I get the following error when executing=20
it on the java program which i have included below.
"Exception in thread "main" java.lang.VerifyError: (class:=20
ComplexNumber_hello, method: add signature:=20
(LComplexNumber;)LComplexNumber;) Incompatible type for getting or=20
setting field"
My java program simply creates two complexNumber objects and adds them=20
together. This compiles and runs successfully on "Java(TM) 2 Runtime=20
Environment, Standard Edition (build 1.4.2_02-b03), Java HotSpot(TM)=20
Client VM (build 1.4.2_02-b03, mixed mode)". The=20
ComplexNumber_hello.class file produces the error above and I cannot=20
understand why. It seems to happen when trying to return the sum of the=20
two complex numbers. I have tried to rectify this problem with no=20
success. When using the Kaffe JVM supplied with RedHat Linux 7.2 I get=20
no errors when running ComplexNumber_hello or ComplexNumber classes. Is=20
this an issue with the latest JVM or am I missing something important?
Thanks.
/*
* Class ComplexNumber specify Complex Number object and
* associated functions
*
*/
class ComplexNumber {
// Private data fields for the complex number:
// realPart + imagPart * i
private double realPart;
private double imagPart;
=20
=20
/**
* initializes the
* the complex number to be zero.
*/
ComplexNumber() {
realPart =3D 0;
imagPart =3D 0;
}
/**
* Constructor that allows the real and imaginary
* parts of the complex number to be initialized
* to arbitrary values.
*/
ComplexNumber(double realPart, double imagPart) {
this.realPart =3D realPart;
this.imagPart =3D imagPart;
}
/**
* Set the value of a complex number by specifying its
* real and imaginary parts.
*/
public void setValue(double realPart, double imagPart) {
this.realPart =3D realPart;
this.imagPart =3D imagPart;
}
/**
* Return a new complex number with its value equal
* to the sum of the invoking ComplexNumber and
* the Complex Number argument.
*/
public ComplexNumber add(ComplexNumber theNum) {
return new ComplexNumber(realPart + theNum.realPart,
imagPart + theNum.imagPart);
} =20
/**
* Convert the complex number into a string representation.
* The string representation is realPart + imagPart i.
*/
public String toString() {
// If the imagPart is >=3D 0 print out a + b i
if (imagPart >=3D 0) {
return realPart + " + " + imagPart + " i";
}
// If the imagPart is < 0 print out a - b i
else {
return realPart + " - " + (-imagPart) + " i";
}
}
=20
//***********************************************************************=
**
// Test the above methods
=20
public static void main(String args[]) {
=20
// Create 3 complex number objects and initialize
ComplexNumber A =3D new ComplexNumber();
ComplexNumber B =3D new ComplexNumber();
ComplexNumber result =3D new ComplexNumber();
System.out.println("Testing ComplexNumber.java...");
=20
A.setValue(5,1);
B.setValue(2,3);
=20
// Test the add method
result =3D A.add(B); =20
=20
// output the result
System.out.println(A.toString() + " + " + B.toString() + " =20
=3D " + result.toString());
=20
}
}
|
|
From: Graham T. <Gra...@ci...> - 2003-03-18 21:12:24
|
>
>
>Don't know why you want to play ping-pong with comparison instructions;
>
>
To build a state-of-the-art mutation test system of course! =' )
I was basing my example on the tech. report, and had something similar
to the 'optimising boolean expressions' example. Using FindPattern, etc,
lead me to focus on methods, which resulted in nasty ClassGenExceptions.
(example below).
Using a ClassGen object, things now work a peach! I've included the
working code below to act as an example, so such dither-brained-ness
can be avoided!
Thanks for your help,
Graham.
Do do:
public class SimpleReplacement {
private static int mutCount = 0;
public static void main(String[] args) {
JavaClass clazz = Repository.lookupClass("TestClass");
ClassGen classGen = new ClassGen(clazz);
ConstantPoolGen constPoolGen = new ConstantPoolGen(
clazz.getConstantPool());
Method[] methods = classGen.getMethods();
int methodIndex = 0;
while (methodIndex < methods.length) {
Method method = methods[methodIndex];
MethodGen methodGen = new MethodGen(
method, clazz.getClassName(), constPoolGen);
InstructionList instList = methodGen.getInstructionList();
InstructionHandle[] handles = instList.getInstructionHandles();
int handleIndex = 0;
while (handleIndex < handles.length) {
InstructionHandle handle = handles[handleIndex];
Instruction inst = handle.getInstruction();
if (inst.getOpcode() == Constants.IF_ICMPEQ) {
System.out.println("We have an IF_ICMPEQ at inst "
+ handle.getPosition());
generateMutant(clazz, methodIndex, handleIndex);
}
++handleIndex;
}
++methodIndex;
}
System.out.println("DONE");
}
private static void generateMutant(JavaClass clazz, int methodIndex,
int handleIndex) {
ClassGen classGen = new ClassGen(clazz);
Method[] methods = classGen.getMethods();
String className = classGen.getClassName();
ConstantPoolGen constPoolGen = classGen.getConstantPool();
MethodGen methodGen = new MethodGen(
methods[methodIndex], className, constPoolGen);
InstructionList instList = methodGen.getInstructionList();
InstructionHandle[] handles = instList.getInstructionHandles();
InstructionHandle handle = handles[handleIndex];
IF_ICMPNE newInst = new IF_ICMPNE(
((IfInstruction)handle.getInstruction()).getTarget());
handle.setInstruction(newInst);
classGen.setMethodAt(methodGen.getMethod(), methodIndex);
System.out.println("new inst: " + handles[handleIndex]);
try {
classGen.getJavaClass().dump(
"H:\\quick_temp\\TestClass.class.mut_" + (++mutCount));
} catch (IOException e) {
e.printStackTrace();
}
}
}
Don't do:
public class SimpleReplacementBad {
public static void main(String[] args) {
int mutationCount = 0;
JavaClass clazz = Repository.lookupClass("TestClass");
Method[] theMethods = clazz.getMethods();
ConstantPoolGen cpg = new ConstantPoolGen(
clazz.getConstantPool());
for (int i = 0, n = theMethods.length; i < n; i++) {
MethodGen theMethodGen = new MethodGen(
theMethods[i], clazz.getClassName(), cpg);
InstructionList il = theMethodGen.getInstructionList();
FindPattern f = new FindPattern(il);
String pat = "(`IF_ICMPNE')";
InstructionHandle next = null;
for (InstructionHandle ih = f.search(pat);
ih != null;
ih = f.search(pat, next)) {
InstructionHandle theMatch = f.getMatch()[0];
System.out.println("match: " + theMatch + " in " +
theMethods[i]);
Instruction original = theMatch.getInstruction();
theMatch.setInstruction(new IF_ICMPEQ(
((IfInstruction)theMatch.getInstruction()).getTarget()));
theMethods[i] = theMethodGen.getMethod();
try {
clazz.dump("H:\\quick_temp\\mut_" +
(mutationCount++) + ".class");
} catch (IOException e) {
e.printStackTrace(); //To change body of catch
statement use Options | File Templates.
}
System.out.println("wrote to H:\\quick_temp\\mut_" +
mutationCount + ".class");
theMatch.setInstruction(original);
if ((next = theMatch.getNext()) == null) {
break;
}
}
il.dispose(); // Reuse instruction handles
}
System.out.println("done");
}
}
Results in:
match: 14: if_icmpne[160](3) -> iload_1 in public boolean plentyEQ(int i)
de.fub.bytecode.generic.ClassGenException: Target of if_icmpne[160](3)
is invalid null handle
at
de.fub.bytecode.generic.BranchInstruction.getTargetOffset(BranchInstruction.java:58)
at
de.fub.bytecode.generic.BranchInstruction.getTargetOffset(BranchInstruction.java:74)
at
de.fub.bytecode.generic.BranchInstruction.dump(BranchInstruction.java:44)
at
de.fub.bytecode.generic.InstructionList.getByteCode(InstructionList.java:930)
at de.fub.bytecode.generic.MethodGen.getMethod(MethodGen.java:555)
at SimpleReplacementBad.main(SimpleReplacementBad.java:44)
Exception in thread "main"
|
|
From: Enver H. <eh...@in...> - 2003-03-18 19:36:54
|
Hi Graham! > I would like to know the correct way to replace an instruction several > times. I don't really know if there are several ways; but here is one: Use your .class file to get JavaClass/ConstantPool objects (read only API); create ClassGen/ConstantPoolGen (read-write API) out of them. Iterate through the methods (MethodGens). Get the InstructionLists. InstructionLists consist of linked InstructionHandles. Go through the handles and check which Instruction they point to [this is done to implement the Flyweight pattern: immutable Instruction objects are shared!]. If you have found the instruction to replace, fine. Either make the InstructionHandle point to the newly generated Instruction object (you'll possibly need the ConstantPoolGen object to create the Instruction object) - or modify the list to include a new InstructionHandle that points to your newly created Instruction object; and remove the old InstructionHandle. If finished, create a JavaClass from your ClassGen/ConstantPoolGen and dump() it into a file. > Ideally I would be able to take a class and scan each of it methods in > turn for a matching instruction, e.g. IF_ICMPLE. When found, this > instruction would be replaced by, say IF_ICMPLT, and dump the class out > to file. Then replace it again by, say IF_ICMPGE, dump that out to file, > etc, until finally being reset to the original IF_ICMPLE, before going > on to look for another match. Don't know why you want to play ping-pong with comparison instructions; but replacing instructions in BCEL is about as easy as replacing strings with a programmable text editor. > All my efforts so far have ended in exceptions and headache!! > > Can anyone help? Yes, of course. Maybe you could provide some source code and _WHICH_ exceptions up with (don't need to know about the sort of headache you suffer, though .) ). Cheers! Enver |
|
From: Graham T. <Gra...@ci...> - 2003-03-17 20:14:50
|
Hi, I would like to know the correct way to replace an instruction several times. Ideally I would be able to take a class and scan each of it methods in turn for a matching instruction, e.g. IF_ICMPLE. When found, this instruction would be replaced by, say IF_ICMPLT, and dump the class out to file. Then replace it again by, say IF_ICMPGE, dump that out to file, etc, until finally being reset to the original IF_ICMPLE, before going on to look for another match. All my efforts so far have ended in exceptions and headache!! Can anyone help? Cheers, Graham. |
|
From: Ron G. <zlg...@ya...> - 2003-03-14 09:22:13
|
Hi there, I'm new to byte code engineering, but I was hoping someone could tell me how to catch all "if" statements being executed within a specific class. After catching it, get the arguments to the if statement so I can use it to dynamically create a statement in another language that would capture the semantics of the original Java "if" statement. I hope the reply could be pretty specific since I still don't know how to approach the whole thing. Thanks in advance, Ron __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com |
|
From: Sapan S. <sap...@pa...> - 2003-02-26 10:47:14
|
Hi,
I am trying to generate a class. It will have the methods for setting and
getting the attribtues within the class.
Something like,
public String getName(){
return this.name;
}
I am not able to find the way to put the return instruction in the code. How
do i get the return instruction and a reference to this.
Thanks for your time and awaiting early response.
------------------------------------
Sapan Shah
Software Engineer
Patni Computer Systems Limited
A 78/9 GIDC Electronics Estate,
Sector 25,
Gandhinagar
mob: (+91)98240 59280
http://www.patni.com
World-Wide Partnerships. World-Class Solutions
This e-mail message may contain proprietary, confidential or legally
privileged information for the sole use of the person or entity to whom this
message was originally addressed. Any review, e-transmission dissemination
or other use of or taking of any action in reliance upon this information by
persons or entities other than the intended recipient is prohibited. If you
have received this e-mail in error kindly delete this e-mail from your
records. If it appears that this mail has been forwarded to you without
proper authority, please notify us immediately at net...@pa... and
delete this mail.
|
|
From: <be...@ne...> - 2002-08-14 23:27:17
|
On Monday, July 29, 2002, at 09:55 AM, Enver Haase wrote: > If unsure, just increase the maxStack. The calculation in Method.java > also sometimes is a little off, better add some slots to be on the > safe side. I wrote the original version of the algorithm that does the max stack calculation. I would be interested to hear more about when it "is a little off" so it can be fixed. Do you have some example code sequences that demonstrate this problem? - Patrick |
|
From: Enver H. <eh...@in...> - 2002-07-29 16:55:53
|
On Sat, 27 Jul 2002, Aarti Thorat wrote: > > Hence i changed it to 2 * no of times method call inserted, it worked > fine. But the lower limit for which the classfile works fine is 3. > > I am a little confused, as to what exactly the max stack depends on, the > number of arguments taken by the method or the code length of the method. > Can any one please throw some light on this issue ? The JVM works stack-based, i.e. many instructions auch as IADD expect arguments on the stack and/or put arguments on the stack. MaxStack is all about the argument stack; arguments meaning arguments to the instructions, not the method parameters! This is the stack size in question here. For example, IADD does push(pop() + pop()); Usually, one would implement "2+3+4" as iconst_2 ; push "2" onto stack iconst_3 iadd iconst_4 iadd You have at most two stack slots used here (an int uses one slot); so maxStack = 2. but you could also iconst_2 iconst_3 iconst_4 iadd iadd Here, there are three stack slots used at one time, so maxStack = 3. Hope the example helps. If unsure, just increase the maxStack. The calculation in Method.java also sometimes is a little off, better add some slots to be on the safe side. Enver |
|
From: Aarti T. <th...@cs...> - 2002-07-28 03:15:19
|
Hi,
I was trying to insert a method call instead of printing hello, in the
example provided , helloify.java.
I had question about setting of maxstack and thought you would be the best
person to ask.
I am attaching the changed helloify.java , as I was experimenting with it.
The method i am trying to insert is galileo.inst.Probe.pipeWrite. this
takes in two arguments one number and one string.If i insert this method
call once then the condition
if(code.getMaxStack() < 2)
mg.setMaxStack(2);
works fine, but if i have more than that for example 3 or 4 method calls
inserted then it gives me, java.lang.VerifyError-- Stack size too large.
Hence i changed it to 2 * no of times method call inserted, it worked
fine. But the lower limit for which the classfile works fine is 3.
I am a little confused, as to what exactly the max stack depends on, the
number of arguments taken by the method or the code length of the method.
Can any one please throw some light on this issue ?
Thanks,
Aarti.
|
|
From: kalyan r. <cka...@ya...> - 2002-06-17 23:44:47
|
Sir, Can you send me a sample class loader which uses the BCEL api?It should input the class file, modify it on the fly and send it to the JVM.By using your API I am able to dynamically expand the byte code but I do not know how to load using the class loader. The following problems I am facing: 1) when I am importing import de.fub.bytecode.util.ClassLoader import de.fub.bytecode.util.JavaWrapper and compiling I am getting the message ClassLoader and JavaWrapper not found in import. 2) I know hot to add bytecode(using your API) to the input class file but I do not know how to implement using the ClassLoader developed by the BCEL API. Can you please send me a sample ClassLoader implemented by the BCEL API: which will input the class file, modify it on the fly and load it into the JVM. I am unable to follow the ProxyCreator.java example given in the samples...that is why I am troubling you. I will ve very thankful to you for the help Ram ===== C.Kalyan Ram 2221,S St Apt #1,Lincoln NE-68503 Email:cka...@ya... Ph:(402)742-6773 University Of Nebraska-Lincoln __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com |
|
From: <m....@4f...> - 2002-05-13 08:37:46
|
I fixed that, thanks.
(It was probably due to automagically generated code ..)
MD
> -----Ursprungliche Nachricht-----
> Von: bce...@li...
> [mailto:bce...@li...]Im Auftrag von Laurent
> Rolaz
> Gesendet: Sonntag, 12. Mai 2002 15:12
> An: bce...@li...
> Betreff: [BCEL-info]accept method in the StoreInstruction class
>=20
>=20
> Is this implementation of the accept method in
> de.fub.bytecode.generic.StoreInstruction class correct ? It call
> visitStoreInstruction twice !
>=20
> public void accept(Visitor v) {
> v.visitStackConsumer(this);
> v.visitPopInstruction(this);
> v.visitStoreInstruction(this); <- ?
> v.visitTypedInstruction(this);
> v.visitLocalVariableInstruction(this);
> v.visitStoreInstruction(this);
> }
>=20
> Thanks.
> Laurent.
>=20
>=20
> _______________________________________________________________
>=20
> Have big pipes? SourceForge.net is looking for download=20
> mirrors. We supply
> the hardware. You get the recognition. Email Us:=20
> ban...@so...
> _______________________________________________
> BCEL-info mailing list
> BCE...@li...
> https://lists.sourceforge.net/lists/listinfo/bcel-info
>=20
|
|
From: Laurent R. <lau...@ep...> - 2002-05-12 13:10:26
|
Is this implementation of the accept method in
de.fub.bytecode.generic.StoreInstruction class correct ? It call
visitStoreInstruction twice !
public void accept(Visitor v) {
v.visitStackConsumer(this);
v.visitPopInstruction(this);
v.visitStoreInstruction(this); <- ?
v.visitTypedInstruction(this);
v.visitLocalVariableInstruction(this);
v.visitStoreInstruction(this);
}
Thanks.
Laurent.
|
|
From: Bruce W. <bw...@ef...> - 2002-04-25 17:04:16
|
I am working on a class that will take the union of a set of java
classes. It is sort of like a limited multiple inheritance scheme for
java. I am using the BCEL to create a single class that contains all of
the fields and methods of the given classes. So far, i have it working
for the fields, but the methods are giving me fits.
The relavant section of code is
for(int jj=0; jj< source_classes.length; jj++) {
ConstantPoolGen ucg_cpg = union_class_gen.getConstantPool();
ConstantPoolGen source_pool = new
ConstantPoolGen(source_classes[jj].getConstantPool());
union_class_gen.setConstantPool(combineConstants(ucg_cpg,
source_pool));
Field[] field = source_classes[jj].getFields();
Method[] method = source_classes[jj].getMethods();
for (int kk = 0 ; kk<field.length; kk++) {
FieldGen fg = new FieldGen(field[kk],
union_class_gen.getConstantPool());
if(union_class_gen.containsField(field[kk].getName()) !=
null) fg.setName(source_classes[jj].getClassName() + "_" +
field[kk].getName());
union_class_gen.addField(fg.getField());
}
for ( int kk = 0 ; kk < method.length; kk++ ) {
MethodGen mg = new MethodGen(method[kk], union_class_name
,union_class_gen.getConstantPool() );
if( union_class_gen.containsMethod( method[kk].getName(),
method[kk].getSignature()) != null) {
mg.setName(source_classes[jj].getClassName() + "_" +
method[kk].getName());
}
union_class_gen.getConstantPool().addNameAndType(mg.getName(),
mg.getSignature());
union_class_gen.addMethod(mg.getMethod());
}
}
union_class_gen.getJavaClass().dump(output_file_name);
this seems to go ok, javap will report all the fields and methods have
been added to the new generated class. The problem is when i go to load
the class. I get hung up by the verifier. It complains thusly
Exception in thread "main" java.lang.VerifyError:
(class: C, method: B_setSame signature: (Ljava/lang/String;)V) Illegal type
in constant
pool
As far as i can tell, the constant pool has the correct sig for the
method..
here is a printout of the offending constantpool...
0--> null
1--> CONSTANT_Utf8[1]("SourceFile")
2--> CONSTANT_Utf8[1]("Generated Class")
3--> CONSTANT_Utf8[1]("C")
4--> CONSTANT_Class[7](name_index = 3)
5--> CONSTANT_Utf8[1]("java/lang/Object")
6--> CONSTANT_Class[7](name_index = 5)
7--> CONSTANT_Utf8[1]("<init>")
8--> CONSTANT_Utf8[1]("()V")
9--> CONSTANT_NameAndType[12](name_index = 7, signature_index = 8)
10--> CONSTANT_Methodref[10](class_index = 6, name_and_type_index = 9)
11--> CONSTANT_Utf8[1]("A")
12--> CONSTANT_Class[7](name_index = 11)
13--> CONSTANT_Utf8[1]("aInt")
14--> CONSTANT_Utf8[1]("I")
15--> CONSTANT_NameAndType[12](name_index = 13, signature_index = 14)
16--> CONSTANT_Fieldref[9](class_index = 12, name_and_type_index = 15)
17--> CONSTANT_Utf8[1]("AFloat")
18--> CONSTANT_Utf8[1]("F")
19--> CONSTANT_NameAndType[12](name_index = 17, signature_index = 18)
20--> CONSTANT_Fieldref[9](class_index = 12, name_and_type_index = 19)
21--> CONSTANT_Utf8[1]("same")
22--> CONSTANT_Utf8[1]("Ljava/lang/String;")
23--> CONSTANT_NameAndType[12](name_index = 21, signature_index = 22)
24--> CONSTANT_Fieldref[9](class_index = 12, name_and_type_index = 23)
25--> CONSTANT_Utf8[1]("Code")
26--> CONSTANT_Utf8[1]("LineNumberTable")
27--> CONSTANT_Utf8[1]("getAInt")
28--> CONSTANT_Utf8[1]("()I")
29--> CONSTANT_Utf8[1]("setAInt")
30--> CONSTANT_Utf8[1]("(I)V")
31--> CONSTANT_Utf8[1]("getAFloat")
32--> CONSTANT_Utf8[1]("()F")
33--> CONSTANT_Utf8[1]("setAFloat")
34--> CONSTANT_Utf8[1]("(F)V")
35--> CONSTANT_Utf8[1]("getSame")
36--> CONSTANT_Utf8[1]("()Ljava/lang/String;")
37--> CONSTANT_Utf8[1]("setSame")
38--> CONSTANT_Utf8[1]("(Ljava/lang/String;)V")
39--> CONSTANT_Utf8[1]("A.java")
40--> CONSTANT_Utf8[1]("this")
41--> CONSTANT_Utf8[1]("LC;")
42--> CONSTANT_Utf8[1]("LocalVariableTable")
43--> CONSTANT_NameAndType[12](name_index = 27, signature_index = 28)
44--> CONSTANT_NameAndType[12](name_index = 29, signature_index = 30)
45--> CONSTANT_Utf8[1]("arg0")
46--> CONSTANT_NameAndType[12](name_index = 31, signature_index = 32)
47--> CONSTANT_NameAndType[12](name_index = 33, signature_index = 34)
48--> CONSTANT_NameAndType[12](name_index = 35, signature_index = 36)
49--> CONSTANT_NameAndType[12](name_index = 37, signature_index = 38)
50--> CONSTANT_Utf8[1]("B")
51--> CONSTANT_Class[7](name_index = 50)
52--> CONSTANT_Utf8[1]("bInt")
53--> CONSTANT_NameAndType[12](name_index = 52, signature_index = 14)
54--> CONSTANT_Fieldref[9](class_index = 51, name_and_type_index = 53)
55--> CONSTANT_Utf8[1]("bFloat")
56--> CONSTANT_NameAndType[12](name_index = 55, signature_index = 18)
57--> CONSTANT_Fieldref[9](class_index = 51, name_and_type_index = 56)
58--> CONSTANT_Fieldref[9](class_index = 51, name_and_type_index = 23)
59--> CONSTANT_Utf8[1]("getBInt")
60--> CONSTANT_Utf8[1]("setBInt")
61--> CONSTANT_Utf8[1]("getBFloat")
62--> CONSTANT_Utf8[1]("setBFloat")
63--> CONSTANT_Utf8[1]("B.java")
64--> CONSTANT_Utf8[1]("B_same")
65--> CONSTANT_Utf8[1]("B_<init>")
66--> CONSTANT_NameAndType[12](name_index = 65, signature_index = 8)
67--> CONSTANT_NameAndType[12](name_index = 59, signature_index = 28)
68--> CONSTANT_NameAndType[12](name_index = 60, signature_index = 30)
69--> CONSTANT_NameAndType[12](name_index = 61, signature_index = 32)
70--> CONSTANT_NameAndType[12](name_index = 62, signature_index = 34)
71--> CONSTANT_Utf8[1]("B_getSame")
72--> CONSTANT_NameAndType[12](name_index = 71, signature_index = 36)
73--> CONSTANT_Utf8[1]("B_setSame")
74--> CONSTANT_NameAndType[12](name_index = 73, signature_index = 38)
Any help would be appreciated.
Bruce
--
/* _ * */
/*| |__ _ __ __ __ __ *Bruce M. White*/
/*| '_ \_| ' \ \ V V / *bw...@ef...*/
/*|_.__(_)_|_|_(_)_/\_(_)* */
|
|
From: Alan O. <al...@ou...> - 2002-04-23 05:43:52
|
It looks like JasmineVisitor.visitSynthetic assumes that the Synthetic attribute is attached to a method (in order to print ".end method"). I have found several class that have a Synthetic attribute attached to a field. In this case, JasmineVisitor attempts to access the "method" field which is null. I am going to check for null before accessing "method". Should anything be printed after the last attribute of a field? Alan Oursland |
|
From: Alan O. <al...@ou...> - 2002-04-22 17:50:35
|
JasminVisitor.printEndMethod is throwing a NullPointerException when I run
the following code:
try {
File testFile = new File("BCEL/ProxyCreator.class");
JavaClass java_class = new
de.fub.bytecode.classfile.ClassParser(testFile.getAbsolutePath()).parse();
new JasminVisitor( java_class, System.out ).disassemble();
System.exit(1);
} catch( IOException e ) {
}
This is the call stack:
java.lang.NullPointerException
at JasminVisitor.printEndMethod(JasminVisitor.java:75)
at JasminVisitor.visitSynthetic(JasminVisitor.java:82)
at de.fub.bytecode.classfile.Synthetic.accept(Synthetic.java:67)
at
de.fub.bytecode.classfile.DescendingVisitor.visitSynthetic(DescendingVisitor
.java:288)
at de.fub.bytecode.classfile.Synthetic.accept(Synthetic.java:67)
at
de.fub.bytecode.classfile.DescendingVisitor.visitField(DescendingVisitor.jav
a:83)
at de.fub.bytecode.classfile.Field.accept(Field.java:52)
at
de.fub.bytecode.classfile.DescendingVisitor.visitJavaClass(DescendingVisitor
.java:63)
at de.fub.bytecode.classfile.JavaClass.accept(JavaClass.java:171)
at
de.fub.bytecode.classfile.DescendingVisitor.visit(DescendingVisitor.java:55)
at JasminVisitor.disassemble(JasminVisitor.java:33)
at TestBCEL.main(TestBCEL.java:394)
Am I doing something wrong? The weird thing is that I have been using BCEL
for several weeks and this bug just appeared.
Alan Oursland
|
|
From: <m....@4f...> - 2002-04-22 12:05:05
|
Hi, you may have already noticed that BCEL has a new home at http://jakarta.apache.org/bcel/=20 The old source base is stable but will not be further developed anymore. So I recommend to switch to the newest version available at the above URL. Cheers Markus |
|
From: I.S. W. <I.S...@ne...> - 2002-03-13 11:56:32
|
Hi Emiliano, 'this' always stored in the first local variable of the stack frame.=20 ALOAD_0 will push 'this' onto the stack. To reference an instance field then you need something like: ALOAD_0 GETFIELD #x ; where x is an appropriate reference to the constant pool Regards, Ian On Wed, 13 Mar 2002, Emiliano Tramontana wrote: > Dear BCEL users, >=20 >=20 > I'm just starting making some tests with BCEL and I'd like > to know whether you could answer the following question. >=20 > - Is it possible to access (or reference) the variable 'this' > of an object? If it's so, I don't think it's straightforward, > so could you point me to how I can do? >=20 >=20 > Thanks for your time, > Emiliano >=20 >=20 >=20 > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Ing. Emiliano Tramontana > Dipartimento di Matematica e Informatica > Universit=E0 di Catania > Tel. + 39 095 738 3018 > mailto:Tra...@dm... >=20 >=20 >=20 >=20 > _______________________________________________ > BCEL-info mailing list > BCE...@li... > https://lists.sourceforge.net/lists/listinfo/bcel-info >=20 |
|
From: Emiliano T. <Tra...@dm...> - 2002-03-13 11:09:29
|
Dear BCEL users, I'm just starting making some tests with BCEL and I'd like to know whether you could answer the following question. - Is it possible to access (or reference) the variable 'this' of an object? If it's so, I don't think it's straightforward, so could you point me to how I can do? Thanks for your time, Emiliano ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Ing. Emiliano Tramontana Dipartimento di Matematica e Informatica Università di Catania Tel. + 39 095 738 3018 mailto:Tra...@dm... |