You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Robert Scholte <rf...@apache.org> on 2015/09/14 18:40:28 UTC

JavaxToolsCompiler

Hi,

On behalf of the Apache Maven team I'd like to ask for advice for changing  
the JavaxToolsCompiler[1]
This implementation is used when java code is being compiled with Maven  
*by default*, so right now when pointing JAVA_HOME to the latest JDK9  
version builds will fail.
There are other ways to compile, e.g. use the fork-parameter[2] or with  
toolchains[3], but what I'd like to know is whether it is still  
possible/valid to use javax.tools.JavaCompiler and is so: how should we  
rewrite this code?

regards,
Robert Scholte

[1]  
https://github.com/codehaus-plexus/plexus-compiler/blob/master/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompiler.java
[2]  
http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#fork
[3] http://maven.apache.org/guides/mini/guide-using-toolchains.html

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: JavaxToolsCompiler

Posted by Robert Scholte <rf...@apache.org>.
Op Mon, 14 Sep 2015 20:27:39 +0200 schreef Alan Bateman  
<Al...@oracle.com>:

> On 14/09/2015 17:40, Robert Scholte wrote:
>> Hi,
>>
>> On behalf of the Apache Maven team I'd like to ask for advice for  
>> changing the JavaxToolsCompiler[1]
>> This implementation is used when java code is being compiled with Maven  
>> *by default*, so right now when pointing JAVA_HOME to the latest JDK9  
>> version builds will fail.
>> There are other ways to compile, e.g. use the fork-parameter[2] or with  
>> toolchains[3], but what I'd like to know is whether it is still  
>> possible/valid to use javax.tools.JavaCompiler and is so: how should we  
>> rewrite this code?
>
> Thanks for bringing this up as a few people have reported issues with  
> Maven not finding the compiler.
>
> Just to be clear, are you seeing this issue with the regular JDK 9 EA  
> builds or just the Jigsaw EA builds?

Regular JDK9 EA works fine, I'm only seeing it with Jigsaw EA

> Did this start when tools.jar went away?

I guess so.

> I just did a quick test to check that  
> ToolProvider.getSystemJavaCompiler() is returning the system  
> JavaCompiler is returned for both builds (and it is). Is the issue that  
> you are seeing that getSystemJavaCompiler() is returning null?

Stuart said yes, I think so too.

>
> -Alan.

Robert

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: JavaxToolsCompiler

Posted by Mandy Chung <ma...@oracle.com>.
On 09/14/2015 12:44 PM, Alan Bateman wrote:
>
>
> On 14/09/2015 20:21, Stuart McCulloch wrote:
>> Yes, the issue is that ToolProvider.getSystemJavaCompiler() is 
>> returning null when using the Jigsaw EA with Maven.
>>
>> AFAICT this is because it’s now using the service loader mechanism 
>> which is influenced by the Thread’s context ClassLoader
>>
>>
> That may be a bug as I wouldn't expect the ToolProvider.getSystemXXX 
> methods to locate the these tools via the TCCL.

I was talking with Jon about this.   This is a bug in ToolProvider that 
it should call
    ServiceLoader.load(clazz, ClassLoader.getSystemClassLoader());

Looking at ToolProvider, the getSystemToolClassLoader method catches my 
attention that I think we should consider deprecating it since this 
assumes there is one class loader loading multiple tools.

Mandy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: JavaxToolsCompiler

Posted by Alan Bateman <Al...@oracle.com>.

On 14/09/2015 20:21, Stuart McCulloch wrote:
> Yes, the issue is that ToolProvider.getSystemJavaCompiler() is returning null when using the Jigsaw EA with Maven.
>
> AFAICT this is because it’s now using the service loader mechanism which is influenced by the Thread’s context ClassLoader
>
>
That may be a bug as I wouldn't expect the ToolProvider.getSystemXXX 
methods to locate the these tools via the TCCL.

-Alan.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: JavaxToolsCompiler

Posted by Robert Scholte <rf...@apache.org>.
Op Fri, 18 Sep 2015 10:26:46 +0200 schreef Alan Bateman  
<Al...@oracle.com>:

>
> On 17/09/2015 22:07, Robert Scholte wrote:
>> I can confirm the fix.
>>
>> thanks!
>>
>> Robert
> Thanks for the confirmation. Just to double check, this is with the  
> ToolProvider fix rather than the patch to the compiler plugin that one  
> of Stuart's mails referenced, right?
>
> As we're exchanging mail, I'm curious as to which plugins are exercised  
> by your testing, just in case there are other plugins where we might  
> still run into issues.
>
> -Alan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

Stuart already closed that pull request[1] since "This has been fixed  
upstream:  
http://hg.openjdk.java.net/jigsaw/jake/langtools/rev/948a1770620e"

I started building Maven[2] with Maven.
Next will be the integrations tests[3] and the maven-plugins[4]
That should give a good overview of the compatibility of Maven projects  
with jigsaw

Robert

[1]  
https://github.com/codehaus-plexus/plexus-compiler/pull/13#issuecomment-140565416
[2] https://git-wip-us.apache.org/repos/asf/maven.git
[3] https://git-wip-us.apache.org/repos/asf/maven-integration-testing.git
[4] https://svn.apache.org/repos/asf/maven/plugins/trunk

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: JavaxToolsCompiler

Posted by Alan Bateman <Al...@oracle.com>.
On 17/09/2015 22:07, Robert Scholte wrote:
> I can confirm the fix.
>
> thanks!
>
> Robert
Thanks for the confirmation. Just to double check, this is with the 
ToolProvider fix rather than the patch to the compiler plugin that one 
of Stuart's mails referenced, right?

As we're exchanging mail, I'm curious as to which plugins are exercised 
by your testing, just in case there are other plugins where we might 
still run into issues.

-Alan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: JavaxToolsCompiler

Posted by Robert Scholte <rf...@apache.org>.
I can confirm the fix.

thanks!

Robert

Op Wed, 16 Sep 2015 12:27:11 +0200 schreef Alan Bateman  
<Al...@oracle.com>:

>
> On 14/09/2015 20:21, Stuart McCulloch wrote:
>> Yes, the issue is that ToolProvider.getSystemJavaCompiler() is  
>> returning null when using the Jigsaw EA with Maven.
>>
>> AFAICT this is because it’s now using the service loader mechanism  
>> which is influenced by the Thread’s context ClassLoader
>>
>> The following patch to make sure Maven uses the system context when  
>> looking up the compiler appears to solve the issue:
>>
>>
> Just to follow-up on this one, the bug in ToolProvider has been fixed in  
> the jigsaw/jake forest. We should have an updated EA build in the next  
> day or two that will pick up this fix.
>
> Thanks again for the mails on this, it's good to have found this one  
> early.
>
> -Alan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: JavaxToolsCompiler

Posted by Alan Bateman <Al...@oracle.com>.
On 14/09/2015 20:21, Stuart McCulloch wrote:
> Yes, the issue is that ToolProvider.getSystemJavaCompiler() is returning null when using the Jigsaw EA with Maven.
>
> AFAICT this is because it’s now using the service loader mechanism which is influenced by the Thread’s context ClassLoader
>
> The following patch to make sure Maven uses the system context when looking up the compiler appears to solve the issue:
>
>
Just to follow-up on this one, the bug in ToolProvider has been fixed in 
the jigsaw/jake forest. We should have an updated EA build in the next 
day or two that will pick up this fix.

Thanks again for the mails on this, it's good to have found this one early.

-Alan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: JavaxToolsCompiler

Posted by Stuart McCulloch <mc...@gmail.com>.
Yes, the issue is that ToolProvider.getSystemJavaCompiler() is returning null when using the Jigsaw EA with Maven.

AFAICT this is because it’s now using the service loader mechanism which is influenced by the Thread’s context ClassLoader  

The following patch to make sure Maven uses the system context when looking up the compiler appears to solve the issue:

https://github.com/codehaus-plexus/plexus-compiler/pull/13

--  
Cheers, Stuart


On Monday, 14 September 2015 at 19:27, Alan Bateman wrote:

> On 14/09/2015 17:40, Robert Scholte wrote:
> > Hi,
> >  
> > On behalf of the Apache Maven team I'd like to ask for advice for  
> > changing the JavaxToolsCompiler[1]
> > This implementation is used when java code is being compiled with  
> > Maven *by default*, so right now when pointing JAVA_HOME to the latest  
> > JDK9 version builds will fail.
> > There are other ways to compile, e.g. use the fork-parameter[2] or  
> > with toolchains[3], but what I'd like to know is whether it is still  
> > possible/valid to use javax.tools.JavaCompiler and is so: how should  
> > we rewrite this code?
> >  
>  
>  
> Thanks for bringing this up as a few people have reported issues with  
> Maven not finding the compiler.
>  
> Just to be clear, are you seeing this issue with the regular JDK 9 EA  
> builds or just the Jigsaw EA builds? Did this start when tools.jar went  
> away? I just did a quick test to check that  
> ToolProvider.getSystemJavaCompiler() is returning the system  
> JavaCompiler is returned for both builds (and it is). Is the issue that  
> you are seeing that getSystemJavaCompiler() is returning null?
>  
> -Alan.
>  
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org (mailto:dev-unsubscribe@maven.apache.org)
> For additional commands, e-mail: dev-help@maven.apache.org (mailto:dev-help@maven.apache.org)
>  
>  



Re: JavaxToolsCompiler

Posted by Alan Bateman <Al...@oracle.com>.
On 14/09/2015 17:40, Robert Scholte wrote:
> Hi,
>
> On behalf of the Apache Maven team I'd like to ask for advice for 
> changing the JavaxToolsCompiler[1]
> This implementation is used when java code is being compiled with 
> Maven *by default*, so right now when pointing JAVA_HOME to the latest 
> JDK9 version builds will fail.
> There are other ways to compile, e.g. use the fork-parameter[2] or 
> with toolchains[3], but what I'd like to know is whether it is still 
> possible/valid to use javax.tools.JavaCompiler and is so: how should 
> we rewrite this code?

Thanks for bringing this up as a few people have reported issues with 
Maven not finding the compiler.

Just to be clear, are you seeing this issue with the regular JDK 9 EA 
builds or just the Jigsaw EA builds? Did this start when tools.jar went 
away? I just did a quick test to check that 
ToolProvider.getSystemJavaCompiler() is returning the system 
JavaCompiler is returned for both builds (and it is). Is the issue that 
you are seeing that getSystemJavaCompiler() is returning null?

-Alan.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org