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


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

Re: @java.lang.DontOverride

Started bySimon Lewis <simonlewis2001@gmail.com>
First post2014-05-11 11:03 +0200
Last post2014-05-11 11:03 +0200
Articles 1 — 1 participant

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 Simon Lewis <simonlewis2001@gmail.com> - 2014-05-11 11:03 +0200

#28432 — Re: @java.lang.DontOverride

FromSimon Lewis <simonlewis2001@gmail.com>
Date2014-05-11 11:03 +0200
SubjectRe: @java.lang.DontOverride
Message-ID<87bnv47kmn.fsf@gmail.com>
ram@zedat.fu-berlin.de (Stefan Ram) writes:

> 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?

A rare requirement but you could just try and call the superclass method
and catch any exception that results and call your own one.

[toc] | [standalone]


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


csiph-web