From owner-freebsd-java Fri Jun 16 13:31:50 2000 Delivered-To: freebsd-java@freebsd.org Received: from lodge.guild.ab.ca (lodge.guild.ab.ca [209.91.118.66]) by hub.freebsd.org (Postfix) with ESMTP id 31F9837B534 for ; Fri, 16 Jun 2000 13:31:47 -0700 (PDT) (envelope-from davidc@lodge.guild.ab.ca) Received: (from davidc@localhost) by lodge.guild.ab.ca (8.9.3/8.9.3) id OAA41777 for freebsd-java@freebsd.org; Fri, 16 Jun 2000 14:31:41 -0600 (MDT) (envelope-from davidc) Date: Fri, 16 Jun 2000 14:31:41 -0600 From: Chad David To: freebsd-java@freebsd.org Subject: Is this possible... Message-ID: <20000616143141.A41759@lodge.guild.ab.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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