ConstantNameAndType...how do get the type?

"Dean Hiller" <[email protected]>
Newsgroups gmane.comp.jakarta.bcel.user
Message-ID <[email protected]>
I am trying to get the type information out of of a ConstantNameAndType...

here is my code so far
      String temp = pool.constantToString(((ConstantNameAndType)c).getNameIndex(), Constants.CONSTANT_Utf8) 
        + " " 
     + pool.constantToString(((ConstantNameAndType)c).getSignatureIndex(), Constants.CONSTANT_Utf8);
      log("temp="+temp);
      String temp2 = pool.constantToString(((ConstantNameAndType)c).getSignatureIndex(), Constants.CONSTANT_Utf8);
      log("temp2="+temp2);
      //log("temp2a="+Utility.typeOfSignature(temp2));
      log("temp3="+Utility.compactClassName(temp2));

which prints the following.....
const[18]=c Lmod/dummy/DummyClass; inst=org.apache.bcel.classfile.ConstantNameAndType

temp=c Lmod/dummy/DummyClass;

temp2=Lmod/dummy/DummyClass;

temp3=Lmod.dummy.DummyClass;

I am just trying to get the mod.dummy.DummyClass string.  how do I do so?  If I uncomment the temp2a above it breaks because of other ConstantNameAndTypes like the following message when I uncomment temp2a above.....

const[18]=<init> ()V inst=org.apache.bcel.classfile.ConstantNameAndType

temp=<init> ()V

temp2=()V

E

Time: 2.244

There was 1 error:

1) testLocalVarDepend(net.sf.antcontrib.design.VerifyDesignTest)C:\ROOT\views\sfviews\ant-contrib2\test\resources\design\verifydesign.xml:102: org.apache.bcel.classfile.ClassFormatException: Invalid method signature: ()V

at org.apache.tools.ant.Task.perform(Task.java:373)

at org.apache.tools.ant.Target.execute(Target.java:341)

at org.apache.tools.ant.Target.performTasks(Target.java:369)

at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

at org.apache.tools.ant.BuildFileTest.executeTarget(BuildFileTest.java:232)

at net.sf.antcontrib.design.VerifyDesignTest.testLocalVarDepend(VerifyDesignTest.java:116)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at net.sf.antcontrib.design.VerifyDesignTest.main(VerifyDesignTest.java:205)

Caused by: org.apache.bcel.classfile.ClassFormatException: Invalid method signature: ()V

at org.apache.bcel.classfile.Utility.typeOfSignature(Utility.java:1024)

at net.sf.antcontrib.design.VerifyDesign.processConstant(VerifyDesign.java:189)

at net.sf.antcontrib.design.VerifyDesign.processConstantPool(VerifyDesign.java:151)

at net.sf.antcontrib.design.VerifyDesign.verifyClassAdheresToDesign(VerifyDesign.java:135)

at net.sf.antcontrib.design.VerifyDesign.execute(VerifyDesign.java:93)

at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)

at org.apache.tools.ant.Task.perform(Task.java:364)

... 21 more

--- Nested Exception ---

org.apache.bcel.classfile.ClassFormatException: Invalid method signature: ()V

at org.apache.bcel.classfile.Utility.typeOfSignature(Utility.java:1024)

at net.sf.antcontrib.design.VerifyDesign.processConstant(VerifyDesign.java:189)

at net.sf.antcontrib.design.VerifyDesign.processConstantPool(VerifyDesign.java:151)

at net.sf.antcontrib.design.VerifyDesign.verifyClassAdheresToDesign(VerifyDesign.java:135)

at net.sf.antcontrib.design.VerifyDesign.execute(VerifyDesign.java:93)

at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)

at org.apache.tools.ant.Task.perform(Task.java:364)

at org.apache.tools.ant.Target.execute(Target.java:341)

at org.apache.tools.ant.Target.performTasks(Target.java:369)

at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

at org.apache.tools.ant.BuildFileTest.executeTarget(BuildFileTest.java:232)

at net.sf.antcontrib.design.VerifyDesignTest.testLocalVarDepend(VerifyDesignTest.java:116)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at net.sf.antcontrib.design.VerifyDesignTest.main(VerifyDesignTest.java:205)

thanks for any help,

dean
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.