jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-1327

Closures in a derived class can't access package private fields of the base class in the same package.

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.0-JSR-6
  • Fix Version/s: 3.0
  • Component/s: None
  • Labels:
    None
  • Environment:
    A recent build of 1.0-RC1
  • Testcase included:
    yes

Description

Java:
public class A { String greeting = "Hello" }
Groovy
class B extends A { doGreet = { println greeting } }
new B().doGreet().call()

Both A and B are in the same package.
Code in the closure will throw a MissingPropertyException, as greeting is not accessible but it should be.
Changing this to either protected or public is a workaround.

Attached test cases perform various visibilty tests.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Hide
    Zip Archive
    groovytest.zip
    26/May/06 4:53 PM
    1 kB
    Edward Povazan
    1. Java Source File
      groovytest/ClosureFieldVisibilityBase.java 0.2 kB
    2. File
      groovytest/ClosureFieldVisibilityChild.groovy 0.3 kB
    3. File
      groovytest/ClosureFieldVisibilityTest.groovy 1.0 kB
    Download Zip
    Show
    Zip Archive
    groovytest.zip
    26/May/06 4:53 PM
    1 kB
    Edward Povazan

Issue Links

depends upon

Task - A task that needs to be done. GROOVY-2503 MOP 2.0 design inflluencing issues

  • Major - Major loss of function.
  • Open - The issue is open and ready for the assignee to start work on it.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Paul King added a comment - 18/Apr/08 5:20 PM

Still an issue in trunk

Show
Paul King added a comment - 18/Apr/08 5:20 PM Still an issue in trunk
Hide
Permalink
Andres Almiray added a comment - 20/May/11 10:18 AM

Can be reproduced with 1.8.0

A.java
public class A {
    String name = "Hello";
}
b.groovy
class B extends A {
    def doGreet = { println greeting }
}
new B().doGreet()
Show
Andres Almiray added a comment - 20/May/11 10:18 AM Can be reproduced with 1.8.0
A.java
public class A {
    String name = "Hello";
}
b.groovy
class B extends A {
    def doGreet = { println greeting }
}
new B().doGreet()

People

  • Assignee:
    Unassigned
    Reporter:
    Edward Povazan
Vote (1)
Watch (1)

Dates

  • Created:
    26/May/06 4:53 PM
    Updated:
    20/May/11 10:18 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.