jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • QDox
  • QDOX-14

resolveTypeInternal doesn't work for nested types

  • Log In
  • Views
    • XML
    • Word
    • Printable

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

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

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Aslak Hellesøy added a comment - 31/Jul/03 3:53 AM

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 - 31/Jul/03 3:53 AM 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
Permalink
Piotr Kaminski added a comment - 01/Aug/03 4:15 PM

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 - 01/Aug/03 4:15 PM 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...
Hide
Permalink
Aslak Hellesøy added a comment - 28/Sep/03 4:02 PM

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 - 28/Sep/03 4:02 PM Class names of inner classes are now using $. See last test case in JavaDocBuilderTest. Proper resolution of types remains to be done.
Hide
Permalink
Aslak Hellesøy added a comment - 28/Sep/03 6:29 PM

Fixed

Show
Aslak Hellesøy added a comment - 28/Sep/03 6:29 PM Fixed

People

  • Assignee:
    Aslak Hellesøy
    Reporter:
    Piotr Kaminski
Vote (0)
Watch (0)

Dates

  • Created:
    30/Jul/03 11:52 PM
    Updated:
    28/Sep/03 6:29 PM
    Resolved:
    28/Sep/03 6:29 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.