QDox
  1. QDox
  2. QDOX-14

resolveTypeInternal doesn't work for nested types

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.3
    • Component/s: Java API
    • Labels:
      None
    • Number of attachments :
      0

      Description

      com.thoughtworks.qdox.model.JavaSource.resolveTypeInternal doesn't respect the type name resolution rules imposed by Java (see http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#106941). In particular, it will fail to resolve unqualified references to nested types that are either within the current parsing scope, or whose outer types have been imported explicitly.

      It also doesn't deal with array types, though arguably that might be somebody else's responsibility.

        Activity

        Hide
        Aslak Hellesøy added a comment -

        Piotr, any chance you could upload a testcase? It's ok if it fails, but a proper testcase makes it easier for us to fix the bug.

        Show
        Aslak Hellesøy added a comment - Piotr, any chance you could upload a testcase? It's ok if it fails, but a proper testcase makes it easier for us to fix the bug.
        Hide
        Piotr Kaminski added a comment -

        Sorry, I don't use that part of the framework and the code is too confusing to write a simple pass/fail JUnit test (I gave it a 15-minute try). But consider this: to load a nested class, you must convert the '.' delimiters between it and its parent classes to '$', and I couldn't find code that does this anywhere within QDox.

        Also, the design for resolving types is wrong. You can't just resolve types at the compilation unit (JavaSource) level since local context matters. Consider:

        package foo;
        class Outer {
        Inner field1;
        class Inner

        { Outer.Inner field2; }

        }

        Both field types should resolve to fully qualified type names foo.Outer.Inner, and be converted to binary type names foo.Outer$Inner for classloading. For field1, QDox lacks the class context to realize that it should be qualified with Outer. For field2, it'll consider it as a fully qualified name, and not add the package prefix.

        You can get into even more complex situations where outer class names have been implicitly or explicitly imported...

        Show
        Piotr Kaminski added a comment - Sorry, I don't use that part of the framework and the code is too confusing to write a simple pass/fail JUnit test (I gave it a 15-minute try). But consider this: to load a nested class, you must convert the '.' delimiters between it and its parent classes to '$', and I couldn't find code that does this anywhere within QDox. Also, the design for resolving types is wrong. You can't just resolve types at the compilation unit (JavaSource) level since local context matters. Consider: package foo; class Outer { Inner field1; class Inner { Outer.Inner field2; } } Both field types should resolve to fully qualified type names foo.Outer.Inner, and be converted to binary type names foo.Outer$Inner for classloading. For field1, QDox lacks the class context to realize that it should be qualified with Outer. For field2, it'll consider it as a fully qualified name, and not add the package prefix. You can get into even more complex situations where outer class names have been implicitly or explicitly imported...
        Aslak Hellesøy made changes -
        Field Original Value New Value
        Status Unassigned [ 1 ] Assigned [ 2 ]
        Assignee Aslak Hellesoy [ rinkrank ]
        Aslak Hellesøy made changes -
        Status Assigned [ 2 ] In Progress [ 3 ]
        Hide
        Aslak Hellesøy added a comment -

        Class names of inner classes are now using $. See last test case in JavaDocBuilderTest. Proper resolution of types remains to be done.

        Show
        Aslak Hellesøy added a comment - Class names of inner classes are now using $. See last test case in JavaDocBuilderTest. Proper resolution of types remains to be done.
        Hide
        Aslak Hellesøy added a comment -

        Fixed

        Show
        Aslak Hellesøy added a comment - Fixed
        Aslak Hellesøy made changes -
        Fix Version/s 1.3 [ 10107 ]
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Closed [ 6 ]

          People

          • Assignee:
            Aslak Hellesøy
            Reporter:
            Piotr Kaminski
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: