Shao Xing Huang | 6 Jul 2010 22:01
Picon
Favicon

Shao Xing Huang is out of the office.


I will be out of the office starting  2010-06-25 and will not return until
2010-07-12.

I will respond to your message when I return.
Christoph R. | 6 Jul 2010 17:35
Favicon

Searching for parameter annotations

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

      
Marco Bessi | 14 Jun 2010 13:12
Picon

Same questions about variable names

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)

Zachary Palmer | 22 Jan 2010 22:18

Re: SyntheticRepository

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)

ss | 22 Dec 2009 19:30
Picon
Favicon

In BCEL how to know if method is calling super method or any non super method


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)

Anton Margoline | 20 Dec 2009 02:24
Picon

from BCEL line back to source

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!
Habib | 27 Nov 2009 15:32
Picon

Are SELECT instructions StackProducer?

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?
theUser BL | 15 Nov 2009 14:29
Picon
Favicon

Bug in BCEL or BCELifier


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)

MUTHURAMAN SWAMINADHAN | 2 Nov 2009 22:49
Picon
Favicon

Getting the local variables of a method

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
theUser BL | 29 Oct 2009 19:04
Picon
Favicon

How to handel debug-informations?


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/ 
JS | 16 Oct 2009 22:09
Picon

Set serialVersionUID

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!

Gmane