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


Groups > comp.lang.java.programmer > #30352

Re: Accessing super method from inner class?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Knute Johnson <eternal@knutejohnson.com>
Newsgroups comp.lang.java.programmer
Subject Re: Accessing super method from inner class?
Date Thu, 13 Nov 2014 10:01:50 -0800
Organization A noiseless patient Spider
Lines 48
Message-ID <m42rm0$tr0$1@dont-email.me> (permalink)
References <m4126g$bkp$1@dont-email.me> <m416lq$c72$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Thu, 13 Nov 2014 18:01:36 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="aba33539224e5c782fe0c4053f7756fd"; logging-data="30560"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sKrP1sC5Gn+mzsaoTlky+"
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
In-Reply-To <m416lq$c72$1@dont-email.me>
Cancel-Lock sha1:XiADD8lV+vtgqqacZpsnFgEMBpw=
Xref csiph.com comp.lang.java.programmer:30352

Show key headers only | View raw


On 11/12/2014 18:54, Jeff Higgins wrote:
> On 11/12/2014 08:40 PM, Knute Johnson wrote:
>> I've got some code where I am wrapping all the calls to
>> JTextArea.append() in EventQueue.invokeLater().  So I thought I would
>> just extend JTextArea but what I thought was obvious isn't.
>>
>> import java.awt.*;
>> import javax.swing.*;
>>
>> public class KTextArea extends JTextArea {
>>      public KTextArea(String text) {
>>          super(text);
>>      }
>>
>>      public void append(final String str) {
>>          EventQueue.invokeLater(new Runnable() {
>>              public void run() {
>>                  KTextArea.this.super.append(str);
>
> In this context, this means your new Runnable, super means Object,
> and KTextArea.super means JTextArea, and KTextArea.this is undefined.
>
> I think.
>

I think I've answered my own question, from the JLS;

"15.12
Method Invocation Expressions
EXPRESSIONS
500

Suppose that a field access expression T.super.f appears within class C, 
and the immediate superclass of the class denoted by T is a class whose 
fully qualified name is S. If f in S is accessible from C , then 
T.super.f is treated as if it had been the expression this.f in the body 
of class S. Otherwise, a compile-time error occurs."

I'm not sure if that is what you are saying but I think so.  I thought 
that the 'this' was needed to reach the instance but it appears as 
though Class.super.field implies SuperClass.this.field.  I'm curious how 
this is going to work with static fields :-).

Thanks for taking the time to answer.

-- 

Knute Johnson

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Accessing super method from inner class? Knute Johnson <eternal@knutejohnson.com> - 2014-11-12 17:40 -0800
  Re: Accessing super method from inner class? Jeff Higgins <jeff@invalid.invalid> - 2014-11-12 21:54 -0500
    Re: Accessing super method from inner class? Knute Johnson <eternal@knutejohnson.com> - 2014-11-13 10:01 -0800

csiph-web