Date: Sat, 17 Jun 2000 00:49:03 +0200 From: Ernst de Haan <ernst@jollem.com> To: Chad David <davidc@lodge.guild.ab.ca> Cc: freebsd-java@freebsd.org Subject: Re: Is this possible... Message-ID: <20000617004903.B43577@c187104187.telekabel.chello.nl> In-Reply-To: <20000616143141.A41759@lodge.guild.ab.ca>; from davidc@lodge.guild.ab.ca on Fri, Jun 16, 2000 at 02:31:41PM -0600 References: <20000616143141.A41759@lodge.guild.ab.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Chad, I recall the getBundle() in class java.util.ResourceBundle uses a native method to get the caller from the Java stack. And I assume the new privileged sections in JDK 1.3 use a similar approach. Perhaps you can get your fingers under one of those. Another thing: The log4j project used stack trace parsing in earlier version (0.8.3 or so), I remember that someone suggested removing this functionality, but at least you may find some more info on how to do that, and on the pitfalls. Because there are. The log4j project is at http://www.log4j.org. Sorry I don't know the details, but perhaps it will get you started. Ernst Chad David wrote: > > Does anybody out there have any ideas about how > one might determine the class type of the caller > of a static method from within the static method? > > That is: > > class A { > public void a() { > B.method(); > } > } > > class B { > public static void method() { > String caller = null; > > caller = ... the magic ... > > System.out.println("called by caller : " + caller); > } > } > > > And the println returns A, or A.a(). > > The only way I can think of doing it is: > > new Exception("").printStackTrace(myPrintStream); > > and parse the results... which is an ugly hack that I have > zero confidence will work across JVMs, and this is not > a fast as I would like. (I have a semi-working example > of this if anybody cares). > > Any takers? > > > Thanks > > Chad > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-java" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000617004903.B43577>
