R
Rhino
I'm an experienced Java programmer but I've been away from Java for a few
years and need a bit of a memory assist. Also, I don't remember all of the
terminology so forgive me if I use the wrong word occasionally: I'll try to
be clear in what I mean so that you understand what I'm asking.
I have two packages in the same Eclipse (Galileo) project: com.foo.old and
com.foo.new. The "new" package does the same thing as the "old" package but
has a couple of new classes that have some new functionality. All of the
existing classes in the "old" project are completely unchanged. The "new"
package contains only the classes containing the new functionality and a new
version of the "driver" program from the old package. The "driver" program
basically just instantiates each of the other classes in turn with
statements like this, where Alpha is the class called by the driver program
and writeBlah() is its primary method, and x and y are parameters passed
from the driver program (x is a String and y is an Object):
new Alpha().writeBlah(x, y);
In the "old" package, the driver program finds classes Alpha, Beta and all
of their peers in its own package. The old version of the driver program
works perfectly.
My problem is in accessing the classes in the old package from the "new"
version of the driver in the "new" package.
I did CTRL-SHIFT-O in Eclipse so that it would find Alpha and its peers in
the "old" package and the statement to import com.foo.old appeared without
difficulty. However, now I get a compile error. The method name, writeBlah,
is underlined in red and the message says "the method writeBlah(String,
Object) in the type Alpha is not applicable for the arguments (String,
Object).".
I don't understand why I'm getting this message. I am passing the correct
parameters to the method and they are in the correct order. In fact, I
haven't changed the content of the code in Alpha at all. The only new thing
is that the new version of the driver program is accessing Alpha in a
different package. I thought perhaps I had a scope problem but all of the
methods in Alpha are public.
Can someone enlighten me on what silly thing I've done and how to fix this?
Just to recap then, com.foo.old contains:
MyDriver.java (old version), which instantiates Alpha, Beta, and Gamma
Alpha.java
Beta.java
Gamma.java
com.foo.new contains:
MyDriver.java (new version), which instantiates Alpha, Beta, and Gamma from
com.foo.old and Delta from com.foo.new
Delta.java
By the way, if this approach is wrong and there is a better one, I'd be glad
to hear about it. I'm not wedded to the idea of doing this via an "old" and
a "new" package.
years and need a bit of a memory assist. Also, I don't remember all of the
terminology so forgive me if I use the wrong word occasionally: I'll try to
be clear in what I mean so that you understand what I'm asking.
I have two packages in the same Eclipse (Galileo) project: com.foo.old and
com.foo.new. The "new" package does the same thing as the "old" package but
has a couple of new classes that have some new functionality. All of the
existing classes in the "old" project are completely unchanged. The "new"
package contains only the classes containing the new functionality and a new
version of the "driver" program from the old package. The "driver" program
basically just instantiates each of the other classes in turn with
statements like this, where Alpha is the class called by the driver program
and writeBlah() is its primary method, and x and y are parameters passed
from the driver program (x is a String and y is an Object):
new Alpha().writeBlah(x, y);
In the "old" package, the driver program finds classes Alpha, Beta and all
of their peers in its own package. The old version of the driver program
works perfectly.
My problem is in accessing the classes in the old package from the "new"
version of the driver in the "new" package.
I did CTRL-SHIFT-O in Eclipse so that it would find Alpha and its peers in
the "old" package and the statement to import com.foo.old appeared without
difficulty. However, now I get a compile error. The method name, writeBlah,
is underlined in red and the message says "the method writeBlah(String,
Object) in the type Alpha is not applicable for the arguments (String,
Object).".
I don't understand why I'm getting this message. I am passing the correct
parameters to the method and they are in the correct order. In fact, I
haven't changed the content of the code in Alpha at all. The only new thing
is that the new version of the driver program is accessing Alpha in a
different package. I thought perhaps I had a scope problem but all of the
methods in Alpha are public.
Can someone enlighten me on what silly thing I've done and how to fix this?
Just to recap then, com.foo.old contains:
MyDriver.java (old version), which instantiates Alpha, Beta, and Gamma
Alpha.java
Beta.java
Gamma.java
com.foo.new contains:
MyDriver.java (new version), which instantiates Alpha, Beta, and Gamma from
com.foo.old and Delta from com.foo.new
Delta.java
By the way, if this approach is wrong and there is a better one, I'd be glad
to hear about it. I'm not wedded to the idea of doing this via an "old" and
a "new" package.