Skip to content

plexus-compiler-eclipse: some warnings from APT processors are lost #68

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
tomaswolf opened this issue Feb 1, 2020 · 6 comments
Closed

Comments

@tomaswolf
Copy link
Contributor

See Eclipse bug 559645 for context and a sample Eclipse maven project showing the issue.

Basically, ECJ reports these diagnostics from APT processors as "extra_problem" elements in the log XML. plexus-compiler-eclipse completely ignores these when parsing the XML to get the diagnostics. Even if it did parse them, ECJ at least up to 3.20.0 has a bug and doesn't report the source file for these extra_problems in the XML, so the output would not be really helpful.

tomaswolf referenced this issue in tomaswolf/plexus-compiler Feb 1, 2020
Instead of invoking BatchCompiler with an option to write diagnostics
to a temporary XML file and then parsing that call ECJ via the standard
JSR-199 interfaces and use a DiagnosticListener.

Besides not needing a temporary file this also ensures that all
diagnostics are reported correctly. ECJ's BatchCompiler reports
diagnostics from APT processors differently than other diagnostics
(they're "extra_problems" in the XML), and the XML parser just ignores
these extra_problems. Even if it did parse them, ECJ up to at least
3.20.0 neglects to give the source file for such extra_problems in the
XML (that's a bug in ECJ), and thus the output would be not exactly
helpful.

Using JSR-199 to call ECJ, it reports all diagnostics including these
"extra_problems" (with source file!) to the DiagnosticListener, and
thus no messages are lost.

A minor quirk is that when no source level is specified, BatchCompiler
compiles with source level 1.3, while the ECJ JSR-199 implementation
uses the latest source level it supports (Java 12 for ECJ 3.20.0). To
maintain backwards compatibility, set source level 1.3 explicitly in
that case. In normal maven usage, <source> is typically set anyway,
either explicitly in the user projects' POMs or via property
maven.compiler.source.

If no JSR-199 interface for ECJ can be found keep using the legacy
mechanism using BatchCompiler.
@tomaswolf
Copy link
Contributor Author

See PR #69.

olamy pushed a commit that referenced this issue Feb 15, 2020
Instead of invoking BatchCompiler with an option to write diagnostics
to a temporary XML file and then parsing that call ECJ via the standard
JSR-199 interfaces and use a DiagnosticListener.

Besides not needing a temporary file this also ensures that all
diagnostics are reported correctly. ECJ's BatchCompiler reports
diagnostics from APT processors differently than other diagnostics
(they're "extra_problems" in the XML), and the XML parser just ignores
these extra_problems. Even if it did parse them, ECJ up to at least
3.20.0 neglects to give the source file for such extra_problems in the
XML (that's a bug in ECJ), and thus the output would be not exactly
helpful.

Using JSR-199 to call ECJ, it reports all diagnostics including these
"extra_problems" (with source file!) to the DiagnosticListener, and
thus no messages are lost.

A minor quirk is that when no source level is specified, BatchCompiler
compiles with source level 1.3, while the ECJ JSR-199 implementation
uses the latest source level it supports (Java 12 for ECJ 3.20.0). To
maintain backwards compatibility, set source level 1.3 explicitly in
that case. In normal maven usage, <source> is typically set anyway,
either explicitly in the user projects' POMs or via property
maven.compiler.source.

If no JSR-199 interface for ECJ can be found keep using the legacy
mechanism using BatchCompiler.
@tomaswolf
Copy link
Contributor Author

Thanks for merging. What's going on with the Travis builds? jdk8/9 fails consistently, jdk11 succeeds.

I suppose this issue could be closed since the PR is merged. When could we expect a release with this?

@olamy
Copy link
Member

olamy commented Feb 16, 2020

switching to openjdk fix the problem

@olamy
Copy link
Member

olamy commented Feb 16, 2020

release done :)

@tomaswolf
Copy link
Contributor Author

Thanks. Just built a fairly large Spring Boot project with this; works well.

In fact, it works too well: it emits the missing warnings, but also shows a few other warnings that previously were hidden, in particular

[WARNING] Unknown source: Field value processing of @ConfigurationProperty meta-data is not supported
[WARNING] Unknown source: Hibernate JPA 2 Static-Metamodel Generator 5.3.7.Final

Both are also visible with plexus-compiler-eclipse 2.8.5 if maven is run with -X.

Don't know where exactly the first one comes from...

The second one is actually another ECJ bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=560204 . Hibernate emits this as an INFO, but ECJ reports any non-error message as a warning.

@tomaswolf
Copy link
Contributor Author

tomaswolf commented May 28, 2020

While https://bugs.eclipse.org/bugs/show_bug.cgi?id=560204 is fixed in the upcoming ECJ 3.22.0, the switch to JSR-199 also exposes another ECJ bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=563654 : sometimes ECJ reports suppressed warnings. A fix is pending in ECJ at https://git.eclipse.org/r/#/c/163738/ .

And there's follow-up issue #73 (configured encoding not respected), for which there is PR #74 pending here.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants