How to get the name of the currently executing method?

Discussion in 'Java' started by Jeff Gaynor, Jun 15, 2004.

  1. Jeff Gaynor

    Jeff Gaynor Guest

    Is there a way to do this? I just want to be able to print out a _quick_
    message for debugging.

    Thanks,

    --j
     
    Jeff Gaynor, Jun 15, 2004
    #1
    1. Advertising

  2. Jeff Gaynor wrote:

    > Is there a way to do this? I just want to be able to print out a _quick_
    > message for debugging.


    System.out.println("nameOfMethod");
    Anything else is neither quick to write nor to execute.
     
    Michael Borgwardt, Jun 15, 2004
    #2
    1. Advertising

  3. Jeff Gaynor

    Roedy Green Guest

    On Tue, 15 Jun 2004 11:39:33 -0500 (CDT), "Jeff Gaynor"
    <> wrote or quoted :

    >Is there a way to do this? I just want to be able to print out a _quick_
    >message for debugging.


    new Throwable().printStackTrace()

    There are even slicker ways if you just want the current method.

    See http://mindprod.com/jgloss/trace.html

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jun 15, 2004
    #3
  4. Jeff Gaynor

    ak Guest

    ak, Jun 15, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Newby

    Access to currently executing Page object

    Chris Newby, Apr 19, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    362
    Matt Berther
    Apr 19, 2005
  2. Stefan
    Replies:
    2
    Views:
    633
    Brock Allen
    Jul 26, 2005
  3. visionset
    Replies:
    4
    Views:
    1,010
    Tor Iver Wilhelmsen
    Apr 13, 2007
  4. Dr. Phillip M. Feldman

    How to find number of line that is currently executing?

    Dr. Phillip M. Feldman, Oct 10, 2009, in forum: Python
    Replies:
    1
    Views:
    326
    ryles
    Oct 10, 2009
  5. Bill Atkins
    Replies:
    1
    Views:
    114
    Stefan Lang
    Aug 9, 2005
Loading...

Share This Page