Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: static data for methods... Date: Thu, 10 Oct 2013 15:44:28 +0200 Organization: A noiseless patient Spider Lines: 23 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Injection-Date: Thu, 10 Oct 2013 13:44:32 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="d13404d57b2028fe1900165c7807070a"; logging-data="8402"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jz3PNLDqFi5axNqDosrBm" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 In-Reply-To: Cancel-Lock: sha1:PBH2BENg0/aep8YPCct3AJ2X+k0= Xref: csiph.com comp.lang.java.programmer:26286 On 2013-10-10 15:13, Andreas Leitgeb allegedly wrote: > Daniele Futtorovic wrote: >> On 2013-10-09 16:18, Andreas Leitgeb allegedly wrote: >>> I'm aware that in Java, methods cannot have static data within >>> them. The usual "workaround" is to place static data for a >>> method in static fields of the class. However, I need the >>> static fields lexically separated for the methods. >> Quick Q: is this you trying to be economical while doing a refactoring, >> or you designing a FUBAR'd mess? > > The former is close enough. The latter is its inevitable result. > > PS: I expected this (entirely justified) question would come up. *Shudder*. Anyway, for my two cents, I'd consider two avenues: a static map where the methods pick their fields (perhaps IdentityHashMap) or, if the performance hit is a concern, perhaps a custom annotation and an annotation parser that would inject the fields into the source code pre-compilation (I'm pretty sure that's possible, although I don't remember how exactly). -- DF.