Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Where am I? Date: Wed, 12 Oct 2011 18:00:47 -0700 Organization: A noiseless patient Spider Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 13 Oct 2011 01:00:54 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="16392"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ArMetC7fGhh53Hz6+AWHCa15rvORVwZ4=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 In-Reply-To: Cancel-Lock: sha1:4Yz4dldqDnVi5m9w+y9q1FKL2ik= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8747 On 10/12/2011 5:04 PM, Roedy Green wrote: > It would be nice for debugging to include the line number of where the > code is when printing out the error message. Is there a simple way to > get it, or do you need to create a Throwable then analyse the > stacktrace? If project coin (the "simple" Java changes project) ever happens again, I would suggest line numbers and method names, at least. Even the old C preprocessor stile macros like __LINE__ would be ok. Just have the compiler interpret that for the line number of the source file. __LINE__ __METHOD__ __CLASS__ __PARAMS__ __CLASS__ for the class name (less urgent due to Clazz.class.getName(), but handy for code templates and such), and __PARAMS__ for an anonymous array of the parameters of a method or constructor. I guess you could add __LOCAL__ and __FIELDS__ for an array of in-scope local variables and fields respectively. It might be desirable to also allow access to the names of parameters, local variables and fields too. Hmm, this got complicated fast. :-)