From notifications-return-18621-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Mon Oct 28 04:41:03 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 022B2180630 for ; Mon, 28 Oct 2019 05:41:02 +0100 (CET) Received: (qmail 98935 invoked by uid 500); 28 Oct 2019 04:41:02 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 98923 invoked by uid 99); 28 Oct 2019 04:41:02 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Oct 2019 04:41:02 +0000 Received: from jira-he-de.apache.org (static.172.67.40.188.clients.your-server.de [188.40.67.172]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 077E3E30A4 for ; Mon, 28 Oct 2019 04:41:00 +0000 (UTC) Received: from jira-he-de.apache.org (localhost.localdomain [127.0.0.1]) by jira-he-de.apache.org (ASF Mail Server at jira-he-de.apache.org) with ESMTP id 43475780538 for ; Mon, 28 Oct 2019 04:41:00 +0000 (UTC) Date: Mon, 28 Oct 2019 04:41:00 +0000 (UTC) From: "Daniel Sun (Jira)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GROOVY-9288) Compilation error when accessing a protected/public/package-private super class field from inside a closure MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/GROOVY-9288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16960751#comment-16960751 ] Daniel Sun commented on GROOVY-9288: ------------------------------------ [~emilles] I have reworked the PR based on the latest master. https://github.com/apache/groovy/pull/1048 > Compilation error when accessing a protected/public/package-private super class field from inside a closure > ----------------------------------------------------------------------------------------------------------- > > Key: GROOVY-9288 > URL: https://issues.apache.org/jira/browse/GROOVY-9288 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 2.5.7, 2.5.8, 3.0.0-rc-1 > Reporter: John Bellassai > Priority: Major > Fix For: 2.5.9, 3.0.0-rc-2 > > Time Spent: 2h 50m > Remaining Estimate: 0h > > The following code works fine in 2.5.6 but breaks in 2.5.7 and 2.5.8: > {code:java} > GroovyShell shell = new GroovyShell() > shell.evaluate(''' > package a > > import groovy.transform.CompileStatic > > @CompileStatic > abstract class Abstract_Class { > protected String protectedField = 'field' > > abstract String doThing() > } > assert true''') > shell.evaluate(''' > package b > > import a.Abstract_Class > import groovy.transform.CompileStatic > > @CompileStatic > class ConcreteClass extends Abstract_Class { > > @Override > String doThing() { > 'something'.with { > return protectedField > } > } > } > assert true''') > shell.evaluate("assert new b.ConcreteClass().doThing() == 'field'") > {code} > {noformat} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: > Script2.groovy: 13: Access to a.Abstract_Class#protectedField is forbidden @ line 13, column 32. > return protectedField > ^ > {noformat} > If you change both classes to be in the same package, you get a runtime error like this: > {noformat} > tried to access field a.Abstract_Class.protectedField from class a.ConcreteClass$_doThing_closure1 > java.lang.IllegalAccessError: tried to access field a.Abstract_Class.protectedField from class a.ConcreteClass$_doThing_closure1 > {noformat} -- This message was sent by Atlassian Jira (v8.3.4#803005)