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 Gareth Morgan <GM...@Armature.com> on 2001/12/12 18:21:00 UTC

method signature types - better way to iterate?

I'm using BCEL to help me generate some code, and excellent it is too!

However, I've got a problem with the Utility class, could someone advise me
if this should go is as a patch request, or if there is a better way to
achieve my aim?

I'm trying to iterate through, and get all the types of input & output
parameters of a method, as expressed by toString() (in Java style). The
problem is in the indicated line (***) below:

     /*
     * takes a BCEL method, returns a Generated method (mostly strings)
     */
    public GeneratedMethod methodToGenMethod(Method m)
    {
<snip>

        // Get name and signature from constant pool
        c = (ConstantUtf8)
m.getConstantPool().getConstant(m.getSignatureIndex(),
                Constants.CONSTANT_Utf8);
        signature = c.getBytes();
	
<snip>

        while (signature.charAt(index) != ')')
        {
            String t = Utility.signatureToString(signature.substring(index),
chopit);
            genMethod.typesVect.add(t);

<snip>

            var_index++;

            //this is private!
***         index += Utility.consumed_chars; // update position
        }

        index++; // update position
	  //deal with return type next...
<snip>

I can't access consumed_chars - it's private. Anyone else got pointers on
better approaches?

Thanks
	Gareth Morgan
	gmorgan AT armature DOT com