Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28434 > unrolled thread

Re: @java.lang.DontOverride

Started byJoerg Meier <joergmmeier@arcor.de>
First post2014-05-11 11:23 +0200
Last post2014-05-14 11:34 +0200
Articles 5 — 2 participants

Back to article view | Back to comp.lang.java.programmer

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: @java.lang.DontOverride Joerg Meier <joergmmeier@arcor.de> - 2014-05-11 11:23 +0200
    Re: @java.lang.DontOverride Arne Vajhøj <arne@vajhoej.dk> - 2014-05-11 21:41 -0400
      Re: @java.lang.DontOverride Joerg Meier <joergmmeier@arcor.de> - 2014-05-12 18:33 +0200
        Re: @java.lang.DontOverride Arne Vajhøj <arne@vajhoej.dk> - 2014-05-13 20:47 -0400
          Re: @java.lang.DontOverride Joerg Meier <joergmmeier@arcor.de> - 2014-05-14 11:34 +0200

#28434 — Re: @java.lang.DontOverride

FromJoerg Meier <joergmmeier@arcor.de>
Date2014-05-11 11:23 +0200
SubjectRe: @java.lang.DontOverride
Message-ID<12zudaw3npuad.18yyakqa7rmfw$.dlg@40tude.net>
On 11 May 2014 01:16:53 GMT, Stefan Ram wrote:

> class Example extends javax.swing.JComponent
> { public boolean isValid(){ return true; }}

>   I do not want to override any method of JComponent with my method.
>   I just want to add a new method. But now or in future versions of
>   Swing there might be an »isValid« method in JComponent. So I'd like
>   to have a @java.lang.DontOverride annotation with the following
>   meaning: »Aborts compilation if any base class has a non-private
>   method of the same name.« Why do we have @java.lang.Ovverride, but
>   not the opposite? Or have I missed something?

It seems to me like if you simply don't put @Override on this method, then
even if JComponent gets a method with that signature later, you will still
get a compiler warning or error, depending on your configuration.
Basically, all methods not tagged with @Override already are tagged with an
invisible @DontOverride.

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [next] | [standalone]


#28442

FromArne Vajhøj <arne@vajhoej.dk>
Date2014-05-11 21:41 -0400
Message-ID<537026b7$0$295$14726298@news.sunsite.dk>
In reply to#28434
On 5/11/2014 5:23 AM, Joerg Meier wrote:
> On 11 May 2014 01:16:53 GMT, Stefan Ram wrote:
>
>> class Example extends javax.swing.JComponent
>> { public boolean isValid(){ return true; }}
>
>>    I do not want to override any method of JComponent with my method.
>>    I just want to add a new method. But now or in future versions of
>>    Swing there might be an »isValid« method in JComponent. So I'd like
>>    to have a @java.lang.DontOverride annotation with the following
>>    meaning: »Aborts compilation if any base class has a non-private
>>    method of the same name.« Why do we have @java.lang.Ovverride, but
>>    not the opposite? Or have I missed something?
>
> It seems to me like if you simply don't put @Override on this method, then
> even if JComponent gets a method with that signature later, you will still
> get a compiler warning or error, depending on your configuration.
> Basically, all methods not tagged with @Override already are tagged with an
> invisible @DontOverride.

Are you saying that this could be done or that it has been done?

If the latter when what is the configuration to enable this?

Arne

[toc] | [prev] | [next] | [standalone]


#28449

FromJoerg Meier <joergmmeier@arcor.de>
Date2014-05-12 18:33 +0200
Message-ID<gglnx1tnyvjr.ev5wpv4z7d9n$.dlg@40tude.net>
In reply to#28442
On Sun, 11 May 2014 21:41:11 -0400, Arne Vajhøj wrote:

> On 5/11/2014 5:23 AM, Joerg Meier wrote:
>> On 11 May 2014 01:16:53 GMT, Stefan Ram wrote:
>>> class Example extends javax.swing.JComponent
>>> { public boolean isValid(){ return true; }}

>>>    I do not want to override any method of JComponent with my method.
>>>    I just want to add a new method. But now or in future versions of
>>>    Swing there might be an »isValid« method in JComponent. So I'd like
>>>    to have a @java.lang.DontOverride annotation with the following
>>>    meaning: »Aborts compilation if any base class has a non-private
>>>    method of the same name.« Why do we have @java.lang.Ovverride, but
>>>    not the opposite? Or have I missed something?
>> It seems to me like if you simply don't put @Override on this method, then
>> even if JComponent gets a method with that signature later, you will still
>> get a compiler warning or error, depending on your configuration.
>> Basically, all methods not tagged with @Override already are tagged with an
>> invisible @DontOverride.
> Are you saying that this could be done or that it has been done?

> If the latter when what is the configuration to enable this?

It has been done, but it seems to be an Eclipse feature, not a Java
feature, so my bad.

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#28462

FromArne Vajhøj <arne@vajhoej.dk>
Date2014-05-13 20:47 -0400
Message-ID<5372bd2a$0$295$14726298@news.sunsite.dk>
In reply to#28449
On 5/12/2014 12:33 PM, Joerg Meier wrote:
> On Sun, 11 May 2014 21:41:11 -0400, Arne Vajhøj wrote:
>
>> On 5/11/2014 5:23 AM, Joerg Meier wrote:
>>> On 11 May 2014 01:16:53 GMT, Stefan Ram wrote:
>>>> class Example extends javax.swing.JComponent
>>>> { public boolean isValid(){ return true; }}
>
>>>>     I do not want to override any method of JComponent with my method.
>>>>     I just want to add a new method. But now or in future versions of
>>>>     Swing there might be an »isValid« method in JComponent. So I'd like
>>>>     to have a @java.lang.DontOverride annotation with the following
>>>>     meaning: »Aborts compilation if any base class has a non-private
>>>>     method of the same name.« Why do we have @java.lang.Ovverride, but
>>>>     not the opposite? Or have I missed something?
>>> It seems to me like if you simply don't put @Override on this method, then
>>> even if JComponent gets a method with that signature later, you will still
>>> get a compiler warning or error, depending on your configuration.
>>> Basically, all methods not tagged with @Override already are tagged with an
>>> invisible @DontOverride.
>> Are you saying that this could be done or that it has been done?
>
>> If the latter when what is the configuration to enable this?
>
> It has been done, but it seems to be an Eclipse feature, not a Java
> feature, so my bad.

I was not even aware that Eclipse could do that.

I assume it is:
- properties
- java compiler
- errors/warnings
- annotations
- missing @Override annotation
that does the trick.

Arne

[toc] | [prev] | [next] | [standalone]


#28471

FromJoerg Meier <joergmmeier@arcor.de>
Date2014-05-14 11:34 +0200
Message-ID<1p16xhw2u6d9l.1674jnxjqh2qp.dlg@40tude.net>
In reply to#28462
On Tue, 13 May 2014 20:47:35 -0400, Arne Vajhøj wrote:

> I was not even aware that Eclipse could do that.

> I assume it is:
> - properties
> - java compiler
> - errors/warnings
> - annotations
> - missing @Override annotation
> that does the trick.

Yes, that is the one. It correctly produces a warning (or an error, if you
prefer, which I do, since it should be a 2 second fix) when you forget to
use @Override (or if you wire something together where a method overrides
another unintentionally).

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web