You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Lucas Gonze <lu...@gonze.com> on 2001/12/13 19:12:36 UTC
visibility modifiers in MailetContext.java
The problem:
The declaration of setAttribute in MailetContext:
package org.apache.mailet;
...
void setAttribute(String name, Object object);
Create a class that implements it with same declarations --
package not.org.apache.mailet;
public MyClass implements MailetContext {
...
void setAttribute(String name, Object object);
Get compiler error:
setAttribute(java.lang.String,java.lang.Object) in not.org.apache.mailet.MyClass
cannot implement setAttribute(java.lang.String,java.lang.Object) in
org.apache.mailet.MailetContext; attempting to assign weaker access privileges;
was public
The fix:
Explicitly declaring access privileges within the Interface definition helps to
prevent this error. Edited MailetContext.java attached. (Based on a CVS
checkout last weekend).
RE: visibility modifiers in MailetContext.java
Posted by Lucas Gonze <lu...@gonze.com>.
> > Which part of "there's no compiler fault involved" didn't you understand?
...
> Could it be the bit when you said "In this case coders will receive a
> slightly baffling compile time error message with regard to changing access
> privileges in an implementing class, which slows down the work of creating a
> Mailet."
Ok, a miscommunication then. I'll plead guilty to misdemeanor tortured syntax.
- Lucas
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: visibility modifiers in MailetContext.java
Posted by Peter Donald <pe...@apache.org>.
On Sat, 15 Dec 2001 08:57, Lucas Gonze wrote:
> Which part of "there's no compiler fault involved" didn't you understand?
Could it be the bit when you said "In this case coders will receive a
slightly baffling compile time error message with regard to changing access
privileges in an implementing class, which slows down the work of creating a
Mailet."
> With regard to this:
> > If you just want public in front of it so you can copy paste then you
> > have zero sympathy from me but if there is a real reason then share it.
>
> I am happy to hear your reasoning. For now there is nothing here but a
> flame.
Hmmmmm.
--
Cheers,
Pete
-----------------------------------------------------------
"Remember, your body is a temple; however, it's also your
dancehall and bowling alley" -- Dharma Montgomery
-----------------------------------------------------------
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: visibility modifiers in MailetContext.java
Posted by Lucas Gonze <lu...@gonze.com>.
Pete -
you said:
> > > Which
> > > compiler is not producing such results?
and I said:
> > There's no compiler fault involved, Pete.
then you said:
> If you have
>
> interface Foo
> {
> void bar();
> }
>
> class FooImpl implements Foo
> {
> public void bar() {}
> }
>
>
> You should not get any warning whatsoever.
Which part of "there's no compiler fault involved" didn't you understand?
With regard to this:
> If you just want public in front of it so you can copy paste then you have
> zero sympathy from me but if there is a real reason then share it.
I am happy to hear your reasoning. For now there is nothing here but a flame.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: visibility modifiers in MailetContext.java
Posted by Peter Donald <pe...@apache.org>.
On Sat, 15 Dec 2001 06:17, Lucas Gonze wrote:
> > Declaring access modifiers on the interface goes against the
> > recomendation of the JLS and should have zero effect on the code. Which
> > compiler is not producing such results?
>
> There's no compiler fault involved, Pete. In this case coders will receive
> a slightly baffling compile time error message with regard to changing
> access privileges in an implementing class, which slows down the work of
> creating a Mailet.
Still have no idea what you are talking about. If you have
interface Foo
{
void bar();
}
class FooImpl implements Foo
{
public void bar() {}
}
You should not get any warning whatsoever. As a matter of fact good compilers
will actually issue warnings if you put a public access specifier in the
interface. If you are not seeing this behaviour then your tools are horribly
broken and not spec compliant.
If you just want public in front of it so you can copy paste then you have
zero sympathy from me but if there is a real reason then share it.
--
Cheers,
Pete
-------------------------------------------------------------
| Egoism is the drug that soothes the pain of stupidity. |
-------------------------------------------------------------
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: visibility modifiers in MailetContext.java
Posted by Lucas Gonze <lu...@gonze.com>.
> Declaring access modifiers on the interface goes against the recomendation of
> the JLS and should have zero effect on the code. Which compiler is not
> producing such results?
There's no compiler fault involved, Pete. In this case coders will receive a slightly baffling compile time error message with regard to changing access privileges in an implementing class, which slows down the work of creating a Mailet.
My feeling is that the style guideline in 9.4 is misleading and tends to create bugs. The reason it is misleading is that the implicit access privilege for a method in a class is different from the implicit access privilege for a method in an interface. In practice, interface declarations are templates for implementing classes. As they should be! Copy, paste, and fill-in is the best way for programmers to avoid transcription errors.
Concurring opinions:
http://groups.google.com/groups?hl=en&selm=35D039B2.E8D18A1F%40eng.delcoelect.com
"I strongly disagree with the style guideline in the second sentence
because I believe it can lead to misunderstandings"
http://www-124.ibm.com/pipermail/jikes/1999-October/001285.html
*** Warning: The lack of the "public" modifier in this context is
misleading and strongly discouraged as a matter of style. This method has
been exposed as public per section 2.13.5 of the VMSpec.
Gil Bracha, one of the Sun spec developers, in email:
I'm inclined to agree, and remove the style guideline in future editions. I
don't particularly agree with the idea of pasting in interfaces as
templates; in my mind this reflects the ludicrously primitive state of
development tools. However, I don't see the need for the JLS to overspecify
things, or mandate a particular style in this case.
best,
Lucas
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: visibility modifiers in MailetContext.java
Posted by Peter Donald <pe...@apache.org>.
On Fri, 14 Dec 2001 05:12, Lucas Gonze wrote:
> Explicitly declaring access privileges within the Interface definition
> helps to prevent this error. Edited MailetContext.java attached. (Based
> on a CVS checkout last weekend).
Declaring access modifiers on the interface goes against the recomendation of
the JLS and should have zero effect on the code. Which compiler is not
producing such results?
--
Cheers,
Pete
*----------------------------------------------------------*
The phrase "computer literate user" really means the person
has been hurt so many times that the scar tissue is thick
enough so he no longer feels the pain.
-- Alan Cooper, The Inmates are Running the Asylum
*----------------------------------------------------------*
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: visibility modifiers in MailetContext.java
Posted by Lucas Gonze <lu...@gonze.com>.
> You're kind of worrying me by trying to reimplement this, but in any case.
understood.
> I agree interfaces that not specifying the access privilege is confusing,
> but I'm seeing it in more and more places (that access privileges on
> interfaces aren't specified). Maybe just something we have to get used to.
Yeah, I've seen it other places also. The key thing, though, is that
unspecified privileges aren't the same as public -- they're relative to the
package.
Not a big deal either way. Just trying to contribute back in exchange for the
assistance I've gotten here.
- Lucas
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: visibility modifiers in MailetContext.java
Posted by Serge Knystautas <se...@lokitech.com>.
You're kind of worrying me by trying to reimplement this, but in any case.
I agree interfaces that not specifying the access privilege is confusing,
but I'm seeing it in more and more places (that access privileges on
interfaces aren't specified). Maybe just something we have to get used to.
Serge Knystautas
Loki Technologies - Unstoppable Websites
http://www.lokitech.com/
----- Original Message -----
From: "Lucas Gonze" <lu...@gonze.com>
To: "James Developers List" <ja...@jakarta.apache.org>
Sent: Thursday, December 13, 2001 1:12 PM
Subject: visibility modifiers in MailetContext.java
> The problem:
>
> The declaration of setAttribute in MailetContext:
> package org.apache.mailet;
> ...
> void setAttribute(String name, Object object);
>
> Create a class that implements it with same declarations --
> package not.org.apache.mailet;
> public MyClass implements MailetContext {
> ...
> void setAttribute(String name, Object object);
>
> Get compiler error:
> setAttribute(java.lang.String,java.lang.Object) in
not.org.apache.mailet.MyClass
> cannot implement setAttribute(java.lang.String,java.lang.Object) in
> org.apache.mailet.MailetContext; attempting to assign weaker access
privileges;
> was public
>
> The fix:
>
> Explicitly declaring access privileges within the Interface definition
helps to
> prevent this error. Edited MailetContext.java attached. (Based on a CVS
> checkout last weekend).
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>