Strange behavior of javac

Maurizio Cimadamore Maurizio.Cimadamore at Sun.COM
Wed Sep 24 05:16:40 PDT 2008


Hi Max
If you read this document:

http://java.sun.com/javase/6/docs/technotes/tools/solaris/javac.html

You'll find the following line:*

*"Note:   The directory specified by -d  is not automatically added to 
your user class path."

Which seems to suggest that the standard behavior is not to add the 
destination directory to the classpath; as a consequence your second 
compilation must fail, as javac cannot find any class/sources under ./x/

It seems like your Linux box with the latest openjdk build is not 
behaving as expected - as it ends up in adding the destination directory 
to your classpath. But I might be wrong.

FYI, under Ubuntu 8.04 your commands fail using both openjdk-6 and 
1.6.0_06 compilers.

Jon, any ideas?
Maurizio

Max (Weijun) Wang wrote:
> Hi All
>
> I just built a bsd-port openjdk, the last of the following commands 
> fails.
>
> cd /tmp
> echo 'package x; public class A {}' > A.java
> javac -d $JM/classes A.java
> echo 'package x; public class B extends A {}' > B.java
> javac -d $JM/classes B.java
>
>   B.java:1: cannot find symbol
>   symbol: class A
>   package x; public class B extends A {}
>                                   ^
>   1 error
>
> (Here $JM is the newly built jdk, javac is the compiler in $JM/bin)
>
> As I understand, the second javac call should be able to load class A 
> from $JM/classes/x/A.class. This is true on my Linux box with the 
> latest openjdk build.
>
> Any ideas?
>
> Thanks
> Max
>




More information about the compiler-dev mailing list