Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: It doesn't like 'super' where ever I put it. Date: Mon, 11 Jun 2012 19:53:35 -0400 Organization: A noiseless patient Spider Lines: 57 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 11 Jun 2012 23:53:36 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="03ebLEozl+tXCe7JS60Feg"; logging-data="2230"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ENE/mf4KmQtZyCfiqlIuB" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120604 Thunderbird/13.0 In-Reply-To: Cancel-Lock: sha1:8bOfws8QxP9E/D0Y6b1ZThQq2DY= Xref: csiph.com comp.lang.java.programmer:15215 On 6/11/2012 6:45 PM, Gavino wrote: > "Robert Klemme" wrote in message > news:a3n43dF3fbU2@mid.individual.net... > On 11.06.2012 20:13, Gavino wrote: >>> It can't because the superclass (JFrame) does not have a constructor without >>> arguments. > >> Also wrong. > >> http://docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html#JFrame() > > My apologies. > I don't know where I got that erroneous idea from, but somehow I've been carrying it > around in my head for the last 12 years. > I should have checked the JavaDocs instead of relying on badly remembered information. > > Now I'm equally confused about the wording of the error message. You are not the only confused person. It might just be clumsy wording: Constructor must call super() or this() before return in method CalcFrame1.()V [...] certainly seems to be complaining about a constructor: That's the first word of the message, and is what one usually sees when a message tries to mention the "name" of a (nameless) constructor. The message *seems* to be saying: "The constructor fails to call super() or this() when it ought to." Instead, what I think it means is "The super() or this() call should be in a constructor, not in a method (where it makes no sense)." One must, however, cut the compiler a certain amount of slack. There's a built-in ambiguity about diagnosing "the" error in erroneous source. All the compiler knows for sure is that the source is wrong; to explain "how" it is wrong, the compiler must guess at what it tried (and failed) to express. That is, there are many possible compilable programs at smaller and larger "edit distances" from the incorrect code at hand, and the compiler has no way to know which was intended. To describe "the error," the compiler must choose one (or a small family) of those nearby candidates and describe how the offered code differs. But it's all guesswork -- even a compilable program may not be what was intended (that's why we debug...). The practical lesson is not to take error messages too literally. Very often the message will highlight the difficulty well enough to prompt you to a facepalm and a fix. But when the message seems at an inexplicable tangent to what you think is going on, the best approach may be to reinterpret "Operand of binary % must be a duodecimal dingle" as "Something's wrong," and read no more into it than that. -- Eric Sosman esosman@ieee-dot-org.invalid