Details
Description
Infinite recursion is possible, if nested class implements interface
like this:
class WrappedInternalContextAdapter implements InternalContextAdapter {
}
( happens in webwork velocity directives )
Bug is in method public String resolveType(String typeName) of JavaClass. ( Inner classes loop )
--%<------
if (innerName.endsWith(typeName)) {
--%<------
Shall be :
--%<--------
if (innerName.endsWith("$" + typeName)) {
--%<------
Maybe mroe elegant solution is possible....
( Line number omitted, because I spiced everything with log statements to track this... )
Merry XMass
Activity
Aslak Hellesøy
made changes -
Field | Original Value | New Value |
---|---|---|
Assignee | Aslak Hellesoy [ rinkrank ] |
Konstantin Pribluda
made changes -
Attachment | test.diff [ 11189 ] |
Konstantin Pribluda
made changes -
Attachment | InfobitDirective.java [ 11194 ] |
Aslak Hellesøy
made changes -
Fix Version/s | 1.4 [ 10304 ] | |
Resolution | Cannot Reproduce [ 5 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Hi Konstantin,
I can't find (or figure out) the source code required to reproduce the bug. The best would be to have a minimal sample source code + some QDox API calls to make it apparent.
I could of course modify line 213 in JavaClass and add the dollar, but I'd really prefer to have a failing testcase to illustrate why this modification is needed.
Could you provide a (failing) test case that looks something like the following?
public void testJiraQdox40() {
{\n" + "// Maybe some more code needed?"; + "}String sourceCode = ""
+ "package foo;\n"
+ "public class WrappedInternalContextAdapter implements InternalContextAdapter
";
JavaDocBuilder builder = new JavaDocBuilder();
builder.addSource(new StringReader(sourceCode));
JavaClass aClass =
builder.getClassByName("foo.WrappedInternalContextAdapter ");
// Perhaps this is what causes the infinite recursion? That's ok. A failing test gives us a clue...
assertNotNull(aClass);
}
It's really simple to write (failing) unit tests for QDox. Try it out See QDox' JavaDocBuilderTest for inspiration.
Cheers,
Aslak