DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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, 01:26 AM
  2. Replies: 0
    Last Post: 02-13-2007, 06:09 PM
  3. Security of dotnet applications
    By Bill McCarthy in forum .NET
    Replies: 29
    Last Post: 01-06-2007, 07:26 PM
  4. Making Java GUI code open source?
    By celendin in forum Java
    Replies: 1
    Last Post: 03-03-2006, 08:13 PM
  5. Replies: 5
    Last Post: 07-19-2001, 01:46 PM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links