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 193952 - Lookup annotation processor makes legal source uncompilable
Summary: Lookup annotation processor makes legal source uncompilable
Status: RESOLVED WONTFIX
Alias: None
Product: platform
Classification: Unclassified
Component: Lookup (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-31 18:37 UTC by _ tboudreau
Modified: 2011-01-03 16:35 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2010-12-31 18:37:40 UTC
See attached project - try compiling it as-is first - it will compile fine.  Then try it again with Lookup on the classpath - uncomment the dependency in the pom.xml - compilation fails with

COMPILATION ERROR : 
-------------------------------------------------------------
com/timboudreau/annotationbug/A.java:[51,54] incompatible types
found   : java.lang.Class<com.timboudreau.annotationbug.A.None>
required: java.lang.Class<? extends java.lang.Throwable>
1 error

Seems I am not the first to have this problem, but it is really not nice - I must somehow exclude the annotation processor, or stop using Lookup.

http://maven.40175.n5.nabble.com/Freaking-out-javac-works-maven-compiler-plugin-does-not-td126247.html
https://issues.apache.org/jira/browse/OPENJPA-1659
Comment 1 _ tboudreau 2010-12-31 18:40:29 UTC
It's a javac bug - http://bugs.sun.com/view_bug.do?bug_id=6512707

Workaround is to add <proc>none</proc> to the maven compiler plugin.  I'm sure I won't be the last person to have this problem :-/

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <executions>
                <execution>
                    <id>default-compile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                    <!-- proc none to fix http://bugs.sun.com/view_bug.do?bug_id=6512707 -->
                <proc>none</proc>
                <debug>true</debug>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>    
    </plugins>
</build>
Comment 2 _ tboudreau 2010-12-31 18:42:33 UTC
Since I never attached the source, the trigger is to have an annotation class like this:

public @interface A {
    static class None extends Throwable { private None() {} }
    Class<? extends Throwable> expected() default None.class;
}

With annotation processing enabled, the compiler thinks None.class is not the same type as ? extends Throwable.
Comment 3 Jaroslav Tulach 2011-01-01 20:56:33 UTC
I think Jan knows a workaround and actually if you put openide-filesystems.jar on classpath, your problem may disappear...
Comment 4 Jan Lahoda 2011-01-03 16:35:01 UTC
-proc:none is a fine workaround if no annotation processing is needed. If AP is needed, then the problem can be workarounded using:
http://hg.netbeans.org/main-silver/file/tip/openide.filesystems/src/org/netbeans/modules/openide/filesystems/CleaningAnnotationProcessor.java
http://hg.netbeans.org/main-silver/file/tip/openide.filesystems/src/org/netbeans/modules/openide/filesystems/CleaningAnnotationProcessorImpl.java
(ideally, CAP should be the very last AP to run as it strips the attribution info which the older javacs forget to clean). Using a recent JDK7 javac should probably resolve the problem as well.