Re: reverse engineering of java code
ram wrote:
hi guys,
iam developing an application which takes input as ".
java/.cpp"[i.e java/cpp source code] and gives output as " classes ,
sub classes,objects,methods"
of that source code.
Java != C++. (Java and C++ are not the same)
Java !< C++. (Java is not a strict subset of C++)
Java !> C++. (Java is not a strict superset of C++)
No code that is capable of handling Java or C+ cannot handle the other
without some (often major) modifications.
can you guys help me out, is there ready made method,
classes ,packages to implement this?.
That said, there are two ways to do this:
1. Go through the JLS 3 and right your own lexer and parser that
manually looks for the class, method, and field (I presume that is what
you meant by 'objects') expressions.
2. Pipe the source code through a Java compiler and parse the resultant
class file for the class, subclasses, fields, and methods.
can you suggest me how to proceed.
hey pls don't comment on simplicity of problem, iam newbie.
Simple, this? You're talking about either implementing a LALR parser or
interfacing a compiler whether through the runtime compiler interface
new to Java 6, the undocumented Java 5 (and older) compiler interface in
tools.jar, or running a subprocess and then parsing a class file (the
spec (chapter 4 of the JVM spec 2 1.5 addendum is only ~ 80 pages long;
Java 6's addendum is another 100 or so pages on that). In short, this is
not a task for a "newbie" to work on.
The best way to proceed is to wet your feet on simpler topics. Roedy has
some pages about simple projects for beginners (see several other
threads for links).
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth