You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Paul Philion <ph...@acmerocket.com> on 2000/08/30 19:00:48 UTC

[PATCH] Problem with the new JavaDoc stuff and Jikes

Greetings...

I just grabbed the new JavaDoc changes from CVS and found problems
when using Jikes (version 1.12) to compiler the javadoc task.

The problem arises from the used of the "dir" parameter to the accept
method in the anonymous FileFilter on line 893 of Javadoc.java. I'm
not sure what the spec is (I typically use the behavior of javac), but
javac is okay and jikes is not.

Jikes complains that "dir" is defined a second time (in the definition
of the method). It looks like jikes does not like overriding a local
variable with a parameter to a method in an anonymous inner class. By
simply changing the name of the second "dir" (to "dir1"), both jikes
and javac compile and seem to run fine.

I don't know if this is a problem with jikes or javac. Does anyone
understand the inner class spec well enough to say? I suspect that it
is a problem with jikes, but I don't want to submit a bug (or see if
one has already been submitted) until I know.

In any case, I think we should simply change the name of the parameter
and not worry about it. Here's a patch:

Index: src/main/org/apache/tools/ant/taskdefs/Javadoc.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Jav
adoc.java,v
retrieving revision 1.27
diff -u -r1.27 Javadoc.java
--- src/main/org/apache/tools/ant/taskdefs/Javadoc.java 2000/08/30
14:34:531.27
+++ src/main/org/apache/tools/ant/taskdefs/Javadoc.java 2000/08/30
16:59:06
@@ -890,12 +890,12 @@
        }

        String[] files = dir.list(new FilenameFilter () {
-                       public boolean accept(File dir, String name) {
+                       public boolean accept(File dir1, String name)
{
                                if (name.endsWith(".java")) {
                                        foundJavaFile = true;
                                        return false;
                                }
-                               File d = new File(dir, name);
+                               File d = new File(dir1, name);
                                if (d.isDirectory()) {
                                        return true;
                                }
===================================================================


Re: [PATCH] Problem with the new JavaDoc stuff and Jikes

Posted by Jesse Glick <Je...@netbeans.com>.
Peter Donald wrote:
> > [snip]
> >Jikes complains that "dir" is defined a second time (in the definition
> >of the method). It looks like jikes does not like overriding a local
> >variable with a parameter to a method in an anonymous inner class. By
> >simply changing the name of the second "dir" (to "dir1"), both jikes
> >and javac compile and seem to run fine. [snip]
> 
> I *believe* it is a bug in Javac - one of those non-compliancies it
> exhibits ;P. Inner classes are meant to not shadow all variables in the
> context it is created - but they can only access final versions IIRC

I'm not so sure...pg. 296 of the JLS maintenance draft seems to say
otherwise, and gives an example which compiles and runs with JDK 1.3
Javac but gives a similar error to what was mentioned on this list when
compiled with Jikes. Anyway, the upshot is that to be safe this
construction should be avoided. I'm getting more familiar than I would
like to be with the gamut of Java compiler bugs. :-(

-Jesse

-- 
Jesse Glick   <ma...@netbeans.com>
NetBeans, Open APIs  <http://www.netbeans.org/>
tel (+4202) 3300-9161 Sun Micro x49161 Praha CR

RE: [PATCH] Problem with the new JavaDoc stuff and Jikes

Posted by do...@mad.scientist.com.
On Wed, 30 Aug 2000, Paul Philion wrote:

> That would imply that the Jikes version is in error, wouldn't it? As
> the local variable "dir" was not final, it is not accessible to the
> inner class (where the "dir" parameter is used) and therefore should
> not result in a conflict.

It can not be used - but it is still in namespace and
thus you can't shadow it. One of the reasons I dislike Inner
Classes is all the small semantic intricacies involved. 


RE: [PATCH] Problem with the new JavaDoc stuff and Jikes

Posted by Paul Philion <ph...@acmerocket.com>.
That would imply that the Jikes version is in error, wouldn't it? As
the local variable "dir" was not final, it is not accessible to the
inner class (where the "dir" parameter is used) and therefore should
not result in a conflict.

- Paul Philion

> -----Original Message-----
> From: Peter Donald [mailto:donaldp@mad.scientist.com]
> Sent: Wednesday, August 30, 2000 7:21 PM
> To: ant-dev@jakarta.apache.org
> Subject: Re: [PATCH] Problem with the new JavaDoc stuff and Jikes
>
> I *believe* it is a bug in Javac - one of those non-compliancies it
> exhibits ;P. Inner classes are meant to not shadow all
> variables in the
> context it is created - but they can only access final versions IIRC


Re: [PATCH] Problem with the new JavaDoc stuff and Jikes

Posted by Peter Donald <do...@mad.scientist.com>.
At 01:00  30/8/00 -0400, you wrote:
>Greetings...
>
>I just grabbed the new JavaDoc changes from CVS and found problems
>when using Jikes (version 1.12) to compiler the javadoc task.
>
>The problem arises from the used of the "dir" parameter to the accept
>method in the anonymous FileFilter on line 893 of Javadoc.java. I'm
>not sure what the spec is (I typically use the behavior of javac), but
>javac is okay and jikes is not.
>
>Jikes complains that "dir" is defined a second time (in the definition
>of the method). It looks like jikes does not like overriding a local
>variable with a parameter to a method in an anonymous inner class. By
>simply changing the name of the second "dir" (to "dir1"), both jikes
>and javac compile and seem to run fine.
>
>I don't know if this is a problem with jikes or javac. Does anyone
>understand the inner class spec well enough to say? I suspect that it
>is a problem with jikes, but I don't want to submit a bug (or see if
>one has already been submitted) until I know.

I *believe* it is a bug in Javac - one of those non-compliancies it
exhibits ;P. Inner classes are meant to not shadow all variables in the
context it is created - but they can only access final versions IIRC

Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*