Mysterious Generics
Some months ago, I've created a simple generics example, which compiled
fine with 1.5.0rc, but not with 1.5.0fcs:
public interface IEntry<_D_ extends IDirectory, F extends IFile> {
String getName();
D getParent();
}
public interface IDirectory<_D_ extends IDirectory, F extends
IFile> extends IEntry<_D_, F> {
Collection getSubDirectories();
Collection<_F_>]]> getFiles();
}
public interface IFile<_D_ extends IDirectory, F extends IFile>
extends IEntry<_D_, F> {
}
The compiler complains about the "Collection]]>
getSubDirectories();"-line in IDirectory:
type parameter D is not within its bound
Does somebody knows, how to fix it? Maybe I'm blind and don't see the
obvious. Thanks in advance.
Tom
请先登录再写评论。
Tom, I really don't see compiler error in your code. Are you sure you use the fcs version?
Eugene.
Thanks for looking into this issue.
Same with me :)
"java -version" executed in the SDK's bin directory returns
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
I believe, this is the final version.
Tom
Hello, Thomas!
You wrote on Wed, 03 Nov 2004 21:50:22 +0100:
As for me, the compiler complains abaut "_F_" for collection :)
But, it so very strange, i'm can compile those three classes separately. If
i compile only IDerectory - all file, i got error only if i make entire
project.
I fix it by follow:
> extends IEntry<_D_, _F_> { Collection<_D_> getSubDirectories(); Collection<_F_> getFiles(); } ]]>Thanks!
--
Alexey Efimov, Java Developer
Tops-BI
http://www.topsbi.ru
Does the file have a package? I've seen some strange bug reports in generics
due to the classes being in the default package.
Just opening my big mouth, without having yet written a single line with
generics :)
Yes, I've tried it with a package statement. I just did not mention it
to make the example as short as possible.
Tom
Hello, Thomas!
You wrote on Wed, 03 Nov 2004 21:50:22 +0100:
Compilation result defferent on Pallada and Irida but in the save version of
JDK...
It seems to 'some precompiling processes in Irida'?
Thanks!
--
Alexey Efimov, Java Developer
Tops-BI
http://www.topsbi.ru