Spring Roo
  1. Spring Roo
  2. ROO-1357

Java keywords are generated for entity type variable names.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1.0.M3
    • Fix Version/s: 1.1.0.RC1
    • Component/s: WEB MVC
    • Labels:
      None

      Description

      When an entity has the same name as a java keyword the variable names used/created by the controller script cause the generated files to be invalid/erroneous.

      ie.
      entity --class ~.products.Package

      will create method signatures on controller aspects which call something like:
      doSomethingWith(Package package)

      this will not compile correctly due to the package keyword being used as a variable.

      I assume that this problem will occur for most java keywords as well as those used by aspectj.

        Issue Links

          Activity

          Hide
          Ben Alex added a comment -

          I'll take a look to verify why it's possible to even create an entity with that name in the first place.

          Show
          Ben Alex added a comment - I'll take a look to verify why it's possible to even create an entity with that name in the first place.
          Hide
          Ben Alex added a comment -

          A type with the name "Package" is level. A type with the name "package" would be illegal due to case sensitivity checking on the reserved word.

          Suggest to Stefan to use org.springframework.roo.model.ReservedWords.RESERVED_JAVA_KEYWORDS.contains(String) to check for the presence of a reserved word in the proposed parameter name before usage. If a reserved word is detected, simply make it unique by appending a parameter index after the word. I've noted this as a requirement in the new Joey infrastructure so we automate this in the future.

          Show
          Ben Alex added a comment - A type with the name "Package" is level. A type with the name "package" would be illegal due to case sensitivity checking on the reserved word. Suggest to Stefan to use org.springframework.roo.model.ReservedWords.RESERVED_JAVA_KEYWORDS.contains(String) to check for the presence of a reserved word in the proposed parameter name before usage. If a reserved word is detected, simply make it unique by appending a parameter index after the word. I've noted this as a requirement in the new Joey infrastructure so we automate this in the future.
          Hide
          Stefan Schmidt added a comment -

          Fixed this with commit d7e27699c8b1c2b289ebffa58866200f1f677684. Indeed it would make sense to put these checks in place on a higher level such as the new JoeyMetadata related infrastructure.

          Show
          Stefan Schmidt added a comment - Fixed this with commit d7e27699c8b1c2b289ebffa58866200f1f677684. Indeed it would make sense to put these checks in place on a higher level such as the new JoeyMetadata related infrastructure.
          Hide
          Chris Phillipson added a comment -

          I'm using the latest Spring Roo package that comes with STS 2.5.0.RELEASE, roo-1.1.0.RELEASE. I have noted that my generated entities using "database reverse engineer" against an MSSQL database still generate entities with Java keywords as member variables (e.g., I have a db table called Properties with two columns: transient and private, these get created as Properties.private and Properties.transient in the Properties_Roo_DbManaged.aj with getters and setters). On a "mvn clean install" I (of course) get compiler complaints.

          Show
          Chris Phillipson added a comment - I'm using the latest Spring Roo package that comes with STS 2.5.0.RELEASE, roo-1.1.0.RELEASE. I have noted that my generated entities using "database reverse engineer" against an MSSQL database still generate entities with Java keywords as member variables (e.g., I have a db table called Properties with two columns: transient and private, these get created as Properties.private and Properties.transient in the Properties_Roo_DbManaged.aj with getters and setters). On a "mvn clean install" I (of course) get compiler complaints.

            People

            • Assignee:
              Stefan Schmidt
              Reporter:
              Benjamin Conlan
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: