From owner-freebsd-java Fri Jun 16 15:49: 7 2000 Delivered-To: freebsd-java@freebsd.org Received: from c187104187.telekabel.chello.nl (c187104187.telekabel.chello.nl [212.187.104.187]) by hub.freebsd.org (Postfix) with SMTP id 5654537BB71 for ; Fri, 16 Jun 2000 15:49:03 -0700 (PDT) (envelope-from ernst@c187104187.telekabel.chello.nl) Received: (qmail 43619 invoked by uid 1000); 16 Jun 2000 22:49:03 -0000 Date: Sat, 17 Jun 2000 00:49:03 +0200 From: Ernst de Haan To: Chad David Cc: freebsd-java@freebsd.org Subject: Re: Is this possible... Message-ID: <20000617004903.B43577@c187104187.telekabel.chello.nl> References: <20000616143141.A41759@lodge.guild.ab.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i 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 Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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