Bug 263558 - Can't compile package-info.java from FindBugs with 3.5 Eclipse
Summary: Can't compile package-info.java from FindBugs with 3.5 Eclipse
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 267765 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-03 17:57 EST by Andrey Loskutov CLA
Modified: 2009-03-18 11:06 EDT (History)
4 users (show)

See Also:


Attachments
Problems view (62.42 KB, image/gif)
2009-02-03 17:57 EST, Andrey Loskutov CLA
no flags Details
Proposed patch (4.24 KB, patch)
2009-02-09 15:45 EST, Kent Johnson CLA
no flags Details | Diff
Updated patch and testcase (4.17 KB, patch)
2009-02-11 11:42 EST, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2009-02-03 17:57:15 EST
Created attachment 124616 [details]
Problems view

Build ID: 3.5 M5

Unfortunately I was not able to isolate a small test case, actually I can't understand what't going wrong there...

Steps To Reproduce:
install 3.5 M5 milestone and import "findBugs" project as described below.

The project didn't compile, there are 31 compile errors reported, all of them related to different package-info.java files (see screenshot).

3 error types:

"The attribute value is undefined for the annotation type DefaultAnnotationForParameters"

"edu.umd.cs.findbugs.annotations.NonNull cannot be resolved to a type"

"edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters cannot be resolved to a type"

Of course all of the mentioned classes are compiled and on the classpath (it's a part of the project).

Clean/rebuild/restart/changing compile target from 1.5 to 1.6 didn't help.

Example:
edu.umd.cs.findbugs.ba.type.package-info.java contains this:

###########
@javax.annotation.ParametersAreNonnullByDefault
@edu.umd.cs.findbugs.annotations.DefaultAnnotationForParameters(edu.umd.cs.findbugs.annotations.NonNull.class)
package edu.umd.cs.findbugs.ba.type;
###########

If just "touching" the file by adding a space to it, it compiles. Full project build causes the error appear again.

With 3.4.1 and Sun's javac compilation works fine...

=========================================================
To get findbugs project, just follow this steps (SVN must be installed):

1) Choose [File | Import | SVN | Checkout Projects from SVN]. The import wizard opens.
2) In the wizard, proceed as follows:
   a) Choose [Create a new repository location]. Click [Next]
   b) Enter http://findbugs.googlecode.com/svn as url. Click [Next]
   c) Select 2 children of the <trunk> element (hold CTRL key):
        <trunk>
            |
            +- findbugs
      Click [Next]
   d) Do not change defaults on the next page. Click [Next]
   e) Choose the workspace location for project sources, e.g. D:\Projects\FBWorkspace.
   f) Click [Finish].
   g) Source code will be checked out from SVN. This can take time, especially with the slow internet connection (~10 MB need to be downloaded first time).
Comment 1 Olivier Thomann CLA 2009-02-05 15:39:47 EST
(In reply to comment #0)
>    c) Select 2 children of the <trunk> element (hold CTRL key):
>         <trunk>
>             |
>             +- findbugs
>       Click [Next]
What 2 children ?
findbugs and ?
Comment 2 Andrey Loskutov CLA 2009-02-05 16:21:00 EST
Sorry, it was a "copy and paste" from 

http://code.google.com/p/findbugs/source/browse/trunk/eclipsePlugin/doc/building_findbugsplugin.txt?r=10519

You just need findBugs project, it is self-contained.
Comment 3 Kent Johnson CLA 2009-02-09 15:45:24 EST
Created attachment 125166 [details]
Proposed patch

We cannot resolve all annotations in a package-info.java file until after types know their fields/methods, but we can check for the deprecated annotation.
Comment 4 Kent Johnson CLA 2009-02-11 11:42:12 EST
Created attachment 125407 [details]
Updated patch and testcase
Comment 5 Kent Johnson CLA 2009-02-11 13:03:24 EST
Fix and test released for 3.5M6
Comment 6 Frederic Fusier CLA 2009-03-09 13:46:12 EDT
Verified for 3.5M6 using I20090309-0100: the 'findbugs' project compiles without any error.

(In reply to comment #4)
> Created an attachment (id=125407) [details]
> Updated patch and testcase
> 
The test case released in this patch does concern bug 258906 and not this one. I verified that it passes with or without this bug fix, hence there's currently no regression test for this peculiar issue. However, I do not know if it was possible to write one though.
Comment 7 Kent Johnson CLA 2009-03-18 11:06:59 EDT
*** Bug 267765 has been marked as a duplicate of this bug. ***