Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: another error with @Override with another code Date: Sat, 07 Dec 2013 08:44:38 -0500 Organization: A noiseless patient Spider Lines: 52 Message-ID: References: <52a1867c$0$2911$e4fe514c@news2.news.xs4all.nl> <796271a4-11a0-402c-85ff-0f91556c8e7a@googlegroups.com> <06afa354-5858-4359-9e29-6f2b1846e628@googlegroups.com> <33f33be7-61be-411f-9dee-704118dfb44f@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 7 Dec 2013 13:44:38 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="12516"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QcA4DcmYX4rzxiDs0PCh5" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 In-Reply-To: Cancel-Lock: sha1:3OpceCCUXHkmSpP/q78ltNRSQ78= Xref: csiph.com comp.lang.java.programmer:26763 On 12/7/2013 12:26 AM, John B. Matthews wrote: >[...] > I see no error on the platform cited up-thread. You may have > adventitious classes in the classpath. Start with a clean build; failing > that, scrutinize your IDE's cache and your platform's java.ext.dirs. "Adventitious classes" seems to me the most likely cause. To expand and (I hope) explain: Things like `int' and `throw' are built in to the Java compiler, but names like `Runnable' and `MyClass' are not: They are merely names, whose definitions need to be found somewhere. When javac encounters `implements Runnable' it doesn't somehow know you mean `implements java.lang.Runnable', but must deduce your intent by searching for a suitable definition of `Runnable'. The problem (probably) is that javac when javac searches for `Override', it finds some other `Override' before it finds `java.lang.Override'. John B. Matthews already diagnosed one of your other problems; in that one, you had an actual class named `Override'. Well, if the file with that `Override' class is in the same package as the file you're trying to compile, javac will find that `Override' class -- and since the `Override' class is not an `Annotation' (a special kind of `interface'), it complains. Try any of these: 1) Move all your other *.java files out of the current directory and away to a desert island where javac won't find them, then try compiling. 2) Rename your `Override' class to `Overturn' (you may also need to rename the containing file), then try compiling. 3) Change `@Override' to `@java.lang.Override', then try compiling. 4) Add `import java.lang.Override;' at the start of the troublesome source, then try compiling. If I'm right, any of these will fix your problem. In the future, try to avoid reusing names already defined by Java's class library -- especially those in the java and java.lang packages, which are automatically visible to all compilations. There are no reserved names (or almost no reserved names) in Java, but you're just begging for trouble if you redefine them. -- Eric Sosman esosman@comcast-dot-net.invalid