This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I noticed Axis2's wsdl2java generates with a ton of compiler warnings. Many of them are generic issues (using the raw type), but others are 'dumber' like creating local variables, private variables and private methods that never get referenced. Since I'm reluctant to ever modify generated code directly, is there a command line option or feature of Axis2 that will eliminate or at least reduce the warnings?
As you say, the code is generated, and its usually best to leave it alone. And its Java source code. However, you get warnings when you compile them. So if you use javac to compile the generated code in an ant task, you can always use the -nowarn option ... of course, this means that it would also hide other types of warnings that you may actually want to see and be aware of. Or if you are using an IDE, the IDE should have some options that you can customize.
For example, in Eclipse, Window->Preferences->Java->Compiler->Errors/Warnings, you can ask Eclipse to show or ignore specific types of warnings. The generated code has lot of warning about ArrayList, e.g. "ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized". You can always ask Eclipse to not show these.
Or ... in Eclipse in the Problems tab, select the desired warnings ... and then right-click and delete them Then they will be gone from your view.
Or ... you can put the generated code in a separate project, make a jar with it, include the jar ... and then close the project so you don't see the warnings anymore.
Good ideas but I'd prefer to remove the warnings rather than masking them... Without directly modifying the code.
Joined: Feb 19, 2010
Oh well. In that case, the only thing I can think of is to modify the WSDL2Java source code to generate code that does not result in warnings - but you knew that of course.
Also, I haven't tried this myself, but I am thinking that the generics warnings are there because we are compiling using JDK 1.5. Have you tried compiling the generated code using javac -source 1.4? I don't know if the generated code uses any generics features.
Interesting question, but I can't think of another creative solution. If you come across any ideas or a solution, please do share it.