From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by sourceware.org (Postfix) with ESMTPS id 0CEDB3858C2C for ; Fri, 25 Mar 2022 09:59:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0CEDB3858C2C Received: by mail-yb1-xb32.google.com with SMTP id o5so13156369ybe.2 for ; Fri, 25 Mar 2022 02:59:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=r3f1iPedJcfYe7xPo3iXFL7Ebtop1elBhQWttle8uz0=; b=yPjHXJFd3mfTKc19An9up5GYGSE2osVLJxbH6/1lu4WGpYzzjHL5ZMRZyG5YTkqixv jZRtsvRcWksiQuLTww/xOa0yTJleRoSkuHRu/Zwhs7NR+OMPnGPIt0727bbm7EwX9T2I CxNTlEx7I4f4PQTV1F2T5/DKd7NVM72Nvcn5/MhkqD+o5o+TXctz3tOWG7w/sZ+1wurm qctKn49CDRCOUJRoG7JnaaErV3uMZiMUCT8s6R+EPPobPdNo6l1hGxdf2lY8tGqRiAgV gEe186iQLPbbuLk8VT7r+omymR94mxO//OFbYR7RUaeLGfHl0th410DuGNwwI/A2EydP aiBQ== X-Gm-Message-State: AOAM531IBr5a1oXHnb3bZog7ifq7lft7AGomA6rt5fXaQEx8r6SeONam 1lg7ew+4CXYvgIrdJ7ohU3o9Wb1vJx7n/AwgzH7EPzFH X-Google-Smtp-Source: ABdhPJzD1HksN2+T54jhP0cRDEP42EQYtwGDD94BfBUltgQ5H/kjtT8XNfhYDPyOCIonyTKYCIKWIYaOua49yuEQgyY= X-Received: by 2002:a25:c385:0:b0:614:d2fd:c9bc with SMTP id t127-20020a25c385000000b00614d2fdc9bcmr8954089ybf.270.1648202378364; Fri, 25 Mar 2022 02:59:38 -0700 (PDT) MIME-Version: 1.0 References: <31ee8d16-0229-3c1a-a11d-2402f4fdffce@bothner.com> In-Reply-To: <31ee8d16-0229-3c1a-a11d-2402f4fdffce@bothner.com> From: Panicz Maciej Godek Date: Fri, 25 Mar 2022 10:59:29 +0100 Message-ID: Subject: Re: A protected slot is not accessible in a subclass To: Per Bothner Cc: kawa@sourceware.org X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: kawa@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Kawa mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2022 09:59:41 -0000 Thanks for the reply! I tried this: (define-simple-class S (gnu.mapping.Symbol) ((*init*) (invoke-special gnu.mapping.Symbol (this) '*init* (("foo":toString):intern) gnu.mapping.Namespace:EmptyNamespace) (set! (field (this) 'name) (("bar":toString):intern)))) (define s::S(S)) but it gives a similar error: java.lang.RuntimeException: no such field name in S at gnu.kawa.reflect.SlotSet.apply(SlotSet.java:115) at gnu.kawa.reflect.SlotSet.apply3(SlotSet.java:120) at S.(tty:14) I also tried replacing (field (this) 'name) with (field (as gnu.mapping.Symbol (this) 'name) but it didn't change anything. Outside the setter context, (field (this) 'name) works fine. BTW my previous message contained an error - instead of (invoke-special gnu.mapping.Symbol (("foo":toString):intern) gnu.mapping.Namespace:EmptyNamespace) I should of course have written (invoke-special gnu.mapping.Symbol (this) '*init* (("foo":toString):intern) gnu.mapping.Namespace:EmptyNamespace) I mistakenly omitted it while I was writing the message. pt., 25 mar 2022, 05:56 u=C5=BCytkownik Per Bothner napis= a=C5=82: > > 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 t= o > the instance field Id > is permitted if and only if the qualifying type is S or a subclass o= f > 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) ...) >