QDox
  1. QDox
  2. QDOX-125

Name resolution of imported nested types does not work correctly

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.8
    • Component/s: None
    • Labels:
      None
    • Testcase included:
      yes
    • Patch Submitted:
      Yes
    • Number of attachments :
      1

      Description

      When while resolving a type "MyType", JavaSource.resolveTypeInternal has an "import my.package.name.MyType", the result is "my.package.name.MyType". This is wrong in cases when name denotes a class, not a package. In this case the result should be "my.package.name$MyType". This is because of line 168:

      if (imports[i].endsWith("." + typeName)) return imports[i];

      Also, "name.MyType" is being resolved to "my.package.name.MyType", which is wrong according to the Java Language Spec (JLS) [1], as one cannot import subpackages.

      The attached patch changes the resolution to follow the JLS. Since one cannot decide if a type "MyType" should be resolved to "my.package.name.MyType" or "my.package.name$MyType" without having the actual classes, some cases where resolution returned a (possibly incorrect) result now return null (see "corrected" test cases).

      [1] http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.5.1

        Activity

        Jochen Kuhnle made changes -
        Field Original Value New Value
        Attachment QDOX-125.patch [ 28202 ]
        Hide
        Paul Hammant added a comment -

        patch applied - thanks.

        Show
        Paul Hammant added a comment - patch applied - thanks.
        Paul Hammant made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Paul Hammant [ paul ]
        Fix Version/s 1.8 [ 14826 ]

          People

          • Assignee:
            Paul Hammant
            Reporter:
            Jochen Kuhnle
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: