Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-662

Extending HashMap and adding JavaBean properties confuses Groovy

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-beta-6
    • 1.0-JSR-2
    • None
    • None
    • Jdk1.4, OS, Linux.

    Description

      Let's say you have a class like so:

      public class StupidClass extends HashMap
      {
      String myProperty = "Hello";

      public String getMyProperty()

      { return myProperty; }

      }

      If you write, in a groovy script:

      obj = new StupidClass();
      return obj.myProperty;

      It doesn't work - it seems to look in the map for "myProperty", and if it doesn't find it, accepts failure. Instead, I have to write:

      obj = new StupidClass();
      return obj.getMyProperty();

      What I think would be appropriate is for Groovy to check for a javabean property first, and then for the Map key.

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              mstover Michael Stover
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: