Generic Type Parameterization

Hey all, pseudo new to Eclipse & Java, very new to jME.



Followed the tuts in the wiki, got everything setup & running fine… have even made a very simple StandardGame.



My Question is from the several hundred warnings that Eclipse offers up about some of the ArrayLists, Callables, Classes, etc.



Examples:

ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized.

Callable is a raw type. References to generic type Callable<V> should be parameterized.

Class is a raw type. References to generic type Class<T> should be parameterized.





I did some research a while ago for a similar issue stemming from the Multiverse technology, but came to no conclusions.  Now I know that Warnings wont prevent a successful compile, but being a bit of a perfectionist, I am curious as to if anyone has attempted clean up all these Warnings?  If not, does anyone know a way to supress Eclipse from offering up this particular type of warning?

Generics have been introduced to Java in Java 1.5 (aka Java 5). jME's development began with Java 1.4 (I suppose) and it should be usable with Java 1.4 as well since this version is still very common (I suppose again here).



The absence of generic parametrization is the absence of a mechanism to prevent coding mistakes, not inevitably the presence of bugs :smiley:

There are two ways to get rid of the compiler warnings:

  1. Tell Eclipse to ignore these specific compiler warnings (Project Properties -> Java Compiler -> Errors/Warnings -> Enable Specific Settings Go to the "generic types" section and set the options to ignore). I would recommend this. Important: Only set this option for this project. You want the compile warnings in your other projects to help you avoid bugs.
  2. Use Java 1.4 (Project Properties -> Java Compiler -> Compiler Compliance Settings -> 1.4). The gain of this is that your compiled code is in fact usable for Java 1.4 VMs. The drawback is that you might not profit of all improvements of Java since 1.4 - Thats a guess! I'm no Java Guru there.



    Of course there would is a third way: "Fix" all the warnings. I.e. add the correct generic references where ever needed. You create your own branch of jME - i'm quite sure you don't want THAT  8)



    To all the developers out there? What is your plan concerning updating the code to Java 1.5/1.6?

Thanks for that!



#1 Worked well.

#2 Is not a good idea as SOME of the generics are Parameterized (aka a few Maps/HashMaps) and they all broke when I changed the compiler compliance.

#3 I might tackle something like this in a few months to a year, aka, no longer a jME noob :slight_smile:

It's something we're tackling over time.

claymore1977 said:

#2 Is not a good idea as SOME of the generics are Parametrized (aka a few Maps/HashMaps) and they all broke when I changed the compiler compliance.

Ah OK, didn't know that. In fact this means that the Java 1.4 compliance is broken already, isn't it? Then "go go" for generics everywhere  8)