Re: Incompatible field Types

Shrinivas Joshi <[email protected]>
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
Hi All,
  With reference to below mail, I just wanted to let you know that
the same code works without any problem if I have an assignment of the
form
   String testString = b.g;
It fails only when I try to assign field of class A with value of field of
class B. Regular variable assignment just works fine.

Thanks and Regards
Shrinivas Joshi.


On Sat, 18 Jun 2005, Shrinivas Joshi wrote:

> Hi All,
>   Below r the e.g classes that I m having problem with.
>
> public  class A {
>    public String f;
>
>    public A(B b)
>    {
> 	f = b.g;
>    }
>    public static void main(String arg[])
>    {
> 	A a = new A(new B);
>    }
>
> }
>
> public class B {
>    public String g;
>    public B()
>    {
> 	g = "TEST";
>    }
> }
>
> The statement f = b.g compiles into
>
> getfield g of B
> putfield f of A
>
> I am changing these 2 instructions into
>
> INVOKE* method //which returns object of Object type
> checkcast java/lang/String
> putfield f of A
>
> But this gives VerifyError saying : Incompatible type for
> getting or setting field
>
> Please let me know whether I m missing something over here.
>
> Thanks and Regards
> Shrinivas Joshi
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
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.