Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2981 > unrolled thread

How does Javac find source code?

Started byRoedy Green <see_website@mindprod.com.invalid>
First post2014-08-04 19:41 -0700
Last post2014-08-05 17:48 -0400
Articles 2 — 2 participants

Back to article view | Back to comp.lang.java.help


Contents

  How does Javac find source code? Roedy Green <see_website@mindprod.com.invalid> - 2014-08-04 19:41 -0700
    Re: How does Javac find source code? Jeff Higgins <jeff@invalid.invalid> - 2014-08-05 17:48 -0400

#2981 — How does Javac find source code?

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-08-04 19:41 -0700
SubjectHow does Javac find source code?
Message-ID<mlg0u9lpiq8rmquc5eimokjlicb2vkh9s9@4ax.com>
Back in the days of Java 1.0 I figured out how Javac.exe and Java.exe
find their source code and classes on the sourcepath/classpath.

However one mystery has remained. The question is not a practical one,
just a minor irritant.

Java insists you put each public class in its own source code file
with a name matching the class and the directory structure matching
the package. This is how Java can find the source for a class it
needs. It can generate the source code file name.

However, you are permitted to include  a non-public top-level class in
the same source file as a public class. How then does Java find that
non-public class?

Does it just search all the *.java files in that package?
Does it postpone looking for it until it has loaded all the top level
classes it wants, and hope it finds it by serendipity?
-- 
Roedy Green Canadian Mind Products http://mindprod.com
The art of strongly-typed language design is largely arranging 
that errors are automatically detected as soon as possible
in the compose, compile, run cycle.

[toc] | [next] | [standalone]


#2983

FromJeff Higgins <jeff@invalid.invalid>
Date2014-08-05 17:48 -0400
Message-ID<lrrjgh$rki$1@dont-email.me>
In reply to#2981
On 08/04/2014 10:41 PM, Roedy Green wrote:
> Back in the days of Java 1.0 I figured out how Javac.exe and Java.exe
> find their source code and classes on the sourcepath/classpath.
>
> However one mystery has remained. The question is not a practical one,
> just a minor irritant.
>
> Java insists you put each public class in its own source code file
> with a name matching the class and the directory structure matching
> the package. This is how Java can find the source for a class it
> needs. It can generate the source code file name.
>
> However, you are permitted to include  a non-public top-level class in
> the same source file as a public class. How then does Java find that
> non-public class?
>
> Does it just search all the *.java files in that package?
> Does it postpone looking for it until it has loaded all the top level
> classes it wants, and hope it finds it by serendipity?
>
You might try the Hitchhiker's Guide to start.
<http://openjdk.java.net/groups/compiler/doc/hhgtjavac/index.html>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.help


csiph-web