Results 1 to 5 of 5
- 11-24-2008, 07:41 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 2
- Rep Power
- 0
Help: how can get method, arg, return type... from a file .class
This is the first time I visit this forum, and I hope I will receive all bros 's advices.
This is my matter:
I have a problem in taking method, args, return type from a file .class of Java. For example, from this file : A.java
class A
{
public int add(int a, int b);
}
It will be compiled into A.class. I only have file A.class. And i must write java code to create a tool, input is compiled file A.class, output is :
method "add"
arg: "a" (int)
arg: "b" (int)
return: (int)
of courses this is a simple example.
I 've read program translate from file .class to file .java at link :, and this is source code in C++vijaymukhi.com/vmis/jclass.htm. In that program, they read file .class in binary, and translate each byte. But with me, this is so complex :(:(vijaymukhi.com/vmis/source.htm
I want to ask, is there another way to get method, args, ... from file .class without read file .class in binary?
And who can give me some sample of source code to solve this problem?
Thanks for reading and answering a lot.
- 11-24-2008, 09:44 PM #2
Perhaps you would like to clarify how it is that you have the .class files and don't have (and can't obtain) the source code.
Do you have the legal right to reverse engineer those .class files?
- 11-24-2008, 10:28 PM #3
Member
- Join Date
- Nov 2008
- Posts
- 2
- Rep Power
- 0
Thanks for your reply.
Further purpose of me is import detail that i took from .class file into WSDL (Web Services Description Language) - is alike one kind of XML. To write WSDL, i must have information from .class file such as method, argument, return data type,... So that, my work is:
1. Compile file A.java into A.class
2. Take details from A.class
3. Using details from [2] to write WSDL
Because i will group all of 3 steps above into one tool, so that i want to take details from A.class first.
Thanks for reading.
- 11-25-2008, 12:49 AM #4
Senior Member
- Join Date
- Nov 2008
- Posts
- 286
- Rep Power
- 5
Use your IDE/javap?
If you just want the method signatures:
(1) most IDEs will give you this if you load the class file into them;
(2) the 'javap' command-line utility supplied with the JDK will dump out the method signatures of a given class.
To the person who mentioned reverse-engineering-- I think you'd have a hard time argung that reading the method signatures from a .class file was "reverse engineering".Neil Coffey
Javamex - Java tutorials and performance info
- 11-25-2008, 05:53 AM #5
Neil
I think you'd have a hard time arguing that I argued that reading the method signatures from a .class file was "reverse engineering". Or don't you know the difference between a question and an accusation?
I was going to suggest using a decompiler, in case the actual requirement was more than originally stated -- which is often the case, as you'll come to know when you have more experience of reading and responding to forum posts.
cheers, dbLast edited by DarrylBurke; 11-25-2008 at 05:59 AM.
Similar Threads
-
Error: invalid method declaration; return type required
By silvia in forum AWT / SwingReplies: 3Last Post: 06-05-2010, 08:05 PM -
Return value of method
By cachi in forum New To JavaReplies: 1Last Post: 08-01-2007, 08:23 AM -
return type determines override/overload?
By hedefalk in forum Advanced JavaReplies: 4Last Post: 07-11-2007, 01:48 PM -
The return type
By Marcus in forum New To JavaReplies: 1Last Post: 07-05-2007, 06:28 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks