[856] in java-interest

home help back first fref pref prev next nref lref last post

Re: Re:mutual dependencies among public classes

daemon@ATHENA.MIT.EDU (Jonathan Payne)
Fri Aug 11 18:52:29 1995

Date: Fri, 11 Aug 1995 08:56:12 -0700
From: jpayne@starwave.com (Jonathan Payne)
To: econsoft@wintermute.co.uk
Cc: java-interest@java.sun.com
In-Reply-To: <199508111223.NAA04059@oberon.wintermute.co.uk> (econsoft@wintermute.co.uk)

> Date: Fri, 11 Aug 1995 13:23:44 +0100
> X-Sender: econsoft@wintermute.co.uk
> X-Mailer: Windows Eudora Version 1.4.4
> Mime-Version: 1.0
> From: econsoft@wintermute.co.uk (David Gunn)
> Sender: owner-java-interest@java.sun.com
> Precedence: bulk
> X-Info: To unsubscribe, send 'unsubscribe' to java-interest-request@java.sun.com
> Content-Type: text/plain; charset="us-ascii"
> Content-Length: 2963
> 
> I haven't seen any response to Doug Leas message, and it is so fundamental to
> my needs that I thought I would repeat it and emphasise how important it is.
> 
> >From: Doug Lea <dl@altair.cs.oswego.edu>
> >Date: Fri, 4 Aug 1995 13:04:30 -0400
> >Subject: mutual dependencies among public classes
> >
> >If two classes cyclically reference each other, then it appears that
> >they must be defined in the same source file.  While I can't find
> >anything in the spec saying so, it seems that all symbols
> >encountered must be resolvable within the same compilation unit (file)
> >and/or its imported classes. So if two classes reference each other,
> >this can only happen if they are defined in the same file.


This statement is incorrect, unless I am confused.  You can have
classes referring to each other, left and right, and it just works.
They don't have to be in the same file or package.  The compiler just
has to be able to find the other classes, which is why there is the
convention that classes (public ones, anyway) are in files that match
their class names.

So the way this all works is your CLASSPATH must be specified at
compile time so that all the classes can be found.

I'm going to ignore the rest of this message, and hope that what I
just said is enough.

> >On the other hand, the Java spec (section 1) says
> >
> >  Although each Java compilation unit can contain multiple classes or
> >  interfaces, at most one class or interface per compilation unit can be
> >  public.
> >
> >Luckily, this rule does not seem to be enforced in the current
> >(alpha3) compiler. Otherwise there would be no way to declare pairs of
> >mutually referential public classes.  It's not all that rare to want
> >to define such classes.

Well, I guess I will read the rest of the message to say:

	THE ABOVE STATEMENT IS INCORRECT

as I said earlier.
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post