Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe05.iad.POSTED!8ad76e89!not-for-mail From: Arved Sandstrom User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Why only public methods on interfaces? References: <25875c94-9af2-4d28-976d-2050a738ae2e@n10g2000yqf.googlegroups.com> In-Reply-To: <25875c94-9af2-4d28-976d-2050a738ae2e@n10g2000yqf.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Lines: 39 Message-ID: X-Complaints-To: abuse@newsgroups-download.com NNTP-Posting-Date: Fri, 08 Apr 2011 00:48:26 UTC Organization: Public Usenet Newsgroup Access Date: Thu, 07 Apr 2011 21:48:23 -0300 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2961 On 11-04-07 09:09 PM, kramer31 wrote: > Could someone please explain to me the rational behind only allowing > public methods on interfaces? In my mind, protection and interfaces > are two independent if perhaps somewhat related concepts. > > For instance, I have an aspect which creates a proxy of a given > interface (which handles transaction propagation). Now in order to > use this aspect, I need an interface (otherwise, no proxy can be > created). However, I have some methods on this class which I would > like to proxy which are public, some are protected, some are package. > Because of this stupid restriction, I have to make all of the methods > public, or do ridiculous things with protection on inner classes. > > There are other examples, too. In fact one could imagine a case where > one would only want protected methods on an interface. > > Yuck, Java, yuck. I can't agree with your take on things here, with all due respect. To me that is what an interface is for - it's the set of public methods that you want an implementing object, including a proxy, to present to the rest of the world. And proxies in Java, by definition, implement a list of interfaces. That's what they are for. Maybe it's just me, but if I wanted an object that implemented public, protected and private methods, I'd construct an instance of a class that defines all those methods. Is there any reason you can't have a class that implements the transaction interface in question? AHS -- That's not the recollection that I recall...All this information is certainly in the hands of the auditor and we certainly await his report to indicate what he deems has occurred. -- Halifax, Nova Scotia mayor Peter Kelly, who is currently deeply in the shit