Bug 321866 - annotation classes not found
Summary: annotation classes not found
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.7 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2010-08-05 09:29 EDT by Jeff McAffer CLA
Modified: 2011-04-28 10:03 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff McAffer CLA 2010-08-05 09:29:36 EDT
I have a plugin that has classes in a "foo" folder at the root.  e.g., /foo/org/eclipse/.../Bar.class.  The classes in this area define annotations that are then used in code in other plugins.  The "foo" dir is on the defining bundle's classpath and the package is exported.

The problem is, the annotation references in the other classes do not compile.  Bar.class is not found by the compiler.

Moving the package folder up so it is at the root of the defining plugin seems to fix the problem.

So, it seems that the annotation mechanism is not properly using the classpath of the bundle defining the annotations.

(Note, I put this in JDT though it may turn out to be a PDE topic)
Comment 1 Olivier Thomann CLA 2010-09-03 09:07:17 EDT
A test case would be welcome.
Comment 2 Jeff McAffer CLA 2010-09-03 11:12:59 EDT
Sorry, the code is all proprietary (I don't even have access).  Basically take any class that defines an annotation and put it in a folder rather than at the root of the project.  Then try to reference the annotation.
Comment 3 Olivier Thomann CLA 2010-09-03 11:19:36 EDT
(In reply to comment #2)
> Sorry, the code is all proprietary (I don't even have access).  Basically take
> any class that defines an annotation and put it in a folder rather than at the
> root of the project.  Then try to reference the annotation.
Are you using APT ? Are you simply referencing the annotation inside another class like this?

package p;

import p1.Annot;

@Annot(1)
public class X {
}

where Annot is defined as:
package p1;

public @interface Annot {
   int value() default 0;
}

This works fine. So it must be something else ?
Are you using annotation processors ? If yes, how did you define them ?
Clearly we have a lack of details here that prevents us from investigating this issue.
Comment 4 Jeff McAffer CLA 2010-09-03 11:43:15 EDT
clearly.  Let me see if I can get more detail.
Comment 5 Olivier Thomann CLA 2010-10-15 10:30:31 EDT
Any update on this ?
Comment 6 Jeff McAffer CLA 2010-10-15 23:18:15 EDT
unfortunately not yet but I hope to get back to it in the next week or two.  Sorry for the delay.
Comment 7 Olivier Thomann CLA 2011-01-19 21:33:54 EST
Any update on this ?
Comment 8 Jeff McAffer CLA 2011-01-20 10:39:52 EST
should  have more info next week.  sorry or the delay.
Comment 9 Olivier Thomann CLA 2011-04-08 13:49:05 EDT
This bug is about to be closed as WORKSFORME.
Comment 10 Jeff McAffer CLA 2011-04-15 16:38:48 EDT
Dunno what to say here.  I can reproduce the problem but only with proprietary annotations and code etc.  I tried to distill this out into a standalone test case but no luck.  We are using processors but I really don't know how/when these are hooked in.  I think think the problem is more the annotation themselves not being found.

For example, I have a bundle "annot" that has the annotations and its processor.  There is something whacky about how the annotation lookup is happening. If the bundle is in the workspace as a project and has the annotation in a jar in the bundle then it works, if the annotation types are exploded in the root of the project, then it does not.  By "works" here I mean that types in some other bundle "test" can reference the annotations correctly.  Here I don't think the annotation processors are being used at all.

So, not sure what to do here.  if you want to close this bug, I can reopen when I can supply a real test case.
Thanks for your patience.
Comment 11 Olivier Thomann CLA 2011-04-28 10:02:30 EDT
Closing as WORKSFORME.
Comment 12 Olivier Thomann CLA 2011-04-28 10:03:02 EDT
Verified.

Please reopen if you can provide a test case with which we can work.