This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes Obtaining method parameter names from compiled class files Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Obtaining method parameter names from compiled class files" Watch "Obtaining method parameter names from compiled class files" New topic
Author

Obtaining method parameter names from compiled class files

Junaid Bhatra
Ranch Hand

Joined: Jun 27, 2000
Posts: 213
For java source compiled with the debug option (-g), the class files contain the method paramter names. However these are not available via Reflection. Does anyone know of a way to get these? Does JavaAssist or BCEL provide such a facility? I had a quick look at JavaAssist API and could not find a way.

I need the paramter names for a custom WSDL creation from Java Source files for Web Services development. I would like the WSDL parameters to be something meaningful rather than generic param1, param2, etc. I know that Web Service engines like Axis do the exact same thing, probably via class file parsing, which I would hate to do on my own.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35426
    
    9
Since you have the Java source files, it might be easier to extract the information from that.

Decompilers like Jode (on SourceForge) obviously can do this. It tmight be worth a look if that capability is accessible through an API.


Android appsImageJ pluginsJava web charts
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Yes, with -g the method parameter names are available. I'm going to bet that this information is available through BCEL - I'd be surprised if not.


Tony Morris
Java Q&A (FAQ, Trivia)
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Obtaining method parameter names from compiled class files
 
Similar Threads
How to retrieve context parameter?
Modifying the bytecode of compiled application w/o the original source code
in-memory compile of java source to bytecode
Automated SOAP Proxy JAR files
Generating and using client code from wsdl file with wsimport