You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by Siam Rafiee <si...@gmail.com> on 2008/02/06 06:50:01 UTC

BCEL annotations

Hi,

I'm wondering what the current state of the BCEL Annotations API is 
(which, last I heard, was in development)... Is it working and complete 
on trunk? Any known issues with it?

Cheers,

Siam

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


Question about branch instruction targets

Posted by Mark Reynolds <mr...@bbn.com>.
I'm trying to get the target of a branch instruction, but it always gives me 
a null
instruction handle.  The code is very simple:

int fnd = (-1);
JavaClass       clazz   = Repository.lookupClass("test");
Method[]        methods = clazz.getMethods();
 // find method "hello"
for(int i = 0;i < methods.length;i++) {
          System.out.println("Method[" + i + "] = " + methods[i]);
          String s = methods[i].getName();
          System.out.println("Name is " + s);
          if ( s.equals("hello") ) fnd = i;
         }
if ( fnd >= 0 ) {
    ConstantPool cp = clazz.getConstantPool();
    methods[fnd].setConstantPool(cp);  // try setting constant pool
    Code c = methods[fnd].getCode();
    c.setConstantPool(cp);  // try again
    byte[] b = c.getCode();
    InstructionList il = new InstructionList(b);
    il.setPositions(true);
    Instruction ii[] = il.getInstructions();
    for(int w=0;w<ii.length;w++) {
          System.out.println("Instruction[" + w + "] = " + ii[w]);
          if ( ii[w] instanceof BranchInstruction ) {
               InstructionHandle ih = 
((BranchInstruction)(ii[w])).getTarget();
               if ( ih != null )
                     System.out.println("   Branch " + ih.getPosition());
          }
     }
}

and yet it fails every time. Clearly I am doing something wrong. Can someone 
please
give me a clue?

Thanks,

Mark




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


Re: BCEL annotations

Posted by Torsten Curdt <tc...@apache.org>.
On 06.02.2008, at 06:50, Siam Rafiee wrote:

> Hi,
>
> I'm wondering what the current state of the BCEL Annotations API is  
> (which, last I heard, was in development)... Is it working and  
> complete on trunk? Any known issues with it?

It seems like people are already playing with it. It comes with unit  
tests. IIUC for custom annotations we might need open up a class (saw  
that in bugzilla) ...but I suggest you give it a try.

The plan was to slowly get a new release out. This week I will  
prepare a first RC out for people to play with. Would be great to get  
some feedback from you.

cheers
--
Torsten


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