1

Suppose we have following method:

1.  public static void main(String args[]) throws Exception {

2.    setUIFont(new javax.swing.plaf.FontUIResource("tahoma", Font.PLAIN, 12));
3.    new Frame();
4.    new Resource();
6.
7.    System.out.println(Integer.MAX_VALUE);
8.    }

As you can see, this method occupied lines 1 through 6. How can I get this list? Assume that I have the reflection class of this method.

Khoda
  • 955
  • 2
  • 14
  • 42
  • Are you looking for something like [this](http://stackoverflow.com/questions/12834887/how-to-get-the-line-number-of-a-method)? – Razib Oct 24 '16 at 11:25
  • Thanks guys, but I need sth runtime. – Khoda Oct 24 '16 at 11:32
  • 2
    In that case, you need access to the source and read this at runtime. The only thing you can get at runtime is the lines in the class provided debugging information was included. – Peter Lawrey Oct 24 '16 at 11:40
  • 2
    Check this http://stackoverflow.com/questions/1928157/how-to-get-surrounding-method-in-java-source-file-for-a-given-line-number – Chandana Kumara Oct 24 '16 at 11:43

0 Answers0