Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-2404

ImportRegistrationResolver uses fqn for genric types, even if not necessary

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 1.1.3.RELEASE
    • Fix Version/s: 1.1.4.RELEASE
    • Component/s: @ CORE
    • Labels:
      None

      Description

      Let's assume, we have an ITD, where we use the following types:

      java.util.List<java.lang.String>
      java.util.List<java.lang.Integer>

      For the first type, the ImportRegistrationResolver sucessfully adds the proper import for java.util.List. So, the type name in the code becomes the short form: List<String>

      But when the second type is resolved, ImportRegistrationResolver.isAdditionLegal() will return false, since both types have the same simple type name (List). Thus, the Javatype java.util.List<java.lang.Integer> is not registered as an import.

      Thus, the long form is used in the generated code: java.util.List<Integer>

      I think a solution to this problem could be not to keep the full JavaTypes in the Set of registered types in ImportRegistrationResolver. Instead, the generic type arguments (and probably also array dimesions and so on) should be stripped off. (Since java.util.List<java.lang.String> , java.util.List<java.lang.Integer>, java.util.List<java.lang.String> [] are all the same import statement java.util.List...)

        Attachments

          Activity

            People

            Assignee:
            stewarta Alan Stewart
            Reporter:
            stefanoc Stefan Ocke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: