RFR: 8305225: A service broken error despite annotation processor generating it if directives listed

Jan Lahoda jlahoda at openjdk.org
Thu May 18 13:28:50 UTC 2023


Consider code like:

module m {
     provides api.Api with impl.Impl; //impl.Impl is not in sources, but is generated by an annotation processor
}


This works fine, until the processor asks for the given module's directives, in which case the build fails with an error like:

testCreateProvidesWithAP/src/m/module-info.java:2: error: the service implementation does not have a default constructor: Test
    provides api.Api with test.Test;


The cause for this error is that when the directive is analyzed, the `test.Test` is attributed (and any errors from that are delayed due to the annotation processing), but even though it attributes to an erroneous type, it will still be checked whether it has the appropriate constructor, etc.

The proposal is to skip the additional checks when the type is an erroneous type. Errors for it should have been reported and handled appropriately (i.e. ignored if resolved by an AP, or reported if not), there does not seem to be any reason to produce any further errors related to the missing type.

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

Commit messages:
 - 8305225: A service broken error despite annotation processor generating it if directives listed

Changes: https://git.openjdk.org/jdk/pull/14046/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14046&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8305225
  Stats: 94 lines in 2 files changed: 91 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/14046.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14046/head:pull/14046

PR: https://git.openjdk.org/jdk/pull/14046


More information about the compiler-dev mailing list