Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3010 fix private field visibility
  3. GROOVY-1591

Private Fields Are Accessible From Other Classes

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.0-RC-1
    • None
    • groovy-runtime
    • None

    Description

      If I declare a private field like this...

      Person.groovy
      class Person {
         private firstName
      }
      

      I can still access this field from another class like this...

      Foo.groovy
      class Foo {
         def doIt() {
             def p = new Person(firstName:'Jeff')
             println p.firstName
         }
         static void main(args) {
             new Foo().doIt()
         }
      }
      

      I don't think that I should be able to access p.firstName inside of the Foo class.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              brownj Jeff Brown
              Votes:
              13 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

                Created:
                Updated: