🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8631

Re: RTTI at method call time

#8631
From: Calvin R. Smith
Date: Mon, 12 Mar 2001 19:34
56 lines
2371 bytes
Torsten,
   Sorry about that I guess I was in a hurry and didn't look to closely at
the example I gave.  Here is an example program that demonstrates the error:

package testrtti;

public class Main
{
  public Main()
  {
  }

  public void a(Object o)
  {
    System.out.println("object version called");
  }

  public void a(Main m)
  {
    System.out.println("Main version called");
  }

  public static void main(String[] args)
  {
    Main main = new Main();
    main.a(main);  // calls main version
    Object o = main;
    main.a(o);  // calls object version even though the class is really a
main class
    main.a((Main)o);  // calls main version due to typecast - which should
be implicit
  }
}

After running this you can see that the Object version is called even though
the class could be casted to Main and work.  Here is the output I get:
Main version called
object version called
Main version called

"Torsten Welches" <torsten.welches@who.cares.netcologne.de> wrote in message
news:3aad162e_2@dnews...
> Calvin,
>
> could you provide a real example?
> In your example it would clearly call b, not c. I assume you meant:
>
> public void c(MyClass mc) {}
>
> public void c(Object o) {}
>
> But even then it would call the MyClass version.
>
> Torsten
>
>
Technical Details
Message-ID: <3aad2512_2@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone2.usenetserver.com!news-out.usenetserver.com!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!dnews!207.201.104.90
References: <3aacf50e_2@dnews> <3aad162e_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,236a87dd0ff35d6d
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-12 11:46:05 PST
Reply-To: "Calvin R. Smith" <calvinrsmith@hotmail.com>
From: "Calvin R. Smith" <calvinrsmith@hotmail.com>
Newsgroups: borland.public.jbuilder.java.language
References: <3aacf50e_2@dnews> <3aad162e_2@dnews>
Subject: Re: RTTI at method call time
Date: Mon, 12 Mar 2001 12:34:06 -0700
Lines: 58
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 207.201.104.90
Message-ID: <3aad2512_2@dnews>
X-Trace: 12 Mar 2001 11:35:46 -0800, 207.201.104.90
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone2.usenetserver.com!news-out.usenetserver.com!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!dnews!207.201.104.90