Errors in @AutoValue processing in Eclipse

1,397 views
Skip to first unread message

Dave Borowitz

unread,
Aug 27, 2015, 10:04:11 AM8/27/15
to repo-discuss, David Pursehouse
Following up the discussion on https://gerrit-review.googlesource.com/70409 in a separate thread.

 > However, the Eclipse build has stopped working with:
 > 
 > AutoValue_LabelVote cannot be resolved to a type
 > 
 > in LabelVote.java.
 > 
 > I've bisected it to this commit, but haven't investigated what
 > actually causes it yet.

If do a full clean/rebuild and then look in your error log (Window -> Show View -> Error Log), you should see a series of errors starting with:

Could not write generated class com.google.gerrit...AutoValue_...: javax.annotation.processing.FilerException: Source file already created: /gerrit/.apt_generated/com/google/gerrit/...

This comes from:

An internal mailing list discussion tells me that the linked Eclipse bug was fixed in such a way as to make that workaround insufficient. The problem has to do with the Eclipse batch compiler splitting up calls to the annotation processor if the number of source files in the project exceeds a certain threshold, by default 2000 files. Coincidentally, Gerrit has about 2200 .java presently.

You should be able to increase the batch size of the project by adding the following under -vmargs in your eclipse.ini:

 -DmaxCompiledUnitsAtOnce=10000

I think the reason us Googlers weren't seeing this before is that our internal projects often contain very many class files, to the point where the internal Eclipse package distribution has this property bumped way up by default.


If this workaround works, we at the very least need to document it, but it's still an annoying hassle as part of Eclipse setup. Absent an upstream fix, which doesn't seem to be immediately forthcoming, there's not really a whole lot we can do other than drop AutoValue support entirely. I thought we could maybe have our build scripts try to inspect eclipse.ini, but we have no way of locating the proper Eclipse installation to use.

Dave Borowitz

unread,
Aug 27, 2015, 2:01:53 PM8/27/15
to repo-discuss, David Pursehouse, Terry Parker
A relevant Eclipse bug is:

From the AutoValue team, the specific issue is that human-written code in one batch of source files sent to the compiler may refer to auto-generated code that is not yet generated because it will be generated in the next batch of source files sent to the compiler. It's not guaranteed that this problem will show up as soon as you hit the 2000-file limit, but it increases the likelihood that a batch boundary will happen in the wrong place.

There might be some source-level changes to the way AutoValue is used by callers that would mitigate this problem, but those are mostly speculative at this point. The best recommendation now is still to set that VM flag. Terry points out that you can also set it to 0 to disable batching entirely; I'm assuming without evidence that that would slow things down.

Terry also said he would look into whether this system property can be hoisted into a propject-level config option. At that point we could just set that from tools/eclipse/project.py and not have to tell people to modify eclipse.ini.

David Pursehouse

unread,
Aug 27, 2015, 8:46:51 PM8/27/15
to Dave Borowitz, repo-discuss
On 08/27/2015 11:03 PM, Dave Borowitz wrote:
> Following up the discussion on
> https://gerrit-review.googlesource.com/70409 in a separate thread.
>
> > However, the Eclipse build has stopped working with:
> >
> > AutoValue_LabelVote cannot be resolved to a type
> >
> > in LabelVote.java.
> >
> > I've bisected it to this commit, but haven't investigated what
> > actually causes it yet.
>
> If do a full clean/rebuild and then look in your error log (Window ->
> Show View -> Error Log), you should see a series of errors starting with:
>
> Could not write generated class com.google.gerrit...AutoValue_...:
> javax.annotation.processing.FilerException: Source file already created:
> /gerrit/.apt_generated/com/google/gerrit/...
>

Yes. I didn't have that view open by default; I was only looking at the
console log.

> This comes from:
> https://github.com/google/auto/blob/master/value/src/main/java/com/google/auto/value/processor/AutoValueProcessor.java#L742
>
> An internal mailing list discussion tells me that the linked Eclipse bug
> was fixed in such a way as to make that workaround insufficient. The
> problem has to do with the Eclipse batch compiler splitting up calls to
> the annotation processor if the number of source files in the project
> exceeds a certain threshold, by default 2000 files. Coincidentally,
> Gerrit has about 2200 .java presently.
>
> You should be able to increase the batch size of the project by adding
> the following under -vmargs in your eclipse.ini:
>
> -DmaxCompiledUnitsAtOnce=10000
>

I can confirm that this fixes it for me (Eclipse 4.5 on Ubuntu).


> I think the reason us Googlers weren't seeing this before is that our
> internal projects often contain very many class files, to the point
> where the internal Eclipse package distribution has this property bumped
> way up by default.
>
>
> If this workaround works, we at the very least need to document it, but
> it's still an annoying hassle as part of Eclipse setup.


https://gerrit-review.googlesource.com/70494


> Absent an
> upstream fix, which doesn't seem to be immediately forthcoming, there's
> not really a whole lot we can do other than drop AutoValue support
> entirely.

Adding a line to eclipse.ini is a minor inconvenience and I don't think
it justifies reverting the AutoValue changes.

Dave Borowitz

unread,
Aug 27, 2015, 8:56:30 PM8/27/15
to David Pursehouse, repo-discuss
Nice! Did it also fix the @AutoAnnotation issue?

David Pursehouse

unread,
Aug 27, 2015, 9:03:44 PM8/27/15
to Dave Borowitz, repo-discuss
On 08/28/2015 09:56 AM, 'Dave Borowitz' via Repo and Gerrit Discussion
wrote:
>
>
> On Thu, Aug 27, 2015 at 8:46 PM, David Pursehouse
> <david.pu...@sonymobile.com
Yes, that's what I meant. "Commands: Use @AutoAnnotation" now builds
for me in Eclipse:

https://gerrit-review.googlesource.com/#/c/63540/4

I'm just doing some more tests now, and then I'll set verified on it and
its parent "Update AutoValue to 1.1".

I haven't got around to testing the other case (your GPG refactoring)
but I think it's safe to assume that will also work now.


>
> I think the reason us Googlers weren't seeing this before is
> that our
> internal projects often contain very many class files, to the point
> where the internal Eclipse package distribution has this
> property bumped
> way up by default.
>
>
> If this workaround works, we at the very least need to document
> it, but
> it's still an annoying hassle as part of Eclipse setup.
>
>
>
> https://gerrit-review.googlesource.com/70494
>
>
> > Absent an
>
> upstream fix, which doesn't seem to be immediately forthcoming,
> there's
> not really a whole lot we can do other than drop AutoValue support
> entirely.
>
>
> Adding a line to eclipse.ini is a minor inconvenience and I don't
> think it justifies reverting the AutoValue changes.
>
>
> I thought we could maybe have our build scripts try to inspect
> eclipse.ini, but we have no way of locating the proper Eclipse
> installation to use.
>
>
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to repo-discuss...@googlegroups.com
> <mailto:repo-discuss...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

David Pursehouse

unread,
Aug 27, 2015, 10:33:20 PM8/27/15
to Dave Borowitz, repo-discuss
On 08/28/2015 10:03 AM, David Pursehouse wrote:
>>
>> Nice! Did it also fix the @AutoAnnotation issue?
>>
>>
>
> Yes, that's what I meant. "Commands: Use @AutoAnnotation" now builds
> for me in Eclipse:
>
> https://gerrit-review.googlesource.com/#/c/63540/4
>
> I'm just doing some more tests now, and then I'll set verified on it and
> its parent "Update AutoValue to 1.1".
>
> I haven't got around to testing the other case (your GPG refactoring)
> but I think it's safe to assume that will also work now.
>

Now I can confirm that yes, it also fixes the error I was seeing with
the GPG module changes.

Bruce Zu

unread,
Feb 19, 2016, 2:37:44 AM2/19/16
to Repo and Gerrit Discussion, David.Pu...@sonymobile.com
I am stop by this issue again today with  Gerrit c9d2f51

$ java -version

java version "1.7.0_79"


mac 10.10.5

eclipse Version: Luna Service Release 2 (4.4.2)


all error message are AutoValue_xxxxx cannot be resolved to a type


I clone a brand new, update eclipse/Eclipse.app/Contents/MacOS/eclipse.ini with "-DmaxCompiledUnitsAtOnce=10000"


buck clean && buck build gerrit

refresh eclipse 


set buck-out as 'Derived'


the error still there. 


there is not '.apt-generated' package

Bruce Zu

unread,
Feb 19, 2016, 2:56:11 AM2/19/16
to Repo and Gerrit Discussion, David.Pu...@sonymobile.com
It is fixed by 
stop eclipse 
rm the workspace 
mkdir a new workspace
import the eclipse again .

 .apt_generated appears now






On Thursday, August 27, 2015 at 7:04:11 AM UTC-7, Dave Borowitz wrote:

David Ostrovsky

unread,
Feb 19, 2016, 2:58:57 AM2/19/16
to Repo and Gerrit Discussion, David.Pu...@sonymobile.com

On Friday, February 19, 2016 at 8:37:44 AM UTC+1, Bruce Zu wrote:
I am stop by this issue again today with  Gerrit c9d2f51

$ java -version

java version "1.7.0_79"


mac 10.10.5

eclipse Version: Luna Service Release 2 (4.4.2)


Have you tried Eclipse Mars:

Version: Mars.1 Release (4.5.1)
Build id: 20150924-1200


Khai Do

unread,
Dec 15, 2016, 5:01:16 PM12/15/16
to Repo and Gerrit Discussion, David.Pu...@sonymobile.com
I'm seeing this these autovalue errors in Eclipse neon.1.  I have added "-DmaxCompiledUnitsAtOnce=10000" to my eclipse.ini but problem still persists.  Anybody have it working on neon.1 or know how to fix it?

Here's my ENV:

I've built gerrit master (bc174c6f8391a75a08d8c8d56e7d9673ce88bff9) with bazel and generated the eclipse project with the bazel tools.

~ ❯❯❯ bazel version
Build label: 0.4.2-homebrew
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Dec 8 03:17:26 2016 (1481167046)
Build timestamp: 1481167046
Build timestamp as int: 1481167046

Eclipse IDE for Java Developers
Version: Neon.1a Release (4.6.1)
Build id: 20161007-1200

~ ❯❯❯ java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
Screen Shot 2016-12-15 at 1.50.42 PM.png

Khai Do

unread,
Dec 15, 2016, 8:20:25 PM12/15/16
to Repo and Gerrit Discussion, David.Pu...@sonymobile.com
I just tried eclipse mars.2 (version 4.5.2) with a clean eclipse workspace and I'm still getting autovalue errors.  Attempted to run eclipse luna but it just crashes when I start it.  I forgot to mention that I'm running on OSX Sierra.

Khai Do

unread,
Dec 15, 2016, 8:26:44 PM12/15/16
to Repo and Gerrit Discussion, David.Pu...@sonymobile.com
Actually I cloned new and built and was able to import this new project without error.  The project I've been using must be in a bad state.  Sorry for the noise.
Reply all
Reply to author
Forward
0 new messages