Thursday, February 10, 2011

groovy language bugs

Hi,

In the Groovy console, the following code executes without error:

class F {
  private def getFoo() {"foo"}
  private def barValue = "bar"
}

def f = new F()
assert f.barValue == "bar"
assert f.properties.containsKey("foo")

This implies that:

  • One can access private members of classes outside the class
  • A class' properties are derived from the private (and public) getter/setter methods

It seems to me that both of these are extremely severe language bugs. Although I really like Groovy, I find it incredible that a language that has been around for a reasonably long time, hasn't implemented something as fundamental as the concept of privacy correctly.

Are these actually bugs or am I missing something?

Thanks, Don

0 comments:

Post a Comment