groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lóránt Pintér (JIRA) <>
Subject [jira] [Created] (GROOVY-8732) @CompileStatic allows access to private
Date Mon, 06 Aug 2018 12:27:00 GMT
Lóránt Pintér created GROOVY-8732:

             Summary: @CompileStatic allows access to private 
                 Key: GROOVY-8732
             Project: Groovy
          Issue Type: Bug
          Components: Static compilation
    Affects Versions: 2.5.1, 3.0.0-alpha-3, 2.6.0-alpha-4, 2.4.15
            Reporter: Lóránt Pintér

import groovy.transform.CompileStatic

interface Thing {
    void call()

class ThingImpl implements Thing {
    void call() {}

class Parent {
    private final ThingImpl thing

    public Thing getThing() { null }

class Child extends Parent {
    public void doSomething() {

Compile via: {{groovyc Example.groovy}}.

The line {{}} in {{Child.doSomething()}} calls {{getThing()}}, but then ends up
referring to the returned value according to the private field's type from {{Parent}} ({{ThingImpl}})
instead of the actual returned type ({{Thing}}). The private field from {{Parent}} (or its
type) should not be visible to {{Child}} at all.

  public void doSomething();
    descriptor: ()V
    flags: (0x0001) ACC_PUBLIC
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokevirtual #20                 // Method Parent.getThing:()LThing;
         4: checkcast     #22                 // class ThingImpl
         7: invokevirtual #25                 // Method
        10: aconst_null
        11: pop
        12: return

This is causing now problems for Gradle plugins compiled against Grade 4.9 or before trying
to run on Gradle 4.9, because we've made a change to an internal type (`ProjectInternal`)
that ended up being referred to via this bug in compiled and released code. See

This message was sent by Atlassian JIRA

View raw message