interesting.  I guess that will work...seems like a kludge, but it will
work.
thanks,
dean

----- Original Message ----- 
From: "Dave Brosius" <[EMAIL PROTECTED]>
To: "BCEL Users List" <[email protected]>
Sent: Thursday, January 13, 2005 4:36 PM
Subject: Re: ConstantNameAndType...how do get the type?


> Obviously, you can look for an open parenthesis in the Signature string to
> see if it's a method signature.
>
> ----- Original Message ----- 
> From: "Dave Brosius" <[EMAIL PROTECTED]>
> To: "BCEL Users List" <[email protected]>
> Sent: Thursday, January 13, 2005 5:29 PM
> Subject: Re: ConstantNameAndType...how do get the type?
>
>
> > Yes, i bleieve CONSTANT_NameAndType can signify fields or methods.
> > I'm not sure at this level (getTag), you can differentiate, but could be
> > wrong.
> >
>
> >> Notice this one case statement....(My question is in the comments in
the
> >> below code...)
> >>
> >>     byte tag = c.getTag();
> >>     switch(tag) {
> >>     case Constants.CONSTANT_Class:
> >>          ///some stuff....
> >>     break;
> >>     case Constants.CONSTANT_Fieldref:
> >>         //some stuff
> >>     break;
> >>     case Constants.CONSTANT_NameAndType:
> >>          //Here I seem to be getting field signatures and method
> >> signatures
> >>          //ie. I can use getReturnTypes but it will throw an exception
on
> >> some and on others I can use the code you gave me previously.
> >>          // How do I tell if it is a field signature or method
> >> signature???
> >>     break;
> >>
> >> thanks,
> >> dean
> >>
> >>
> >> ----- Original Message ----- 
> >> From: "Dave Brosius" <[EMAIL PROTECTED]>
> >> To: "BCEL Users List" <[email protected]>
> >> Sent: Thursday, January 13, 2005 8:50 AM
> >> Subject: Re: ConstantNameAndType...how do get the type?
> >>
> >>
> >>> Oh, ()V is a method signature.
> >>>
> >>> Use
> >>>
> >>> Type getReturnType(String signature)
> >>> or
> >>> Type[] getArgumentTypes(String signature)
> >>>
> >>>
> >>> ----- Original Message ----- 
> >>> From: "Dean Hiller" <[EMAIL PROTECTED]>
> >>> To: "BCEL Users List" <[email protected]>
> >>> Sent: Thursday, January 13, 2005 9:53 AM
> >>> Subject: Re: ConstantNameAndType...how do get the type?
> >>>
> >>>
> >>> > thanks much for the hint, though that didn't seem to work as other
> >>> > constants
> >>> > then caused what looks like the same exception even though the code
is
> >>> > different.
> >>> >
> >>> > Here is the code with line numbers...
> >>> >
> >>> > 193      String sig5 = ((ConstantNameAndType)c).getSignature(pool);
> >>> > 194      log("type="+Type.getType(sig5));
> >>> >
> >>> > Here is the exception...notice the exception coming out of line
> >> 194....(Is
> >>> > there some way to prevent this?  This looks like the same exception
I
> >> got
> >>> > with my previous code)
> >>> >
> >>> > 1)
> >>> >
> >>
testLocalVarDepend(net.sf.antcontrib.design.VerifyDesignTest)C:\ROOT\views\s
> >>> > fviews\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(VerifyDesignTes
> >>> > t.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 org.apache.bcel.generic.Type.getType(Type.java:158)
> >>> >
> >>> > at
> >>> >
> >>
net.sf.antcontrib.design.VerifyDesign.processConstant(VerifyDesign.java:194)
> >>> >
> >>> > at
> >>> >
> >>
net.sf.antcontrib.design.VerifyDesign.processConstantPool(VerifyDesign.java:
> >>> > 152)
> >>> >
> >>> > at
> >>> >
> >>
net.sf.antcontrib.design.VerifyDesign.verifyClassAdheresToDesign(VerifyDesig
> >>> > n.java:136)
> >>> >
> >>> > at
net.sf.antcontrib.design.VerifyDesign.execute(VerifyDesign.java:94)
> >>> >
> >>> > 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 org.apache.bcel.generic.Type.getType(Type.java:158)
> >>> >
> >>> > at
> >>> >
> >>
net.sf.antcontrib.design.VerifyDesign.processConstant(VerifyDesign.java:194)
> >>> >
> >>> > at
> >>> >
> >>
net.sf.antcontrib.design.VerifyDesign.processConstantPool(VerifyDesign.java:
> >>> > 152)
> >>> >
> >>> > at
> >>> >
> >>
net.sf.antcontrib.design.VerifyDesign.verifyClassAdheresToDesign(VerifyDesig
> >>> > n.java:136)
> >>> >
> >>> > at
net.sf.antcontrib.design.VerifyDesign.execute(VerifyDesign.java:94)
> >>> >
> >>> > 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(VerifyDesignTes
> >>> > t.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)
> >>> >
> >>> >
> >>> > ----- Original Message ----- 
> >>> > From: "Dave Brosius" <[EMAIL PROTECTED]>
> >>> > To: "BCEL Users List" <[email protected]>
> >>> > Sent: Wednesday, January 12, 2005 11:03 PM
> >>> > Subject: Re: ConstantNameAndType...how do get the type?
> >>> >
> >>> >
> >>> >> Can't you use
> >>> >> ConstantNameAndType.getSignature(pool), and then
> >>> >> Type getType(String signature)
> >>> >>
> >>> >>
> >>> >>
> >>> >>
> >>> >> 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\s
> >>> > fviews\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(VerifyDesignTes
> >>> > t.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(VerifyDesig
> >>> > n.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(VerifyDesig
> >>> > n.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(VerifyDesignTes
> >>> > t.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
> >>> >>
> >>> >>
> >>> >>
> >>>
>> ---------------------------------------------------------------------
> >>> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>> >>
> >>> >
> >>> >
> >>>
> ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>> > For additional commands, e-mail: [EMAIL PROTECTED]
> >>> >
> >>> >
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>> For additional commands, e-mail: [EMAIL PROTECTED]
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to