AST error: ASTAllocationExpression (NetBeans)
A source code analyzer
Brought to you by:
adangel,
juansotuyo
When running PMD on my source I get quire a few errors
of the form:
com.bleaklow.bollocks.ui.Downloader [1]: Error while
processing com.bleaklow.bollocks.ui.Downloader;
net.sourceforge.pmd.ast.ASTAllocationExpression
during the scan. I have no idea what this mean, but it
looks broken. I'm using NetBeans 4.1
Logged In: YES
user_id=5159
Hi Alan -
Hm, thanks for the report. Could you attach a small code
sample that reproduces this error to this bug?
Also, Radim, I'm assigning this to you just in case you've
seen it before...
Thanks,
Tom
Logged In: YES
user_id=1294929
Here's the source snippet - note that the code is being
built as part of a J2ME project, althought I don't expect
that to be relevant:
package foo;
public class Foo {
public Foo() {
new Runnable() { public void run() {
Foo.this.back(); } };
}
public void back() {
}
}
Logged In: YES
user_id=5159
Sorry, should have asked this the first time around - which
rulesets are you running? If you can narrow it down to one
ruleset, that'd be even better...
Thanks,
tom
Logged In: YES
user_id=1294929
Whatever it comes with, I guess - I've disabled some of the
more obviously broken rules - what exactly do you want me to
provide?
Logged In: YES
user_id=5159
I was thinking that maybe it was only appearing when you
ran, say, the "basic" ruleset:
http://pmd.sourceforge.net/rules/basic.html
or maybe one of the others. But I'm not sure how the
Netbeans plugin displays the ruleset names, so the above
link may not mean much.
That error does ring a bell... but it seems like it was a
while back. Hm, maybe I just better wait for Radim (or
anyone else who's working on NB) to respond...
Yours,
Tom
Logged In: YES
user_id=158233
I can reproduce it and will look into this. Thanks for the
report.
Logged In: YES
user_id=158233
Also it is stupid that the result of the error is a
confusing annotation.
Logged In: YES
user_id=158233
I am reassigning it to Tom. My investigation showed that the
reason is here -
Caused by: java.lang.ClassCastException:
net.sourceforge.pmd.ast.ASTAllocationExpression
at
net.sourceforge.pmd.rules.UnusedFormalParameterRule.visit(UnusedFormalParameterRule.java:20)
Looking at the source of unusedformalparameter it seems like
a problem of this rule. AST viewer shows that
grand-grand-parent of MethodDeclaration belonging to run()
in the anonymous inner class is AllocationExpression and not
an expected ASTClassOrInterfaceDeclaration. I am not sure
why there is no problem when I run PMD directly on this code
(it is only reported if I run with -debug).
However it is still a good idea to provide better exception
handling in NetBeans plugin.
Logged In: YES
user_id=5159
Hi Radim -
Cool, it is fixed in CVS; any chance you could use the
latest build from CVS here:
http://infoether.com/~tom/pmd-3.1.jar
in Netbeans? Or you could wait until 3.2 comes out, which
might not be too long... not sure when though.
Yours,
Tom
Logged In: YES
user_id=5159
Hi Radim -
OK, this should be fixed with 3.2... no need to use an
interim build now.
Good times,
Tom
Logged In: YES
user_id=158233
OK, that's what I prefer too
Logged In: YES
user_id=158233
fixed in PMD 3.2 and thus in pmd-netbeans-1.2 too.