Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Jun 2000 14:31:41 -0600
From:      Chad David <davidc@lodge.guild.ab.ca>
To:        freebsd-java@freebsd.org
Subject:   Is this possible...
Message-ID:  <20000616143141.A41759@lodge.guild.ab.ca>

next in thread | raw e-mail | index | archive | help

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000616143141.A41759>