Community
Participate
Working Groups
When working with a Hashtable and a new style for loop the editor is confused about the correct type of the Hashtables key and values sets. In the simple example below the editor states a type mismatch cannot convert Integer to String. Change the String s to Integer s, the editor complains that it cannot convert String to Integer. The same holds true for other Collection classes as well. In the example code the same cannot covert from type Integer to String occures when using the list in the for loop. I imagine this has something to do with the JavaModel being used in the editor as they are only visual errors and the class compiles and runs ok. public class test { public static void main(String[] args) { Hashtable<Integer, String> h = new Hashtable<Integer,String>(); h.put(new Integer(0), "value"); String st = h.get(new Integer(0)); for(String s: h.values()){ System.out.println(s); } List<String> l = new ArrayList<String>(); for(String s: l){ System.out.println(s); } } }
Playing around a bit more this seams to happen sporadically when initially creating a class and editing it. If you close the editor and reopen the error markers are gone.
You guessed right, this is due to the model not yet knowing about generics and thus fooling the editor. When you build however, the compiler has no issue with these, and this explains why you don't see markers persisted in problem view. These inconsistencies are temporary. As soon as support is added to the model, these should disappear. FYI, we are working on adding this support at the moment, and will refresh the Cheetah as soon as we can finalize it.
Support released in JavaModel for generics. Testcase is no longer reporting problems in editor.