You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by Satria Mandala <th...@gmail.com> on 2009/05/22 10:01:22 UTC

using getClassName in bcel 5.2

Hi Ramesh,

Let me introduced myself, my name satria.
I am new in BCEL 5.2, and need using method getClassName in class
FieldOrMethod of bcel 5.2.
Let say I have a snippet codes as follows:

public void doInstruction(ClassGen cg, MethodGen mg, InstructionHandle ih,
Instruction inst) throws ClassNotFoundException
  {
    if(inst instanceof FieldInstruction)
    {
      FieldInstruction fieldinst = (FieldInstruction)inst;
      ConstantPoolGen cpg = cg.getConstantPool();
      if(rewriter.isEntity(fieldinst.getClassName(cpg)) &&
          !rewriter.isIgnored(fieldinst.getClassName(cpg))
        )
    ....
   }
}

The FieldInstruction extends the FieldOrMethod class. Unfortunately, the
method String getClassName(ConstantPoolGen cpg ) deprecated.

Referring to note in this code, In Java 1.5 may get wrong. Thus a suggestion
is to use the getReferenceType().

I need getting array of String classname from the
fieldinst.getClassName(cpg).
If I used "fieldinst.getLoadClassType(cpg).getClassName()", the method
getLoadClassType(cpg), would return getClassType(cpg), which deprecated
also.

Any suggestion? In addition I can not use the getReferenceType() using the
fieldinst variable.

Regards,
Satria Mandala
Network Security Laboratory
FSKSM - 81310 UTM Skudai
Johor Malaysia