This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Running a Java Program
- From: Ranjit Mathew <rmathew at hotmail dot com>
- To: java at gcc dot gnu dot org
- Date: Fri, 10 Oct 2003 20:22:47 +0530
- Subject: Re: Running a Java Program
- References: <bm6eqe$39d$1@sea.gmane.org>
Uggghhh! I got confused between overriding and
inheriting static methods. Consider:
------------------------- 8< ----------------------------
public class C
{
public static void main( String[] args)
{
B.main( new String[] { "SNAFU"});
}
}
------------------------- 8< ----------------------------
Both gij and Sun's JREs run this successfully.
So it looks like a bug in gij (and Oracle JDeveloper
10g Preview)!
Note that GCJ is able to compile it successfully
to a native application but on execution the
same error as gij is printed.
Ranjit.
Ranjit Mathew wrote:
> Hi,
>
> Today I came across this weird behaviour in the
> Sun JRE that is not present in gij. Consider these:
> ------------------------- 8< ----------------------------
> public class A
> {
> public static void main( String[] args)
> {
> System.out.println( "Hello World!");
> }
> }
> ------------------------- 8< ----------------------------
> public class B extends A
> {
> }
> ------------------------- 8< ----------------------------
>
> Compile these files to bytecode.
>
> If I run "java B" Sun's JRE (both 1.3.1 and 1.4.2)
> goes ahead and runs the main( ) from class A!
>
> If I run "gij B" it (rightly, IMHO) prints out:
>
> no suitable method `main' in class
>
> This is also rejected by Oracle's new JDeveloper 10g preview
> while the older version allowed this to happen (that's
> how I discovered it).
>
> What do you guys think is the correct behaviour?
> Should we bother emulating Sun in this even though
> it is not even documented in the main "java"
> tool documentation?
>
> Ranjit.
>
--
Ranjit Mathew Email: rmathew AT hotmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.tripod.com/