Error trying to integrate Error Prone with Gradle

392 views
Skip to first unread message

Thomas Broyer

unread,
Oct 3, 2013, 6:36:25 PM10/3/13
to error-pro...@googlegroups.com
Hi,

I'm trying to integrate Error Prone with Gradle (disclaimer: I'm new –less than a week– to both Gradle and Groovy) and keep getting the same kind of errors related to messages/I18N (see stacktraces below).

Errors are not the same in JDK 6 or JDK 7, but are identical between Oracle JDK and OpenJDK.

I tried to mimic the classloading used in the Plexus compiler but it didn't solve the issue.

Any idea what's wrong and how to fix it?

---

With JDK 6:

java.lang.RuntimeException: Unable to register message bundle. java.vm.vendor=[Sun Microsystems Inc.],  java.version=[1.6.0_27]
at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:139)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
... 62 more
Caused by: java.lang.reflect.InvocationTargetException
at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:137)
... 64 more
Caused by: java.util.MissingResourceException: Can't find bundle for base name com.google.errorprone.errors, locale fr_FR
at com.sun.tools.javac.util.Messages.add(Messages.java:66)
... 65 more

With JDK 7:

An exception has occurred in the compiler (1.7.0_25). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.InternalError: Cannot find javac resource bundle for locale fr_FR
at com.sun.tools.javac.util.JavacMessages.getBundles(JavacMessages.java:124)
at com.sun.tools.javac.util.JavacMessages.getLocalizedString(JavacMessages.java:141)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.localize(AbstractDiagnosticFormatter.java:305)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatKind(AbstractDiagnosticFormatter.java:105)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMeta(BasicDiagnosticFormatter.java:163)
at com.sun.tools.javac.util.BasicDiagnosticFormatter.formatDiagnostic(BasicDiagnosticFormatter.java:100)
at com.sun.tools.javac.util.AbstractDiagnosticFormatter.format(AbstractDiagnosticFormatter.java:114)
at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:112)
at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:67)
at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:434)
at com.sun.tools.javac.util.Log.report(Log.java:416)
at com.sun.tools.javac.util.AbstractLog.error(AbstractLog.java:94)
at com.google.errorprone.JavacErrorDescriptionListener.onDescribed(JavacErrorDescriptionListener.java:88)
at com.google.errorprone.Scanner.reportMatch(Scanner.java:176)
at com.google.errorprone.ErrorProneScanner.visitEmptyStatement(ErrorProneScanner.java:552)
at com.google.errorprone.ErrorProneScanner.visitEmptyStatement(ErrorProneScanner.java:33)
at com.sun.tools.javac.tree.JCTree$JCSkip.accept(JCTree.java:757)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
at com.google.errorprone.Scanner.scan(Scanner.java:111)
at com.google.errorprone.Scanner.scan(Scanner.java:44)

hr.st...@gmail.com

unread,
Oct 4, 2013, 1:04:21 PM10/4/13
to error-pro...@googlegroups.com
Thomas,
Have tried the Gradle forums : http://forums.gradle.org/gradle
These guys are very helpful

Alex Eagle

unread,
Oct 4, 2013, 1:44:29 PM10/4/13
to error-pro...@googlegroups.com, hr.st...@gmail.com
Looks like a locale problem. We don't have any internationalization support for error messages, so there is no message bundle for fr_FR. Can you change your environment to US english?
If that helps, then we should change our message bundle setup to hardcode the locale.

Thomas Broyer

unread,
Oct 5, 2013, 1:25:19 PM10/5/13
to error-pro...@googlegroups.com, hr.st...@gmail.com


On Friday, October 4, 2013 7:44:29 PM UTC+2, Alex Eagle wrote:
Looks like a locale problem. We don't have any internationalization support for error messages, so there is no message bundle for fr_FR. Can you change your environment to US english?
If that helps, then we should change our message bundle setup to hardcode the locale.

I should have been clearer sorry; no, sadly it doesn't change anything changing the locale (using "env LANG=en_US.utf8 gradle build" to launch Gradle), except of course the error message now saying "locale en_US".

I debugged the Gradle process and tracked down the issue to a classloader problem: com.sun.tools.javac classes are loaded from the "root" classloader (sun.misc.Launcher$ExtClassLoader) while the error-prone classes are loaded from my URLClassLoader.
…I forgot to set the parent ClassLoader to 'null' (I used new URLClassLoader(urls) instead of new URLClassLoader(urls, null)) !

So in the end: I got it working in just a few days with Gradle and a few hours with Groovy! Yay!
Now time to extract it to a Gradle plugin and contribute it to error-prone (if you want it, or I'll put it up on GitHub)

Alex Eagle

unread,
Oct 5, 2013, 3:54:43 PM10/5/13
to error-pro...@googlegroups.com, t.br...@gmail.com, hr.st...@gmail.com
I'm sorry that was such a pain. I was starting to reply to your mail with an explanation of the classloading issue (which I had to deal with in Maven as well). But then I saw the French locale and thought that might be an easier place to start.
It's true that error-prone needs to be run in a classloader that includes both its own library code as well as the tools.jar. It seems common for build systems to use a different classloader for the in-process compiler, which might make sense if there's some chance that a library they use might conflict with something the compiler loads internally.
Someday we hope that error-prone will be part of javac (maybe in version 9) and then this won't be needed.

If you'd like to submit your plugin under the error-prone tree, I think it would be nice, and I'd be very pleased to take a pull request. If you'd like to host in github, that's okay too, unless there is some integration test we could add to our build to prevent future changes breaking the Gradle plugin.
We should also add a trivial example under our examples/gradle directory.

Thanks!!


--
Googlers: This an external list. Please be careful when posting.
---
You received this message because you are subscribed to the Google Groups "error-prone-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to error-prone-dis...@googlegroups.com.
Visit this group at http://groups.google.com/group/error-prone-discuss.
To view this discussion on the web visit https://groups.google.com/d/msgid/error-prone-discuss/255203c4-83d9-4afa-9396-8cf2cefb7d83%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Thomas Broyer

unread,
Oct 6, 2013, 7:37:01 PM10/6/13
to error-pro...@googlegroups.com, t.br...@gmail.com, hr.st...@gmail.com


On Saturday, October 5, 2013 9:54:43 PM UTC+2, Alex Eagle wrote:
If you'd like to submit your plugin under the error-prone tree, I think it would be nice, and I'd be very pleased to take a pull request. If you'd like to host in github, that's okay too, unless there is some integration test we could add to our build to prevent future changes breaking the Gradle plugin.
We should also add a trivial example under our examples/gradle directory.

Dependencies necessary to write Gradle plugins aren't available in Maven repos, and tests require a Gradle environment (AFAICT), so I couldn't make a Maven module to integrate in the error-prone tree, and thus decided to host it on GitHub: https://github.com/tbroyer/gradle-errorprone-plugin
I just released a 0.0.1 version that should appear soon on Central, so I think you can add something to the wiki page (see README of the project on GitHub).
I put the code under Apache v2, in case you're interested in hosting it as an "official" plugin.

BTW, is there a 1.0 version of the IDEA plugin? the wiki page says that once a 1.0 is cut the plugin would be available in JetBrains repository, and I haven't found anything there.

Alex Eagle

unread,
Oct 6, 2013, 7:56:04 PM10/6/13
to error-pro...@googlegroups.com, Thomas Broyer, Hristo Stoyanov
No, I need to get that IntelliJ plugin released. The problem is we don't have a build script for it, and the version I uploaded was built with the wrong JDK -target ... also I need to get back to an old thread to see if they want to bring it into their repo now...


--
Googlers: This an external list. Please be careful when posting.
---
You received this message because you are subscribed to the Google Groups "error-prone-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to error-prone-dis...@googlegroups.com.
Visit this group at http://groups.google.com/group/error-prone-discuss.

Alex Eagle

unread,
Oct 6, 2013, 8:13:04 PM10/6/13
to error-pro...@googlegroups.com, Thomas Broyer, Hristo Stoyanov
I added an example in the error-prone repo
and I'll update the "Installing Errorprone" wiki page.

Thomas Broyer

unread,
Oct 6, 2013, 8:26:57 PM10/6/13
to Alex Eagle, error-pro...@googlegroups.com, Hristo Stoyanov
On Mon, Oct 7, 2013 at 2:13 AM, Alex Eagle <alex...@google.com> wrote:
I added an example in the error-prone repo
and I'll update the "Installing Errorprone" wiki page.

\o/

In the mean time, I tested with JDK 6 (an old Oracle JDK, and OpenJDK from Ubuntu) and it fails with:
An exception has occurred in the compiler (1.6.0_27). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.AbstractMethodError
at com.sun.tools.javac.util.Context.get(Context.java:146)
at com.sun.tools.javac.main.JavaCompiler.instance(JavaCompiler.java:88)
at com.sun.tools.javac.main.Main.compile(Main.java:375)
at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:151)
at com.sun.tools.javac.main.Main.compile(Main.java:308)
at com.sun.tools.javac.main.Main.compile(Main.java:299)

Any idea?

(I don't really care about JDK 6 these days, but just in case someone reports a bug to the gradle-errorprone-plugin about it ;-) )

Alex Eagle

unread,
Oct 6, 2013, 11:11:36 PM10/6/13
to Thomas Broyer, Hristo Stoyanov, error-pro...@googlegroups.com

Hmm we have a JDK 6 continuous build so it should work at least in that environment. We will have to try to repro.

Jens

unread,
Oct 7, 2013, 9:00:37 AM10/7/13
to error-pro...@googlegroups.com, t.br...@gmail.com, hr.st...@gmail.com

BTW, is there a 1.0 version of the IDEA plugin? the wiki page says that once a 1.0 is cut the plugin would be available in JetBrains repository, and I haven't found anything there.

I think you wouldn't like it anyways as it requires you to turn off external compilation. Without external compilation and thus "auto make" turned off, you only have error highlighting in the current active file. That really hurts when doing manual refactors or introducing methods to interfaces etc. You always have to manually trigger Make to see all the problems in your code. Coming from Eclipse that really feels strange and is kind of annoying.

I tried the error-prone plugin in IntelliJ and quickly deinstalled it again. I don't want to miss external compilation + auto make.

-- J.

Alex Eagle

unread,
Oct 7, 2013, 11:44:09 AM10/7/13
to error-pro...@googlegroups.com, Thomas Broyer, Hristo Stoyanov
Oh, that's cool, I didn't know IJ had that feature now. I'm accustomed to hitting F9 when I want to see what I've broken in an unsafe refactor, but I know it's second nature for Eclipse users to have compilations happening in the background.

It's very convenient to distribute error-prone as a jar. I worry that if we also have to provide a "javac-with-errorprone" binary, then we'll have to test it on different platforms, deal with bugs where we don't pick the same JDK that your "javac" path would have used, etc. But there's probably some way to make external compilation happen without doing all that.

I'll see what the JetBrains guys think.


--
Googlers: This an external list. Please be careful when posting.
---
You received this message because you are subscribed to the Google Groups "error-prone-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to error-prone-dis...@googlegroups.com.
Visit this group at http://groups.google.com/group/error-prone-discuss.
Reply all
Reply to author
Forward
0 new messages