[ 
https://issues.apache.org/jira/browse/GROOVY-11373?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles updated GROOVY-11373:
---------------------------------
    Description: 
Consider the following:
{code:java}
package p;
public class C extends java.util.HashMap {
  public    void setFoo(Object x) {}
  protected void setBar(Object x) {}
            void setBaz(Object x) {}
  private   void setBoo(Object x) {}
}
{code}
{code:groovy}
@groovy.transform.CompileStatic
void test(p.C p_c) {
  p_c.foo = null // works
  p_c.bar = null // SC: Method setBar is protected in p.C
  p_c.baz = null // IllegalAccessError
  p_c.boo = null // SC: Cannot call private method p.C#setBoo from class ...
}
{code}

Prior to GROOVY-11319, each of the non-public references produced error "Cannot 
access method setBxx(java.lang.Object) from class: p.C" -- error improved by 
GROOVY-11223.

Also, replacing "extends HashMap" with either of the following does not yield 
dynamic property semantics -- because "p_c.bxx" is not an implicit-this 
expression (see GROOVY-7996).
{code:java}
  public Object set(String name, Object value) { return null; }
  public Object setProperty(String name, Object value) { return null; }
  public Object propertyMissing(String name, Object value) { return null; }
{code}

  was:
Consider the following:
{code:java}
package p;
public class C extends java.util.HashMap {
  public    void setFoo(Object x) {}
  protected void setBar(Object x) {}
            void setBaz(Object x) {}
  private   void setBoo(Object x) {}
}
{code}
{code:groovy}
@groovy.transform.CompileStatic
void test(p.C p_c) {
  p_c.foo = null // works
  p_c.bar = null // SC: Method setBar is protected in p.C
  p_c.baz = null // IllegalAccessError
  p_c.boo = null // SC: Cannot call private method p.C#setBoo from class ...
}
{code}

Prior to GROOVY-11319, each of the non-public references produced error "Cannot 
access method setBxx(java.lang.Object) from class: p.C" -- error improved by 
GROOVY-11223.

Also, replacing "extends HashMap" with either of the following does not yield 
dynamic property semantics -- because "p_c.bxx" is not an implicit-this 
expression (see GROOVY-7996).
{code:java}
  public Object set(String name, Object value) { return null; }
  public Object setProperty(String name, Object value) { return null; }
{code}


> IllegalAccessError writing package-private property of other-package 
> map-based type
> -----------------------------------------------------------------------------------
>
>                 Key: GROOVY-11373
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11373
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 5.0.0-alpha-8, 4.0.21
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:java}
> package p;
> public class C extends java.util.HashMap {
>   public    void setFoo(Object x) {}
>   protected void setBar(Object x) {}
>             void setBaz(Object x) {}
>   private   void setBoo(Object x) {}
> }
> {code}
> {code:groovy}
> @groovy.transform.CompileStatic
> void test(p.C p_c) {
>   p_c.foo = null // works
>   p_c.bar = null // SC: Method setBar is protected in p.C
>   p_c.baz = null // IllegalAccessError
>   p_c.boo = null // SC: Cannot call private method p.C#setBoo from class ...
> }
> {code}
> Prior to GROOVY-11319, each of the non-public references produced error 
> "Cannot access method setBxx(java.lang.Object) from class: p.C" -- error 
> improved by GROOVY-11223.
> Also, replacing "extends HashMap" with either of the following does not yield 
> dynamic property semantics -- because "p_c.bxx" is not an implicit-this 
> expression (see GROOVY-7996).
> {code:java}
>   public Object set(String name, Object value) { return null; }
>   public Object setProperty(String name, Object value) { return null; }
>   public Object propertyMissing(String name, Object value) { return null; }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to