[3712] in java-interest
Re: Dependencies
daemon@ATHENA.MIT.EDU (David Geary)
Wed Nov 22 20:42:34 1995
Date: Wed, 22 Nov 1995 08:23:53 -0700
From: David.Geary@Central.Sun.COM (David Geary)
To: mlorton@eshop.com
Cc: java-interest@java.Eng.Sun.COM
Hi Michael,
> > package java.awt;
> >
> > import B.java;
> >
> > class A {
> > B b = null;
> > A() {
> > }
> > }
>
> Dependencies aren't your problem; DOTS are your problem.
>
> Try
> import B
>
> (No dot, not "java")
OK, but look:
/home/geary/java/src/java/foo
total 4
-rw-r--r-- 1 geary staff 55 Nov 22 08:04 A.java
-rw-r--r-- 1 geary staff 55 Nov 22 08:05 B.java
trilby >> export CLASSPATH=/home/geary/java/classes:/home/geary/java/src/java/foo
trilby >> cat A.java
package foo;
import java.foo.B; // I've tried just 'import B;' also, with the same effect
class A {
B b = null;
A() {
}
}
trilby >> cat B.java
package foo;
import java.foo.A; // 'import A;' doesn't work either
class B {
A a = null;
B() {
}
}
Now classes A and B are no longer in awt, and I've fixed the import
statements. So:
trilby >> javac A.java
A.java:3: Class java.foo.B not found in import.
import java.foo.B;
^
A.java:6: Class java.foo.B not found in type declaration.
B b = null;
^
2 errors
Other folks have pointed out that I shouldn't need the import statements if
the classes I'm importing are in the same package:
trilby >> cat A.java
package foo;
class A {
B b = null;
A() {
}
}
trilby >> cat B.java
package foo;
class B {
A a = null;
B() {
}
}
trilby >> javac A.java
A.java:4: Class foo.B not found in type declaration.
B b = null;
^
1 error
>
> Also, you shouldn't put this class in the java.awt package, that would
> only screw (other) things up.
Agreed, however, the real class in question, View, inherits from Container,
and implicitly calls Container's default constructor. If View is in another
package, I cannot get the compiler to swallow the Container() call because it's
"protected". If I put View in awt, then I can compile.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Geary "Alright. Now what"
geary@rmtc.Central.Sun.COM
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com