How to use generics in the world of mixed Java versions?

I like generics and I use them as much as I can. From time to time I need to use one of my classes in another project, which should run on the old JVM (before 5.0), run on JavaME (where generic is not allowed either), or in Microsoft J # (which has VERY poor Generic Support) .

Currently, I delete all generic files manually, which also means adding many castings.

Since generics are called time-only compilation, and each piece of shared code can be automatically converted to non-shared code, I wonder if there is any tool that can do this for me.

If there is no such tool, how else can I solve the problem? Should I completely stop using generics?

Already there are answers related to bytecode compatibility. What if I need to compile the source code for some reason?

+4
source share
4 answers

- Retroweaver, . . Generics - -, , (. java.lang.reflect.Type, ). , -, , 1.5, . Retroweaver , Java 5, .

+5

Netbeans ( , IDE) java- - , . , generics - -, JVM/JRE, , , .

+2
+2

Compatible bytecode, it should work out of the box with the old interpreter.

-5
source

All Articles