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: Stanimir Stamenkov Newsgroups: comp.lang.java.programmer Subject: Re: Create Dynamic Proxy for class instead of interface Date: Sun, 12 Jun 2011 20:42:37 +0300 Organization: A noiseless patient Spider Lines: 21 Message-ID: References: <95ka2uFjg5U1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 12 Jun 2011 17:42:29 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="VdcnnljfizG2LUdZ5iOA6g"; logging-data="30051"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19g3tL5zi2f7rT+ITKagdyP" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20110608 SeaMonkey/2.1 In-Reply-To: <95ka2uFjg5U1@mid.individual.net> X-Face: )>>ChyF_H If you read closely what the Javadoc of ProxyFactory say, you will > notice that you get a _new_ class which is a _subclass_ of the class > that you want to augment. For that you do not need proxy mechanisms. > In fact it is much simpler to inherit the class and make the new > class implement additional interfaces. > [...] > Why do you need to manipulate an existing class? Though I don't know how useful it might be, I've played a bit at implementing the try-with-resources [1] (the easier part) and exception masking Java 7 features using Java 6 facilities. For the later I needed to create proxy exceptions augmented with interface allowing to attach 'suppressed' exceptions information. [1] http://www.oracle.com/technetwork/articles/java/trywithresources-401775.html -- Stanimir