Java interpretes source code files


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Java interpretes source code files

  1. #1
    Join Date
    Oct 2007
    Posts
    2

    Java interpretes source code files

    Hi all,

    I need to write a program that reads, say, a java source code file and spits out where classes, methods, etc are.

    For example, if input file has the following:

    Code:
    class Game {
      Game(int i) {
        System.out.println("Game constructor");
      }
    }
    
    class BoardGame extends Game {
      BoardGame(int i) {
        super(i);
        System.out.println("BoardGame constructor");
      }
    }
    
    public class Chess extends BoardGame {
      Chess() {
        super(11);
        System.out.println("Chess constructor");
      }
    
      public static void main(String[] args) {
        Chess x = new Chess();
    
      }
    }

    Then program should read and output:

    class found: game
    method found: game(int i)

    class: boardgame
    method found: boardgame(int i)

    etc.

    How can i achieve this?

    Your help would be much appreciated.

    A.

  2. #2
    Join Date
    Oct 2007
    Posts
    1
    I haven't done this my self, but wouldn't the best way be to use reflection? There's an example at http://java.sun.com/developer/techni...ion/index.html

Similar Threads

  1. Replies: 0
    Last Post: 05-08-2007, 02:26 AM
  2. Replies: 0
    Last Post: 02-13-2007, 07:09 PM
  3. Security of dotnet applications
    By Bill McCarthy in forum .NET
    Replies: 29
    Last Post: 01-06-2007, 08:26 PM
  4. Making Java GUI code open source?
    By celendin in forum Java
    Replies: 1
    Last Post: 03-03-2006, 09:13 PM
  5. Replies: 5
    Last Post: 07-19-2001, 02:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center