Skip to Content

Suspected bug in class loading for JDT

Posted in

Hi,

I'm trying out moving our "continuous integration tests" from using ECJ "directly" from ant to using ant4eclipse so I can get the project's warning levels from the eclipse .settings file for jdt. But I've run into something that looks like a bug in ant4eclipse, but I haven't been able to confirm it yet.
I'm using the "latest build" (rev 1921) of ant4eclipse (downloaded yesterday).

I have a project structure where I have a "src" and one "test" directory with mirrored package structures, so my ant build.xml file has separate targets for building these, and test depending on src so it is built after src.

In src, I have the following classes:
src/some/package/Blah.java
src/some/package/blah/SomeClass.java
Which builds fine.

But when I build test, which has:
src/some/package/blah/SomeClassTest.java

Then my ant4eclipse build errors out with:
1. ERROR in C:\project\test\some\package\blah\SomeClassTest.java (at line 9)
package some.package.blah;
^^^^^^^^^^^^^^^^
The package some.package.blah collides with a type

So, it misses out on the case-sensitivity of the class Blah (previously built form src) and the package blah when compiling test. But the same thing works fine when I build using ECJ without ant4eclipse. Note that I'm running on a Windows system right now with their "wonderful" ideas about case insensitive filenames, so I'm guessing it has something to do with the problem.

From browsing around a bit in the source code, I can see that somehow the problem happens under org.ant4eclipse.lib.jdt.ecj.internal.tools.NameEnviromentImpl.findType(...), which is called from ECJ's LookupEnvironment.java (createPackage(..)).
In ECJ's code (looking at the source from ecj-3.6 from the eclipse site), the equivalent call seems to go down into FileSystem.java, which seems to go down into ClasspathDirectory.java, which actually has some code related to case insensitivity in isPackage(). So my guess is that the ant4eclipse code is missing something equivalent, but I'm unable to confirm this as I can't get the debugger running on neither ECJ nor ant4eclipse.

Currently, this is stopping me from starting to use ant4eclipse, so I'd be interested in knowing if this is like a bug and if it something that can be fixed soon-ish. I'm willing to try patches if anyone knows how to fix it. If you think I'm doing something wrong, let me know.

BR,
Chris

Fixed

Hi Chris,

thanks for reporting. Indeed it was a bug in ant4eclipse.

I opened an issue in our jira (http://www.javakontor.org:8080/jira/browse/AE-238).

It's already solved with build http://hudson.nilshartmann.net/job/ant4eclipse/186/

Regards,
Gerd

Works for me

Hi,

I tested the the new build and I can now compile the project I had issues with.

Thanks for the extremely fast support.

BR,
Chris

Please provide an isolated test case

Hi chris,

I can not reproduce your case. Using something like src/some/package/Blah.java and src/some/package/blah/SomeClass.java works perfectly fine for me!

Could you please provide an isolated test case (1-2 projects together with a build file), so that I am able to reproduce your case?

Thanks!

Regards,
Gerd

Testcase

Hi,

thanks for the quick reply.
I have mailed a small testproject to you mail address (which I found in the source files, hope it is accurate) since I didn't know how to attach to this forum.

By the way, the issue is deifnitely Windows-specific, it works on Linux.

Chris