who calls a method

2001-10-12 Thread Raphael Mack

Hello,

is there a possibility to find out where a method has been called? 
Something like the information given by an exception.

Thanks,
Rapha
-- 
procreo - Webseitenentwicklung und Individualsoftwarelösungen
 _
/ __  /  _/ __  / ___/  _/ / __  /  procreo GbR
   / /_/ / / / /_/ / /__/ / /  O__/ /_/ /   Kochgasse 1
  / /_/ /_//_/ /_/_/73630 Remshalden
 / /[EMAIL PROTECTED]
/_/  http://www.procreo.de


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Environment

2001-10-12 Thread Raphael Mack

Hello again,

is there a way to read the system-environmentvariables with JAVA?

Thanks a lot,
Rapha
-- 
procreo - Webseitenentwicklung und Individualsoftwarelösungen
 _
/ __  /  _/ __  / ___/  _/ / __  /  procreo GbR
   / /_/ / / / /_/ / /__/ / /  O__/ /_/ /   Kochgasse 1
  / /_/ /_//_/ /_/_/73630 Remshalden
 / /[EMAIL PROTECTED]
/_/  http://www.procreo.de


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: who calls a method

2001-10-12 Thread Sylvain GIL

On Fri, Oct 12, 2001 at 03:08:46PM +0200, Raphael Mack wrote:
> Hello,
> 
> is there a possibility to find out where a method has been called? 
> Something like the information given by an exception.

In the method add a call to Thread.dumpStack(); and you'll see the
calling stack.

regards,
-- 
Sylvain.


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: who calls a method

2001-10-12 Thread Peter Graves

> Hello,
> 
> is there a possibility to find out where a method has been called? 
> Something like the information given by an exception.
> 
> Thanks,
> Rapha

Thread.dumpStack()


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: Environment

2001-10-12 Thread Nathan Meyers

On Fri, Oct 12, 2001 at 05:08:12PM +0200, Raphael Mack wrote:
> Hello again,
> 
> is there a way to read the system-environmentvariables with JAVA?

If you mean the Unix/Linux environment - not without making JNI calls.
If you can make JNI calls, the "getenv()" call will retrieve individual
values and the global "environ" variable (man 5 environ) will let you
find all of them.

Nathan

> 
> Thanks a lot,
> Rapha
> -- 
> procreo - Webseitenentwicklung und Individualsoftwarelösungen
>  _
> / __  /  _/ __  / ___/  _/ / __  /  procreo GbR
>/ /_/ / / / /_/ / /__/ / /  O__/ /_/ /   Kochgasse 1
>   / /_/ /_//_/ /_/_/73630 Remshalden
>  / /[EMAIL PROTECTED]
> /_/  http://www.procreo.de
> 
> 
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> 

-- 


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: who calls a method

2001-10-12 Thread Nathan Meyers

On Fri, Oct 12, 2001 at 03:08:46PM +0200, Raphael Mack wrote:
> Hello,
> 
> is there a possibility to find out where a method has been called? 
> Something like the information given by an exception.

Are you looking for a profiling tool to generate the information, or
do you want to generate the information from within the method itself?
If the latter, something like this will work:

Exception e = new Exception();
e.fillInStackTrace();
e.printStackTrace();

Nathan


> 
> Thanks,
> Rapha
> -- 
> procreo - Webseitenentwicklung und Individualsoftwarelösungen
>  _
> / __  /  _/ __  / ___/  _/ / __  /  procreo GbR
>/ /_/ / / / /_/ / /__/ / /  O__/ /_/ /   Kochgasse 1
>   / /_/ /_//_/ /_/_/73630 Remshalden
>  / /[EMAIL PROTECTED]
> /_/  http://www.procreo.de
> 
> 
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> 

-- 


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: who calls a method

2001-10-12 Thread Avi Cherry

At 8:55 AM -0700 10/12/01, Peter Graves wrote:
>  > is there a possibility to find out where a method has been called? =
>
>>  Something like the information given by an exception.
>>  =
>
>>  Thanks,
>>  Rapha
>
>Thread.dumpStack()

Just to point out, the documentation specifically says:
This method is used only for debugging.

This means to not rely on the output of this in production code. 
Basically, if your code relies on this for its behavior, it's likely 
to break at some point.  Different VMs will give different output 
anyway.


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: who calls a method

2001-10-12 Thread Nathan Meyers

On Fri, Oct 12, 2001 at 10:21:38AM -0700, Avi Cherry wrote:
> At 8:55 AM -0700 10/12/01, Peter Graves wrote:
> >  > is there a possibility to find out where a method has been called? =
> >
> >>  Something like the information given by an exception.
> >>  =
> >
> >>  Thanks,
> >>  Rapha
> >
> >Thread.dumpStack()
> 
> Just to point out, the documentation specifically says:
> This method is used only for debugging.
> 
> This means to not rely on the output of this in production code. 
> Basically, if your code relies on this for its behavior, it's likely 
> to break at some point.  Different VMs will give different output 
> anyway.

Yep... this is good for dumping info to be read by humans. If you want a
data structure usable from software, you'll need to implement a profiler
through the JVMPI interface.

Nathan

> 
> 
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> 

-- 


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: who calls a method

2001-10-12 Thread David Brownell

> Yep... this is good for dumping info to be read by humans. If you want a
> data structure usable from software, you'll need to implement a profiler
> through the JVMPI interface.

OR maybe use those funky new JDK 1.4 APIs I noticed in the vicinity
of the new Exeption.getCause() calls and stack backtrace facility.

- Dave



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: who calls a method

2001-10-12 Thread John R MacMillan

|> Basically, if your code relies on this for its behavior,
|> it's likely to break at some point.  Different VMs will give
|> different output anyway.
|
|Yep... this is good for dumping info to be read by humans. If
|you want a data structure usable from software, you'll need to
|implement a profiler through the JVMPI interface.

The same caveat applies even with the JVMPI stuff; depending on the JVM,
and particular optimizations you've performed you'll find that either
the GetCallTrace interface function, or tracking you do based on
METHOD_ENTRY and METHOD_EXIT events will give you results that may
surprise you.

Eg. either of those may indicate that you were called by foo even though
foo never calls the method directly, if foo calls bar which calls you,
and the JVM inlined bar into foo.

If you really, really have to know who called you, the only failsafe way
I can think of is to make the callers identify themselves when they
call.


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: who calls a method

2001-10-12 Thread Nelson Minar

>> Yep... this is good for dumping info to be read by humans. If you want a
>> data structure usable from software, you'll need to implement a profiler
>> through the JVMPI interface.
>
>OR maybe use those funky new JDK 1.4 APIs I noticed in the vicinity
>of the new Exeption.getCause() calls and stack backtrace facility.

Ah, this would be
  http://java.sun.com/j2se/1.4/docs/api/java/lang/Throwable.html#getStackTrace()

Hooray! This would be great for log4j and other logging packages.

 [EMAIL PROTECTED]
.   .  . ..   .  . . http://www.media.mit.edu/~nelson/


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]