public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Panicz Maciej Godek <godek.maciek@gmail.com>, kawa@sourceware.org
Subject: Re: A protected slot is not accessible in a subclass
Date: Thu, 24 Mar 2022 21:56:04 -0700	[thread overview]
Message-ID: <31ee8d16-0229-3c1a-a11d-2402f4fdffce@bothner.com> (raw)
In-Reply-To: <CAMFYt2Ze+RjNJbyTqVW0WkicXbNQJAFaFw1R-JywtsfGCjmM_A@mail.gmail.com>



On 3/24/22 15:14, Panicz Maciej Godek via Kawa wrote:
> I get the following error:
> 
> slot 'name' in gnu.mapping.Symbol not accessible here
> 
> What are the rules for accessing protected members in Kawa?

The rules are supposed to be the same as in Java
(because those rules are enforced by the JVM).
However, those rules are actually a bit complicated:
https://docs.oracle.com/javase/specs/jls/se11/html/jls-6.html#jls-6.6.2

In this case there is a bug in Kawa. It treats
   (set! name ...)
as equivalent to:
   (set! (this):name ...)
which is fine.

However, there seems to a problem where Kawa thinks (this) has the type Symbol (because that is
where name is defined) rather than class S.  And this violates the rule:

     If the access is by (i) a qualified name of the form ExpressionName.Id or TypeName.Id, or
     (ii) a field access expression of the form Primary.Id, then access to the instance field Id
     is permitted if and only if the qualifying type is S or a subclass of S.

     The qualifying type is the type of the ExpressionName or Primary, or the type denoted by TypeName.

A work-around is to use the field special procedure:

    (set! (field (this) 'name) ...)
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

  reply	other threads:[~2022-03-25  4:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24 22:14 Panicz Maciej Godek
2022-03-25  4:56 ` Per Bothner [this message]
2022-03-25  9:59   ` Panicz Maciej Godek
2022-03-25 18:46     ` Per Bothner
2022-03-25 20:53       ` Panicz Maciej Godek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31ee8d16-0229-3c1a-a11d-2402f4fdffce@bothner.com \
    --to=per@bothner.com \
    --cc=godek.maciek@gmail.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).