6 Jul 2010 22:01
6 Jul 2010 17:35
Searching for parameter annotations
Christoph R. <r_christoph <at> ymail.com>
2010-07-06 15:35:46 GMT
2010-07-06 15:35:46 GMT
Hey!
I'm currently writing a static analyser and for this I need to scan class files for annotations. I was able to
do this for class and method annotations but I couldn't find a way to figure out parameter annotations. I
found in the archive that it should be possible, but not how! I'm using the last version from the repository.
Would be great if someone could help me!
Christoph
14 Jun 2010 13:12
Same questions about variable names
Marco Bessi <bessimarco <at> gmail.com>
2010-06-14 11:12:46 GMT
2010-06-14 11:12:46 GMT
Hi all,
I have same problem with bcel api, so I try to answere in this list.
1) How can I get the class variable name about the method that is invoked?
Explain: I have this example code.
String s = "hello";
String g = "world";
int i = s.lenght();
How can I retrieve the name of the variable where i call the method
lenght()? I want the variable name "s"!
Because if I lunch the command "javap -verbose ClassName" I obtain the
bytecode for the class ClassName and I can't get directly the name of
the class where the method is called. For the example code I can get
only that lenght() is a method of the class String but not the name of
the variable "s".
2) If I didn't compile the file class with "javac -g" I can't have the
LocalVariableTable, ok? But can I know if a variable is declarated
internally in the method or is a global variable of the class?
HashSet<String> argsVar = new HashSet<String>();
String[] args = mg.getArgumentNames(); //mg is a MethodGen variable
int k = 0;
int nArgs = args.length;
while(k < nArgs){
argsVar.add(args[k]);
k++;
}
3) The bytecode instructions aload_0 refears always at: args if the
(Continue reading)
22 Jan 2010 22:18
Re: SyntheticRepository
Zachary Palmer <zep_bcel <at> bahj.com>
2010-01-22 21:18:58 GMT
2010-01-22 21:18:58 GMT
After examining the BCEL source code (which was, at least for SyntheticRepository and ClassPath, a pretty nice experience) I have discovered that the SyntheticRepository implementation uses ClassPath.getInputStream(...) to obtain the binary. ClassPath.getInputStream(...) does not check the provided paths first; it checks the current system classloader. Fortunately, ClassPath.getClassFile(...) errors out if the class is not in the explicitly-specified classpath entries. This means I should be able to write my own Repository implementation to get things working for my specific project. I just wanted to leave this explanation for anyone who might stumble into it in the archives. :) Cheers, and thanks again for the impressive library! - Zachary Palmer > Hi, all. I'm new to both the list and to BCEL, but it looks like > precisely what I need for a research project on which I'm working. I > need reflective access to the .class files which are on a given > classpath without loading them into my JVM, so I've been experimenting > with SyntheticRepository and ClassPath. I've written small test app > and I'm getting results other than what I would expect. (e-mail > continues below the following source) > > > import org.apache.bcel.classfile.JavaClass; > import org.apache.bcel.util.ClassPath; > import org.apache.bcel.util.Repository; > import org.apache.bcel.util.SyntheticRepository; >(Continue reading)
22 Dec 2009 19:30
In BCEL how to know if method is calling super method or any non super method
ss <sarmistha <at> hotmail.com>
2009-12-22 18:30:27 GMT
2009-12-22 18:30:27 GMT
Hi
Class constructor can call super or this in it. Both are INVOKESPECIAL. Is
there any way i can know if instrcution is calling super class method or any
other method.
Class B extends A
class B(int i)
{
super(i);
}
or
class B(int i)
{
this(i,null);
}
class B(int i,String desc)
{
super(i);
}
I tried getting class name, but it is same for both super and this.
int h = cp.addMethodref( oldClass.getClassName(), m.getName(), signature);
IVOKESPECIAL newinst1 = new INVOKESPECIAL(h);
System.out.println("************************ "+newinst1.getClassName(cp));
Both cases above reutns class B for first constructor with integer
(Continue reading)
20 Dec 2009 02:24
from BCEL line back to source
Anton Margoline <margant <at> gmail.com>
2009-12-20 01:24:25 GMT
2009-12-20 01:24:25 GMT
Is there a good way to catch assignments to specific value in code?
public void testB() {
*boolean o = !true;*
}
translates to
boolean a = !false;
public testB() : void
L0 (0)
*LINENUMBER 32 L0
ICONST_0
ISTORE 1: o*
L1 (3)
LINENUMBER 33 L1
RETURN
L2 (5)
LOCALVARIABLE this TestDoubleNegative L0 L2 0
LOCALVARIABLE o boolean L1 L2 1
MAXSTACK = 1
MAXLOCALS = 2
I am particularly interested in getting from ICONST_0 to assignment of*!true
*. Let me know if anyone has an idea how to do this.
Thanks in Advance!
27 Nov 2009 15:32
Are SELECT instructions StackProducer?
Habib <hobbbo <at> gmail.com>
2009-11-27 14:32:10 GMT
2009-11-27 14:32:10 GMT
I am currently learning both BCEL and java bytecode. From the javadoc I noticed that LOOKUPSWITH and TABLESWITCH implements the StackProducer interface, however, don't these instructions actually consume the stack (like IfInstruction do), and hence should implement StackConsumer?
15 Nov 2009 14:29
Bug in BCEL or BCELifier
theUser BL <theuserbl <at> hotmail.com>
2009-11-15 13:29:20 GMT
2009-11-15 13:29:20 GMT
Hi!
Have a look at this one:
------------------------
C:\>dir
Volume in Laufwerk C: hat keine Bezeichnung.
Volumeseriennummer: 5481-B7B1
Verzeichnis von C:\
15.11.2009 00:02 <DIR> .
15.11.2009 00:02 <DIR> ..
15.11.2009 00:04 372 Test.java
1 Datei(en), 372 Bytes
2 Verzeichnis(se), 158.248.124.416 Bytes frei
C:\>type Test.java
public class Test {
public static void TestMethod (int first, double second, float third) {
third = 15;
first = 12;
second = 17.2;
third = 19;
System.out.println(first);
System.out.println(second);
System.out.println(third);
System.out.println(third);
(Continue reading)
2 Nov 2009 22:49
Getting the local variables of a method
MUTHURAMAN SWAMINADHAN <muthu437 <at> yahoo.com>
2009-11-02 21:49:42 GMT
2009-11-02 21:49:42 GMT
Hi, I have been trying to get the local variables in a method but I don't see anything returned. I am using the following snippet. LocalVariable lv[]; LocalVariableTable lvt; lvt=mt.getLocalVariableTable(); //mt is a method object lv=lvt.getLocalVariableTable(); I don't get anything back in the lv array. Can anyone advise if this is the correct approach or if there is a better approach? Thanks, Muthu
29 Oct 2009 19:04
How to handel debug-informations?
theUser BL <theuserbl <at> hotmail.com>
2009-10-29 18:04:49 GMT
2009-10-29 18:04:49 GMT
Hi! Where can I read how to handle debug-informations with BCEL? And is it possible with it? I have tried org.apache.bcel.util.BCELifier out. The created programs still runs like the originals. But the recreated programs are all WITHOUT debug-informations.So, is it possible to create them? And how? Btw: At http://jakarta.apache.org/bcel/faq.html there stands under the question "Can I use BCEL in a commercial product?" the address "http://jakarta.apace.org/bcel/". You read right. There stant "Apache" without "h" ! Btw2: At http://packages.debian.org/de/source/lenny/bcel there existing already a BCEL 5.2-3. And as you can see at http://packages.qa.debian.org/b/bcel.html thats the stable version. Unstable is 5.2-6. Why are that patches not in the official BCEL-version? Why existing no new version 5.2.3 on the BCEL-side? Or are the changes unimportant? Greatings theuserbl _________________________________________________________________ Das neue Windows 7: Vereinfachen Sie Ihre täglichen Aufgaben. Finden Sie den richtigen PC. http://www.microsoft.com/germany/windows/buy/
16 Oct 2009 22:09
Set serialVersionUID
JS <jshellman <at> gmail.com>
2009-10-16 20:09:34 GMT
2009-10-16 20:09:34 GMT
How would I set the serialVersionUID using BCEL? I'm using BCEL's ClassLoader, overriding modifyClass. I have it adding the Serializable interface successfully, but I also need to set the serialVersionUID for the class. How would I do so? Thanks!
So, is it possible to create them? And how?
Btw: At
RSS Feed