This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 152620 - Existence of Processor instance in ${java.class.path} breaks compilation
Summary: Existence of Processor instance in ${java.class.path} breaks compilation
Status: VERIFIED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
: 152353 (view as bug list)
Depends on:
Blocks: 147393
  Show dependency tree
 
Reported: 2008-11-07 08:12 UTC by _ leonchiver
Modified: 2009-02-19 20:14 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Project reproducing the error (13.16 KB, application/x-compressed)
2008-11-07 08:13 UTC, _ leonchiver
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ leonchiver 2008-11-07 08:12:59 UTC
This happens in the latest development build (pulled from mercurial)

Product Version: NetBeans IDE Dev (Build 081106) 
Java: 1.6.0_10; Java HotSpot(TM) Client VM 11.0-b15

It's a compiler error, so the easiest way to reproduce it is  to compile the attached project. In console the project
compiles flawlessly, this also worked with an earlier version of the IDE (about 2 weeks old).
Comment 1 _ leonchiver 2008-11-07 08:13:55 UTC
Created attachment 73422 [details]
Project reproducing the error
Comment 2 Jiri Prox 2008-11-07 12:42:31 UTC
Can you attach some error description, please?
I've opened and compiled the project w/o any problems.
Comment 3 _ leonchiver 2008-11-07 14:33:25 UTC
Here it is. Are you using the latest build? I'm pulling right now from mercurial, maybe the problem was fixed
in the meantime. Will let you know after the update.


Compiling 4 source files to /home/leon/nbprojects/TestAnnotationAndEnum/build/classes
/home/leon/nbprojects/TestAnnotationAndEnum/src/TheAnnotation.java:6: incompatible types
found   : TheEnum
required: TheEnum
    TheEnum enumValue() default TheEnum.RED;
/home/leon/nbprojects/TestAnnotationAndEnum/src/TheAnnotation.java:8: incompatible types
found   : java.lang.Class<InterphaceImpl>
required: java.lang.Class<? extends Interphace>
    Class<? extends Interphace> clazz() default InterphaceImpl.class;
2 errors
BUILD FAILED (total time: 0 seconds)
Comment 4 _ leonchiver 2008-11-07 15:07:36 UTC
So, I've just finished building a fresh IDE, and the error is still here.

Product Version: NetBeans IDE Dev (Build 081107)
Java: 1.6.0_10; Java HotSpot(TM) Client VM 11.0-b15

But like I said: I had an older copy of the IDE (netbeans-golden repository, 10 days old maybe) and this scenario
worked. It also works, when I'm running ant from the command line.
Comment 5 _ leonchiver 2008-11-07 15:14:31 UTC
So, I've found some further interesting information: when I switch the Java Platform to 1.5 I can compile the project.
Switching the platform to 1.6 (which is jdk1.6.0_10) brings this error. I hope you can also reproduce it this way.
Comment 6 Jan Lahoda 2008-11-09 20:51:48 UTC
The root cause for this problem is a javac bug:
http://bugs.sun.com/view_bug.do?bug_id=6512707
http://bugs.sun.com/view_bug.do?bug_id=6558580 (probable duplicate of the first one)

We triggered the bug by adding the annotation processor to openide.util. As openide.util is loaded by the same
classloader (the application classloader) as the javac when running the compiler in non-forking mode (used when building
J2SE Project with default platform), the annotation processor in openide.util is also executed during the compilation.

I guess we will need to workaround this in NetBeans. For J2SE Projects, this could be done by forcing "fork=true" even
for the default platform. But, I am afraid that this may not be enough - the bug will affect all project types that use
ant and javac in non-forking mode (including freeform). So maybe we should come up with a more general workaround (e.g.
moving the annotation processor from openide.util out from the application classpath).
Comment 7 Jesse Glick 2008-11-10 18:48:24 UTC
Let me see if this can be worked around in the Ant module. Forcing fork=true is undesirable.
Comment 8 Jesse Glick 2008-11-10 19:11:58 UTC
I can reproduce, and can easily fix by changing how Ant is run, to not include NB's classes on the classpath (and to
readd tools.jar). However it is a significant if subtle change and I am unsure what the consequences will be. Still
investigating.
Comment 9 Jesse Glick 2008-11-10 21:05:30 UTC
I think I have a fix in core-main #b67c171c7f6a. Unfortunately there is no Issuezilla keyword
DANGER_DANGER_WILL_ROBINSON, for the fix involves partially rewriting 8-year-old code which no one (including myself)
completely understands and which contains numerous fixes for various historical P1-P2 bugs. Seems to work as far as I
can tell on Ubuntu under JDK 5 and 6 with compiling the attached project, running Ant module unit tests, running unit
tests from other modules which involve running Ant, and running and debugging user programs (both in regular IDE mode
and inside commit validation). I'm sure I'm missing some obscure use cases; it is especially difficult to make automated
tests cover ClassLoader-related functionality. I hope someone from QE can help sanity-check.
Comment 10 Quality Engineering 2008-11-11 05:07:21 UTC
Integrated into 'main-golden', will be available in build *200811110201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/b67c171c7f6a
User: Jesse Glick <jglick@netbeans.org>
Log: #152620: due to javac bug, cannot compile certain valid programs using Ant when CP includes ServiceProviderProcessor.
No longer keeping original ${java.class.path} at all. Readding tools.jar to Ant's CP separately (with the exception of JDI).
Comment 11 Jesse Glick 2008-11-24 19:36:58 UTC
*** Issue 152353 has been marked as a duplicate of this issue. ***
Comment 12 Tomas Danek 2008-12-11 18:01:02 UTC
I've sanity-tested ant's functionality on Win XP, no problems found.
Comment 13 Jesse Glick 2008-12-12 03:52:40 UTC
Thanks! I have not heard of any issues since this commit either.
Comment 14 Tomas Danek 2008-12-12 12:28:54 UTC
..so let's mark this verified.