843793Jun 27 2002 — edited Jul 29 2002
If I template a class it will replace the interface of that class such that I dont have to cast what goes in and out of the class anymore because the new class will accept the true object type in the raw. This is not the same as wrapping the class because a wrapped class just has its casts on the inside. Generics MUST eliminate all typecasting.
Collections will have to be written from the bottom up as template classes which will have to be essentially abstract because they can not be compiled without knowing what types of objects to use.
This should speed up code and make it more safe by removing all of the typecasting.
But my question is now what is the contract or relationship between my templated class and the class it was templated from? The template class of course will never exist as a .class file.
Technically wouldnt a generic generation tool be more appropriate? Like we have the IDL tool? Make generic classes a .gen file and make them require processing through another tool that will simply generate java source code in a consistent fashion. Since this is all compile time, this would be a perfect solution especially since the debugger would be able to step through the source and the class cleanly.
I think this has to be better and the least invasive of the options. letting people create and manage their own generic classes and also sun can supply generic collections too.
1. no javac changes.
2. no JVM changes.
3. no changes to appearance of source code for developers who review code they didnt write.
4. The generic class is there and ready to generate new .java files at your discretion.
5. Completely optional. a user does not even have to know they exist.
Anyone have a problem with this? Did I miss the point?