Change in behavior of javax.tools.JavaCompiler in JDK 8 running with -proc:only ?
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Mar 12 17:17:49 UTC 2014
This sounds like a possible bug, but I doubt it is related to -proc:only.
In JDK 8 javac, diagnostics are classified as "recoverable" or not,
depending on whether a diagnostic could conceivably go away if an
annotation processor is run. It is possible that "package does not
exist" is not being marked as a recoverable error. The other possibility
is that the message is coming out of the last round of anno processing
(before -proc:only) is kicking in.
-- Jon
On 03/12/2014 03:00 AM, Boaz Nahum wrote:
> Thank you so much for your reply.
>
> The simplest file that fails to compile is like this:
>
> package wf.auto_testing_jsystem_tiny_test.tint_test;
>
> import amat.jsystem.bbs_params.annotation.BuildingBlock;
> import amat.jsystem.bbs_utils.infrastructure.BuildingBlockContext;
>
> public class TinyTest {
>
> /**
> * A dummy comment
> */
> @BuildingBlock
> public static void loadBatchFromFile(BuildingBlockContext context,
> String batchPath) throws Exception {
>
> }
> }
>
>
> one of the error messages is:
>
> * ....\TinyTest.java:4: error: package
> amat.jsystem.bbs_utils.infrastructure does not exist
> *
> * import amat.jsystem.bbs_utils.infrastructure.BuildingBlockContext;
> * ^
>
> As I mentioned in my question, it is expected error, because we don't
> supply all the necessary compilation dependencies(we can't) .
>
> My question -again-, is That in JDK 7, it works perfect:
> The errors above are reported only via
> javax.tools.DiagnosticListener#report (not printed to the console)
> javax.tools.JavaCompiler.CompilationTask#*call returns true*.
>
> In JDK 8,
> Same errors are reported both via
> javax.tools.DiagnosticListener#report and are printed to the console,
> javax.tools.JavaCompiler.CompilationTask#*call returns false*.
>
> *In JDK 7*, If I omit '-proc:only', then I get the exact behavior *as
> JDK 8*, that why I'm wondering, *maybe JDK 8 somehow ignore '-proc:only'*
>
> Thank again
> Boaz
>
>
>
>
> On Tue, Mar 11, 2014 at 8:24 PM, Jonathan Gibbons
> <jonathan.gibbons at oracle.com <mailto:jonathan.gibbons at oracle.com>> wrote:
>
> Boaz,
>
> In JDK 8, javac is more aggressive about reporting errors (and
> stopping the compilation) if the errors cannot be fixed by running
> annotation processors. This should not be an issue if you are
> using anno processors for generating code.
>
> What sort of errors are you seeing in your compilation?
>
> -- Jon
>
>
> On 03/11/2014 08:27 AM, Boaz Nahum wrote:
>> Hi
>>
>> I hope some can give me hint how anlyse our probelms with JDK 8.
>>
>> We use some code like this to do annotation processing (for
>> generating code):
>>
>> JavaCompiler.CompilationTask task =
>> javaCompiler.getTask(null, fileManager,
>> diagnostics, optionsAsList, null, compilationUnits);
>>
>> BuildingBlockParamProcessor processor = new
>> BuildingBlockParamProcessor();
>> List<Processor> processors = new ArrayList<Processor>();
>> processors.add(processor);
>> task.setProcessors(processors);
>> if(!task.call()){ .... }
>>
>> The code we try to process won't be compile in regular
>> environment - a lot of stuff is missing from classpath.
>> But that is OK, we use '-proc:only' and we *thought* that this
>> what allows us to ignore the errors.
>>
>>
>> When we moved to JDK 8, the exact code fails,
>> javax.tools.JavaCompiler.CompilationTask#call returns false.
>>
>> *My question, is a possibilty that '-proc:only' is ignored in JDK 8 ?
>> *
>> *Or maybe there is by-design change regarding annotation
>> processing that we need to be aware of ?
>> *
>> I want to mention that if the early EAP of JDK 8 , this code run
>> without any problems.
>>
>> (Moving to annotation processing during compilation is big effort
>> for us)
>>
>> Any tip/hint will be appreciatively accepted
>>
>> Thanks
>> Boaz
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20140312/21f2d2de/attachment-0001.html>
More information about the compiler-dev
mailing list