Skip to main content



      Home
Home » Newcomers » Newcomers » annotation processor not working.
annotation processor not working. [message #261267] Wed, 16 July 2008 13:01 Go to next message
Eclipse UserFriend
Hi all,

I've read several threads on this topic.

Here's my situation:

I upgraded to 3.4 this morning in order to see if it solve the problem I
had with Europa. No change.

I am running off of OS X and am using the Java6 pre-release. My
processor works from javac and doesn't use any of the Sun proprietary
APIs. Can't anyway. It's not part of the Mac port apparently.

The processor generates code, but isn't invoked at all from Eclipse. No
errors, warnings or what not. I still may have some mistake. However,
the processor shows up in the compiler settings dialogs.

I figure wrapping it up into a plugin is the only viable solution. I am
hoping Mr Harley can give me a heads up.

I had tried the tutorials, but Eclipse crashed. I abandoned the tuts and
developed the processor by calling the compiler from a test program.
:) A bit of grubbing around revealed the secret incantation to make the
processor work from a jar file for 1.5 and 1.6. Most tutorials don't
cover this detail. :/

Any help is appreciated.
Re: annotation processor not working. [message #261274 is a reply to message #261267] Wed, 16 July 2008 13:36 Go to previous messageGo to next message
Eclipse UserFriend
Julia Smith a écrit :
> Any help is appreciated.
If you can provide a test case with steps to reproduce, I encourage you
to submit a bug report against JDT/APT.
--
Olivier
Re: annotation processor not working. [message #261302 is a reply to message #261274] Wed, 16 July 2008 17:53 Go to previous messageGo to next message
Eclipse UserFriend
Olivier Thomann wrote:
> Julia Smith a écrit :
>> Any help is appreciated.
> If you can provide a test case with steps to reproduce, I encourage you
> to submit a bug report against JDT/APT.
> --
> Olivier

I would like to provide a test case, but I'm at a loss how to go about
it. The jar file works when invoked from the command line java 6 version
of javac. Java6 support on 10.5 is limited to the published annotation
APIs so I can have no issue referencing Sun internal APIs.

Project configuration finds the processor without any issue, as the
advanced tab shows the processor class. Editing a source file to include
erroneous applications of my annotations does not generate processor
errors, when the file is saved, which is the first indication nothing is
operating. The second clue is that a correct application of annotations
fails to produce generated code.

No errors or warnings are issued in the status tab.

So if there are particulars you can offer that would help me, such as
turning on magical internal debugging flags and what not, I'll be glad
to try them out.

Alternately if somebody could point me to a known working processor jar
file, I can try it and see if I have the same issue.

There are outside possibilities for me to consider:

1) The upgrade from Europa to Ganymede has produced problems interfering
with stuff.
2) Installed plugins are interfering with stuff.
3) The project is referencing outdated version of the jar file, even if
other aspects of the project sees the correct version.
Re: annotation processor not working. [message #261306 is a reply to message #261302] Wed, 16 July 2008 18:27 Go to previous messageGo to next message
Eclipse UserFriend
Julia Smith wrote:
> Olivier Thomann wrote:
>> Julia Smith a écrit :
>>> Any help is appreciated.
>> If you can provide a test case with steps to reproduce, I encourage
>> you to submit a bug report against JDT/APT.
>> --
>> Olivier
>
> I would like to provide a test case, but I'm at a loss how to go about
> it. The jar file works when invoked from the command line java 6 version
> of javac. Java6 support on 10.5 is limited to the published annotation
> APIs so I can have no issue referencing Sun internal APIs.

I've had to back out of Ganymede. SVN support isn't working.
Re: annotation processor not working. [message #261495 is a reply to message #261306] Sat, 19 July 2008 02:43 Go to previous messageGo to next message
Eclipse UserFriend
"Julia Smith" <invisiblesun@mac.com> wrote in message
news:g5lsk6$p81$1@build.eclipse.org...
> I've had to back out of Ganymede. SVN support isn't working.

Europa also supports Java 6 annotation processing, though not as thoroughly
as Ganymede.

I'm afraid I'll be somewhat incommunicado for the next few days, as I have
some travel coming up. I'll try to do what I can to support you. Olivier
is also quite familiar with the internals of the compiler and the annotation
processing implementation and may be able to help.

If your processor is getting recognized by the factory path dialog, but is
not being executed, it may be throwing an uncaught exception during
processing, perhaps due to a bug or unimplemented method in our APT
implementation. Is there anything showing up in the error log? Are you
able to step through it in the debugger?

There's a tutorial on working with APT that I and some coworkers gave at
EclipseCon 2007: http://www.eclipsecon.org/2007/index.php?page=sub/&id=36 18
.. The tutorial presentation is linked from there, and may possibly be of
some help. It focuses mainly on Java 5 processing, but there are working
examples of Java 6 processors.

Do make sure that you are running on a Java 6 JRE, or else your processor
will be recognized but not executed. Perhaps that's the issue here? I
don't know much about Java 6 support on the Mac, though I'm about to switch
to using a Mac myself and I'm sure I'll quickly find out more :-)

-Walter Harley
JDT APT lead
Re: annotation processor not working. [message #261647 is a reply to message #261495] Mon, 21 July 2008 19:25 Go to previous messageGo to next message
Eclipse UserFriend
Walter Harley wrote:


>It focuses mainly on Java 5 processing, but there are working
>examples of Java 6 processors.
> ...
>Is there anything showing up in the error log? Are you
>able to step through it in the debugger?


I started with the tutorial. The biggest problem I had is it seemed
debugging the target had it's own bugs. I ended up abandoning tutorial
simply to speed up development. I just created a project that invoked
the compiler programmatically.

In order to get things working from a jar file, I stumbled around to
find out what to package in the jar file (files in the services
directory) to get the processor to work and it's a bit annoying that the
package names change isn't well documented (by Sun).

As far as using the annotation processor from Eclipse I've found the
following:

1) No amount of playing around with the annotation processing @ 1.6 works.

2) I've tried exporting to an ant build. I can make _this_ run from the
command line by setting the build.compiler to javac1.6. Apparently, even
if the project is set to 1.6, the export doesn't bother to configure the
build file correctly.

An ant build doesn't take inside Eclipse, because, when added as an ant
builder, compilation fails on the unknown 1.6 target. Again the
compliance level is 1.6 and the JRE is 1.6.

3) I went through the hassle of creating a dirt simple processor whose
only job is to spit out an error. A test case that should be so simple
an exception should not happen. No errors are produced. Not on a clean.
Not on a build project. Nada.

Errata: If 1.6 is supported it seems to me you don't need a dialog to
specify the processor since the compiler is supposed to find it from jar
files.

> Do make sure that you are running on a Java 6 JRE, or else your processor
> will be recognized but not executed. Perhaps that's the issue here? I
> don't know much about Java 6 support on the Mac, though I'm about to switch
> to using a Mac myself and I'm sure I'll quickly find out more :-)
>
If I can return the favor and offer help, I'll try. About the only trick
is getting the developer download and remembering where Apple puts the
vm versions. You also won't get any of Sun's internal compiler APIs that
let you play with more of the parse tree.


------------

OK now i am really frustrated. I spent a good hour or two putting
together a proper test case and went on to the bug submission tool.

There is no way to post a set of test case files (sources/outputs). And
submission fails. I guess it doesn't want anonymous postings. I click
finish in the submit dialog and it just pops back. Cute.


Turning to the create account, the bug report is gone because I closed
the create new account tab.

Eclipse is _not_ making my day here.

The GUI bloopers are rather numerous.
Re: annotation processor not working. [message #261978 is a reply to message #261647] Sat, 26 July 2008 18:12 Go to previous messageGo to next message
Eclipse UserFriend
"Julia Smith" <invisiblesun@mac.com> wrote in message
news:g635ua$o9j$1@build.eclipse.org...
> 1) No amount of playing around with the annotation processing @ 1.6 works.

The feature itself does work; e.g., the nightly automated tests pass, on
Mac, Windows, and Linux, against 1.6 processing in both the IDE and command
line implementations.

I understand that it is not yet working for you, and I understand that's
quite frustrating; I sympathize. There are a lot of variables here, very
little room for error, and not much help for when errors do occur.

I saw you submitted a bug report; I'll try to check that out this weekend
(sorry for the slow response, I've been traveling and have not had access to
any of my Eclipse accounts).


> 3) I went through the hassle of creating a dirt simple processor whose
> only job is to spit out an error. A test case that should be so simple an
> exception should not happen. No errors are produced. Not on a clean. Not
> on a build project. Nada.

So, it seems that the annotation processing feature may not be getting
loaded at all. If you're running at the command line, possibly you have the
wrong runtime classpath; are you executing against ecj.jar, or against the
jdt.core jar? APT is not part of the jdt.core jar. If in the IDE, are you
certain that Eclipse is running with a 1.6 JRE? Sorry if you already
mentioned that and I've forgotten.


> Errata: If 1.6 is supported it seems to me you don't need a dialog to
> specify the processor since the compiler is supposed to find it from jar
> files.

Which jar files?

In javac 1.6, if you don't specify a -processorPath, you're right, it will
fall back to looking for processors on the. Personally I think this is a
source of confusion, since it muddles together the runtime classpath of the
compiler with the compile-time classpath of the code being compiled. These
are distinct concepts, even though there can be some overlap (e.g., at one
extreme java.lang.* will be in both classpaths, and on the other extreme you
may choose to have annotation types be in both classpaths).

The behavior of the Sun 'apt' command line tool, which supported 1.5
processors, was somewhat different than javac 1.6. The Eclipse command-line
(ecj.jar) implementation behaves the same as javac 1.6 does. The Eclipse
IDE config GUI supports both 1.5 and 1.6 processors, so there is no direct
analogy to any particular command-line tool. Perhaps I should have made it
fall back to the Java Build Path for 1.6 processors; in general I've opted
to make the behavior more explicit, to err on the side of conservatism
rather than producing unexpected behavior.


> There is no way to post a set of test case files (sources/outputs). And
> submission fails. I guess it doesn't want anonymous postings. I click
> finish in the submit dialog and it just pops back. Cute.

I see that you did eventually figure it out :-) I'm sorry the learning
curve is so steep! That's certainly one of the problems with Eclipse, and
perhaps with other open-source projects - people tend to focus effort on
their own pain points, and so not much effort gets focused on the things
that affect first-time users. The same is probably true of the web site.

Do feel free to submit a bug report against the web site, too. The Eclipse
webmasters are remarkably responsive given the scale of their task.


Thanks,
-walter
Re: annotation processor not working. [message #261984 is a reply to message #261647] Sun, 27 July 2008 03:53 Go to previous messageGo to next message
Eclipse UserFriend
"Julia Smith" <invisiblesun@mac.com> wrote in message
news:g635ua$o9j$1@build.eclipse.org...
> 3) I went through the hassle of creating a dirt simple processor whose
> only job is to spit out an error. A test case that should be so simple an
> exception should not happen. No errors are produced. Not on a clean. Not
> on a build project. Nada.


I ran your processor, and looked in the error log (as opposed to the
problems view), and found an exception being thrown by the processor, due to
a difference in how Eclipse and javac interpret the JSR269 spec (we return
an unmodifiable set from a method you're calling; the spec doesn't say
anything about whether it's modifiable or not).

Broadly speaking, we treat annotation processors as if they were part of the
compiler: if the processor throws an exception rather than reporting an
error through the Messager interface, we report that in the error log and
abort processing. This is sometimes confusing to people who are developing
processors, but doing the converse would seem like the wrong way to treat
ordinary users. A processor exception is not a problem with the user's
code, it's a problem with the processor, that is, a problem with the
toolset. It is therefore a good idea, at least during processor
development, to keep an eye on the error log and possibly to wrap the
process() method in a try/catch block that reports exceptions through the
Messager.

When I fix your processor code (by making a copy of the set before modifying
it), it seems to run fine; the expected error is obtained.

It is probably a reasonable enhancement request for the Eclipse
implementation of the method you're calling to return a modifiable set, like
javac apparently does. I hope you'll understand that it is not possible for
us to exactly model all of javac's undocumented behaviors, but we do try to
close the gaps as we discover them. I've updated the Bugzilla entry
accordingly.


Thanks,
-walter
Re: annotation processor not working. [message #262232 is a reply to message #261984] Tue, 29 July 2008 22:15 Go to previous messageGo to next message
Eclipse UserFriend
Walter Harley wrote:

> I hope you'll understand that it is not possible for
> us to exactly model all of javac's undocumented behaviors, but we do try to
> close the gaps as we discover them.

Standards have gray areas. *shrugs* That's engineering.
Re: annotation processor not working. [message #262235 is a reply to message #261978] Tue, 29 July 2008 22:25 Go to previous messageGo to next message
Eclipse UserFriend
Walter Harley wrote:
> "Julia Smith" <invisiblesun@mac.com> wrote in message
> news:g635ua$o9j$1@build.eclipse.org...
>> 1) No amount of playing around with the annotation processing @ 1.6 works.
>
> The feature itself does work; e.g., the nightly automated tests pass, on
> Mac, Windows, and Linux, against 1.6 processing in both the IDE and command
> line implementations.
>
> I understand that it is not yet working for you, and I understand that's
> quite frustrating; I sympathize. There are a lot of variables here, very
> little room for error, and not much help for when errors do occur.

Yeh, it was good to find the error log for Eclipse itself. :)

Logs are a lifeline.

The annoying confusion really came about because of the subtle problems
between javac and eclipse compiling. Without a view into where eclipse
was falling over, things were kind of rough.

>
>> 3) I went through the hassle of creating a dirt simple processor whose
>> only job is to spit out an error. A test case that should be so simple an
>> exception should not happen. No errors are produced. Not on a clean. Not
>> on a build project. Nada.
>
> So, it seems that the annotation processing feature may not be getting
> loaded at all. If you're running at the command line, possibly you have the
> wrong runtime classpath; are you executing against ecj.jar, or against the
> jdt.core jar? APT is not part of the jdt.core jar. If in the IDE, are you
> certain that Eclipse is running with a 1.6 JRE? Sorry if you already
> mentioned that and I've forgotten.
>
>
I'm still at that point. I'm not sure how I can proceed to figure out
what's going on. Operator error. Something exotic, like don't mix Apple
java1.6. Not sure. The IDE is running off of 1.5 -- I could change the
runtime version around, but Apple advises against it, so I have my path
and JAVA_HOME setup to point to the release.

>> Errata: If 1.6 is supported it seems to me you don't need a dialog to
>> specify the processor since the compiler is supposed to find it from jar
>> files.
>
> Which jar files?
Jar files with annotation processing. As you mention they can be found
on the classpath.

>
> In javac 1.6, if you don't specify a -processorPath, you're right, it will
> fall back to looking for processors on the. Personally I think this is a
> source of confusion, since it muddles together the runtime classpath of the
> compiler with the compile-time classpath of the code being compiled. These
> are distinct concepts, even though there can be some overlap (e.g., at one
> extreme java.lang.* will be in both classpaths, and on the other extreme you
> may choose to have annotation types be in both classpaths).
>
> The behavior of the Sun 'apt' command line tool, which supported 1.5
> processors, was somewhat different than javac 1.6. The Eclipse command-line
> (ecj.jar) implementation behaves the same as javac 1.6 does. The Eclipse
> IDE config GUI supports both 1.5 and 1.6 processors, so there is no direct
> analogy to any particular command-line tool. Perhaps I should have made it
> fall back to the Java Build Path for 1.6 processors; in general I've opted
> to make the behavior more explicit, to err on the side of conservatism
> rather than producing unexpected behavior.
>
Well for 1.6 it may also cause confusion. It's a bunch of setup that
isn't needed. However, having a window that shows discovered processors
it a real help because it tells you if the processor has been found.

>
>> There is no way to post a set of test case files (sources/outputs). And
>> submission fails. I guess it doesn't want anonymous postings. I click
>> finish in the submit dialog and it just pops back. Cute.
>

Workflow issues like this really does need a "workflow test open source
project". It's pretty hard to keep everything consistent.
Re: annotation processor not working. [message #262269 is a reply to message #262235] Wed, 30 July 2008 10:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Julia Smith wrote:
> Walter Harley wrote:
>> So, it seems that the annotation processing feature may not be getting
>> loaded at all. If you're running at the command line, possibly you
>> have the wrong runtime classpath; are you executing against ecj.jar,
>> or against the jdt.core jar? APT is not part of the jdt.core jar. If
>> in the IDE, are you certain that Eclipse is running with a 1.6 JRE?
>> Sorry if you already mentioned that and I've forgotten.
>>
>>
> I'm still at that point. I'm not sure how I can proceed to figure out
> what's going on. Operator error. Something exotic, like don't mix Apple
> java1.6. Not sure. The IDE is running off of 1.5 -- I could change the
> runtime version around, but Apple advises against it, so I have my path
> and JAVA_HOME setup to point to the release.

Walter is much more knowledgeable than I about the APT stuff, but I'm
pretty sure that if you run Eclipse in a 1.5 JVM then the APT plugins
will not load; if they aren't loading that would seem to explain the
problems you've had just doing a simple example. I think that is what
Walter was trying to say above.

Hope this helps,
Eric
Re: annotation processor not working. [message #262512 is a reply to message #262269] Tue, 05 August 2008 02:13 Go to previous message
Eclipse UserFriend
"Eric Rizzo" <eclipse-news@rizzoweb.com> wrote in message
news:g6ptm3$vr4$2@build.eclipse.org...
> Walter is much more knowledgeable than I about the APT stuff, but I'm
> pretty sure that if you run Eclipse in a 1.5 JVM then the APT plugins will
> not load; if they aren't loading that would seem to explain the problems
> you've had just doing a simple example. I think that is what Walter was
> trying to say above.

Yes. To be precise, if you run Eclipse in a 1.4 JVM then none of the APT
plugins will load; if you run in a 1.5 JVM then only the 1.5-related plugins
will load, but not the 1.6-related plugsins (which are needed for Java 6
processors).

To run a 1.6 processor (that is, JSR269, aka javax.annotation.processing.*)
you need Eclipse to be running in a 1.6 JVM.

As I mentioned, if I recall correctly the UI shows both 1.5 and 1.6
processors, regardless of whether you're actually running on 1.6 (because
the processor discovery is declarative, it doesn't rely on the APT runtime
interfaces actually being present). It strikes me that it would be useful
if the UI indicated when a processor required 1.6 but Eclipse was not
running on 1.6 (i.e., the processor is not available). I've entered a
feature request, https://bugs.eclipse.org/bugs/show_bug.cgi?id=243119 .

Unfortunately I'm currently with a new employer and (I hope temporarily)
unable to commit Eclipse code so it may be a little while till I can do
anything about this.
Previous Topic:Cannot instal Visual Editor with Eclipse 3.4 (Ganymede)
Next Topic:turn off unnecessary warning
Goto Forum:
  


Current Time: Wed May 14 10:37:01 EDT 2025

Powered by FUDForum. Page generated in 0.09010 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top