This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
Re: java/1413: gdb loses java type information
- From: David Carlton <carlton at kealia dot com>
- To: nobody at sources dot redhat dot com
- Cc: gdb-prs at sources dot redhat dot com,
- Date: 9 Oct 2003 19:38:00 -0000
- Subject: Re: java/1413: gdb loses java type information
- Reply-to: David Carlton <carlton at kealia dot com>
The following reply was made to PR java/1413; it has been noted by GNATS.
From: David Carlton <carlton@kealia.com>
To: Jim Blandy <jimb@redhat.com>
Cc: GNATS Filer <gdb-gnats@sources.redhat.com>
Subject: Re: java/1413: gdb loses java type information
Date: Thu, 09 Oct 2003 12:36:21 -0700
> Are there cases where treating every object according to its dynamic
> type would change the semantics of an expression, aside from making
> more expressions permissible (while still never accepting non-typesafe
> expressions)?
Yes. At least in C++; Java has overloading too, right?
class A {
public:
void member(A *x);
};
class B : public A {
public:
void member(B *x);
};
void foo(A *y)
{
B b;
y->member(&b);
}
Here, A::member should be called. But if y is really a B *, and we go
by the dynamic type, then B::member would be called instead.
I've forgotten how Java's overloading rules work, but I would be
surprised if you couldn't construct similar examples in Java.