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.
can you guys help me out, is there ready made method,
classes ,packages to implement this?.
can you suggest me how to proceed.
hey pls don't comment on simplicity of problem, iam newbie.
Joshua Cranmer - 21 Aug 2007 16:40 GMT
> 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).

Signature
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
Roedy Green - 22 Aug 2007 09:40 GMT
On Tue, 21 Aug 2007 15:40:31 GMT, Joshua Cranmer
<Pidgeot18@verizon.net> wrote, quoted or indirectly quoted someone who
said :
>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).
see http://mindprod.com/project/projects.html
for project ideas. They are graded by difficulty, financial potential
and how many existing implementations there are.
I find it odd so many people tackle projects where there are over:20
implementations already, e.g. SQL engine, servlet womb, drawing
package, rules engine, xml parser.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Patricia Shanahan - 22 Aug 2007 14:02 GMT
> On Tue, 21 Aug 2007 15:40:31 GMT, Joshua Cranmer
> <Pidgeot18@verizon.net> wrote, quoted or indirectly quoted someone who
[quoted text clipped - 11 lines]
> implementations already, e.g. SQL engine, servlet womb, drawing
> package, rules engine, xml parser.
Deciding whether the task is feasible, and its approximate scope, is a
difficult part of project selection. If there is at least one existing
implementation there is a proof by example that it can be implemented in
no more than N lines of Java for some N.
Patricia
Roedy Green - 23 Aug 2007 01:22 GMT
>Deciding whether the task is feasible, and its approximate scope, is a
>difficult part of project selection. If there is at least one existing
>implementation there is a proof by example that it can be implemented in
>no more than N lines of Java for some N.
Sometimes it is even possible to peak at existing code, or
disassembler it. I still think re-inventing the wheel with only
trivial changes is cowardly and a waste of time. There are SO many
projects out there with no implementations at all or with just utterly
inept implementations. I have listed many of them at
http://mindprod.com/project/projects.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Mike Schilling - 21 Aug 2007 16:50 GMT
> hi guys,
> iam developing an application which takes input as ".
[quoted text clipped - 5 lines]
> can you suggest me how to proceed.
> hey pls don't comment on simplicity of problem, iam newbie.
By far the simplest way to do this is to compile the Java source and use
reflection (see java.lang.reflect) on the result.
Joe Attardi - 21 Aug 2007 16:51 GMT
> hi guys,
> iam developing an application which takes input as ".
[quoted text clipped - 5 lines]
> can you suggest me how to proceed.
> hey pls don't comment on simplicity of problem, iam newbie.
There are already lots of applications that can do this. One such
program is included with the JDK: javap. Although, it's slightly
different in that you run it against .class files instead of .java files.
javap <class name>.
For example, javap java.lang.Object outputs:
Compiled from "Object.java"
public class java.lang.Object{
public java.lang.Object();
public final native java.lang.Class getClass();
public native int hashCode();
public boolean equals(java.lang.Object);
protected native java.lang.Object clone() throws
java.lang.CloneNotSupportedException;
public java.lang.String toString();
public final native void notify();
public final native void notifyAll();
public final native void wait(long) throws
java.lang.InterruptedException;
public final void wait(long, int) throws
java.lang.InterruptedException;
public final void wait() throws java.lang.InterruptedException;
protected void finalize() throws java.lang.Throwable;
static {};
}

Signature
Joe Attardi
jattardi@gmail.com
ram - 22 Aug 2007 05:20 GMT
> > hi guys,
> > iam developing an application which takes input as ".
[quoted text clipped - 38 lines]
> Joe Attardi
> jatta...@gmail.com
thanx a lot for quick and sincere support.
Jeff Higgins - 21 Aug 2007 17:19 GMT
> 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.
Doxygen? <http://www.stack.nl/~dimitri/doxygen/>
> can you guys help me out, is there ready made method,
> classes ,packages to implement this?.
> can you suggest me how to proceed.
> hey pls don't comment on simplicity of problem, iam newbie.
Roedy Green - 22 Aug 2007 05:05 GMT
>hi guys,
> iam developing an application which takes input as ".
[quoted text clipped - 5 lines]
> can you suggest me how to proceed.
>hey pls don't comment on simplicity of problem, iam newbie.
See http://mindprod.com/jgloss/decompiler.html
http://mindprod.com/jgloss/disasssembler.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com