posted 16 years ago
[Raj Kumar]: So,can i conclude that,there is no solution for that or whatever jammy has told is the maximum possible that can be done.
I would say that what Jammy suggests is probably the most extreme measure you should consider. It's possible to do more than that, but probably a bad idea. Then again, anything other than making the class non-public seems to be a bad idea. If you wanted to do more, despite all advice to the contrary, you could for example use Thread.currentThread().getStackTrace() (or new Throwable().getStackTrace()) to discover what else was in the current stack trace, and throw an exception if you think it necessary. Really, you can do all sorts of preposterous things if you want to. But again, the obvious solution was to simply make the class package-level rather than public to begin with. If you want to create a more convoluted, baroque solution, it's possible, sure. But why do it?
[ November 22, 2007: Message edited by: Jim Yingst ]
"I'm not back." - Bill Harding, Twister