File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Axis2 Generate without Warnings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis2 Generate without Warnings" Watch "Axis2 Generate without Warnings" New topic
Author

Axis2 Generate without Warnings

Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

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?


My Blog: Down Home Country Coding with Scott Selikoff
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi. Just some ideas...

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.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Good ideas but I'd prefer to remove the warnings rather than masking them... Without directly modifying the code.
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Axis2 Generate without Warnings