Karl: I think Stanley was looking for the method name, not the class name -
I have the same issue, and the only answer
I've found is to put a string in the class that defines the name - doesn't
seem to be a dynamic way of getting the current method name. You can get ALL
method names with reflection, but not just the one you're in now, at least
not without throwing an exception & reading it from the stacktrace.
Anyone knows a better way, I'd be very happy!
Mike
Javacorporate Ltd
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's
> Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On
> Behalf Of Karl
> Roberts
> Sent: Thursday, September 30, 1999 4:50 AM
> To: [EMAIL PROTECTED]
> Subject: Re: A Java question
>
>
> "Wu, Stanley (IM&T)" wrote:
>
> > I need to printout some error messages like "Entering
> Method A", "Exiting
> > Method A" and etc. Instead of hard-coding the method names
> all over the
> > places, I wonder if there is class / method I can call to
> return me the
> > current method I am in?
> >
> > Thanks,
> >
> > Stan
>
> Hi,
>
>
> java.lang.class.getName()
>
> public native String getName()
>
> Returns The fully qualified name of this class or interface.
>
> Description:
>
> This method returns the fully qualified name of the type
> represented by
> this Class object.
>
> If the object represents the class of an array, the
> method returns a
> String that contains as many left square brackets as there are
> dimensions in the array, followed by a code that
> indicates the type of
> element contained in the base array. Consider the following:
>
> (new int [3][4][5]).getClass().getName()
>
> This code returns "[[[I". The codes used to indicate the
> element type are
> as follows:
>
> Code Type
> [ array
> B byte
> C char
> d double
> F float
> I int
> J long
> L fully_qualified_class_name class or interface
> S short
> Z boolean
>
> ______________________________________________________________
> _____________
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
> http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html