[SrcML] Java 1.5 update
Status: Beta
Brought to you by:
crashchaos
From: Frank R. <fra...@in...> - 2005-05-27 22:57:11
|
As we decided to use java 1.5 features from now on I rewrote most parts of the existing code to use generics where applicable. Please update all your CVS modules and in case of conflicts use your own code and just add the generic part to it. (And I don't think I have to mention that from now on using a java 1.5 compiler would be a good idea) All compiles are now done with -Xlint:unchecked. There are a few places where the generics aren't as nice as I'd like them to be. Everywhere where we interact with other libraries not using generics we obviously get into trouble. There's still a compiler warning in the srcml module for the line elements().add(i, e) which involves a dom4j method. Maybe Dennis can take a look at that, as I haven't found a way to silence the compiler there. I've not added this compiler option to the parser-java's build.xml as the generated antlr sourcecode is giving a myriad of errors then. We will still have to wait for a 1.5 version of antlr for that. I've also come to realize first hand what Prof. Heinlein meant about the existing generics not allowing polymorphic use. As we want to get the most benefits from the generic typing we have methods like: Vector<Method> getMethods() which is nice, as it is guaranteeing us that all elements will be instanceof Method. However we often want to use this result Vector and add it to a Vector<SrcMLElement>. This doesn't work however (as we would be working on the original Vector<Method> and could add SrcMLElement instances to it like that). For the same reason it doesn't work with a Vector<? extends SrcMLElement> either. For now I've worked around this problem with the following code template: Vector<SrcMLElement> v = new Vector<SrcMLElement> for (Method m : getMethods()) v.add(m); This basically means 'casting' a Vector<Method> to a Vector<SrcMLElement>. If someone knows a more elegant way to solve the above problem please let me know. -- Raiser, Frank Student @ University of Ulm (www.uni-ulm.de) A complex system that works is invariably found to have evolved from a simple system that worked. (John Gall) |