You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Dennis Kieselhorst <de...@apache.org> on 2018/12/20 20:33:27 UTC

CxfTypeSafeClientBuilderTest failing on JDK9+

Hi,

only CxfTypeSafeClientBuilderTest is missing to have a stable build from JDK 9 - 11.

java.lang.reflect.UndeclaredThrowableException
	at org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)
Caused by: java.lang.IllegalAccessException: access to public member failed: org.apache.cxf.microprofile.client.mock.MyClient.myDefaultMethod[Ljava.lang.Object;@10cf09e8/invokeSpecial, from org.apache.cxf.microprofile.client.mock.MyClient/2 (unnamed module @14dd9eb7)
	at org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)

Anyone seen something similar before?

Cheers
Dennis

Re: CxfTypeSafeClientBuilderTest failing on JDK9+

Posted by Andriy Redko <dr...@gmail.com>.
Yes, and we build against JDK12-ea builds, so I think we could ignore it for now. 

Best Regards,
    Andriy Redko

RMB> Guess the hack on modifiers can be ignored, it is not deterministic anyway
RMB> - it can lead to a noop since java 8. While in unamed modules
RMB> unreflectSpecial will be available which should be enough for cxf for now,
RMB> no?

RMB> Romain Manni-Bucau
RMB> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
RMB> <https://rmannibucau.metawerx.net/> | Old Blog
RMB> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
RMB> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
RMB> <https://www.packtpub.com/application-development/java-ee-8-high-performance>


RMB> Le ven. 21 déc. 2018 à 09:15, Dennis Kieselhorst <de...@apache.org> a écrit :

>> Thanks Andriy, looks good for 8-11 now, but 12 is now failing with:

>> Caused by: java.lang.NoSuchFieldException: allowedModes
>>         at
>> org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)


>> https://builds.apache.org/view/A-D/view/CXF/job/CXF-Master-JDK12/lastCompletedBuild/org.apache.cxf$cxf-rt-rs-mp-client/testReport/org.apache.cxf.microprofile.client/CxfTypeSafeClientBuilderTest/testCanInvokeDefaultInterfaceMethods/

>> Regards
>> Dennis



Re: CxfTypeSafeClientBuilderTest failing on JDK9+

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Guess the hack on modifiers can be ignored, it is not deterministic anyway
- it can lead to a noop since java 8. While in unamed modules
unreflectSpecial will be available which should be enough for cxf for now,
no?

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le ven. 21 déc. 2018 à 09:15, Dennis Kieselhorst <de...@apache.org> a écrit :

> Thanks Andriy, looks good for 8-11 now, but 12 is now failing with:
>
> Caused by: java.lang.NoSuchFieldException: allowedModes
>         at
> org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)
>
>
> https://builds.apache.org/view/A-D/view/CXF/job/CXF-Master-JDK12/lastCompletedBuild/org.apache.cxf$cxf-rt-rs-mp-client/testReport/org.apache.cxf.microprofile.client/CxfTypeSafeClientBuilderTest/testCanInvokeDefaultInterfaceMethods/
>
> Regards
> Dennis
>

Re: CxfTypeSafeClientBuilderTest failing on JDK9+

Posted by Dennis Kieselhorst <de...@apache.org>.
Thanks Andriy, looks good for 8-11 now, but 12 is now failing with:

Caused by: java.lang.NoSuchFieldException: allowedModes
	at org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)

https://builds.apache.org/view/A-D/view/CXF/job/CXF-Master-JDK12/lastCompletedBuild/org.apache.cxf$cxf-rt-rs-mp-client/testReport/org.apache.cxf.microprofile.client/CxfTypeSafeClientBuilderTest/testCanInvokeDefaultInterfaceMethods/

Regards
Dennis

Re: CxfTypeSafeClientBuilderTest failing on JDK9+

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi, yes, in j > 10 the workaround is different and the one you pushed :(.

Le ven. 21 déc. 2018 04:43, Andriy Redko <dr...@gmail.com> a écrit :

> Hi Andy,
>
> I've committed a small patch to master [1] to fallback to
> MethodHandles.privateLookupIn (JDK9+)
> in case the main flow fails with IllegalAccessException, it seems to fix
> the issue and properly
> invoke the default method for JDK9+. As far as I know, at the moment there
> is no universal
> solution which works for JDK 8, 9, 10 and 11. Please let me know what do
> you think.
>
> Thank you!
>
> [1]
> https://github.com/apache/cxf/commit/58d9bcd12059c46713902b756881e80c2f28f030
>
> Best Regards,
>     Andriy Redko
>
> Thursday, December 20, 2018, 3:52:29 PM, you wrote:
>
> AM> Hi Dennis,
>
> AM> I most likely introduced this with my fix for CXF-7922 - in that fix, I
> AM> made some changes to internal JDK classes in ClientProxyImpl's
> AM> invokeDefaultMethod method.  The MP Rest Client (as well as the CXF
> proxy
> AM> client) should be able to invoke default methods, and there doesn't
> seem to
> AM> be a good way of doing that... Romain wrote a blog post on the subject
> AM> here:
> AM>
> https://rmannibucau.wordpress.com/2014/03/27/java-8-default-interface-methods-and-jdk-dynamic-proxies/
> AM> - this was the idea behind that change, but I would bet that it is not
> AM> allowed with JPMS enabled - and is most likely causing the failure.
>
> AM> It sounds like I need to find a better way to invoke default interface
> AM> methods without using JDK internals.  If anyone knows of a better way
> or
> AM> has any hints, please let me know.  In the meantime, I could add
> something
> AM> like "assume Java 8" to skip the test in Java 9+ environments.  What
> do you
> AM> think?
>
> AM> Thanks,
>
> AM> Andy
>
> AM> On Thu, Dec 20, 2018 at 2:33 PM Dennis Kieselhorst <de...@apache.org>
> wrote:
>
> >> Hi,
>
> >> only CxfTypeSafeClientBuilderTest is missing to have a stable build from
> >> JDK 9 - 11.
>
> >> java.lang.reflect.UndeclaredThrowableException
> >>         at
> >>
> org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)
> >> Caused by: java.lang.IllegalAccessException: access to public member
> >> failed:
> >>
> org.apache.cxf.microprofile.client.mock.MyClient.myDefaultMethod[Ljava.lang.Object;@10cf09e8
> /invokeSpecial,
> >> from org.apache.cxf.microprofile.client.mock.MyClient/2 (unnamed module
> >> @14dd9eb7)
> >>         at
> >>
> org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)
>
> >> Anyone seen something similar before?
>
> >> Cheers
> >> Dennis
>
>
>

Re: CxfTypeSafeClientBuilderTest failing on JDK9+

Posted by Andriy Redko <dr...@gmail.com>.
Hi Andy,

I've committed a small patch to master [1] to fallback to MethodHandles.privateLookupIn (JDK9+)
in case the main flow fails with IllegalAccessException, it seems to fix the issue and properly
invoke the default method for JDK9+. As far as I know, at the moment there is no universal 
solution which works for JDK 8, 9, 10 and 11. Please let me know what do you think. 

Thank you!

[1] https://github.com/apache/cxf/commit/58d9bcd12059c46713902b756881e80c2f28f030

Best Regards,
    Andriy Redko

Thursday, December 20, 2018, 3:52:29 PM, you wrote:

AM> Hi Dennis,

AM> I most likely introduced this with my fix for CXF-7922 - in that fix, I
AM> made some changes to internal JDK classes in ClientProxyImpl's
AM> invokeDefaultMethod method.  The MP Rest Client (as well as the CXF proxy
AM> client) should be able to invoke default methods, and there doesn't seem to
AM> be a good way of doing that... Romain wrote a blog post on the subject
AM> here:
AM> https://rmannibucau.wordpress.com/2014/03/27/java-8-default-interface-methods-and-jdk-dynamic-proxies/
AM> - this was the idea behind that change, but I would bet that it is not
AM> allowed with JPMS enabled - and is most likely causing the failure.

AM> It sounds like I need to find a better way to invoke default interface
AM> methods without using JDK internals.  If anyone knows of a better way or
AM> has any hints, please let me know.  In the meantime, I could add something
AM> like "assume Java 8" to skip the test in Java 9+ environments.  What do you
AM> think?

AM> Thanks,

AM> Andy

AM> On Thu, Dec 20, 2018 at 2:33 PM Dennis Kieselhorst <de...@apache.org> wrote:

>> Hi,

>> only CxfTypeSafeClientBuilderTest is missing to have a stable build from
>> JDK 9 - 11.

>> java.lang.reflect.UndeclaredThrowableException
>>         at
>> org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)
>> Caused by: java.lang.IllegalAccessException: access to public member
>> failed:
>> org.apache.cxf.microprofile.client.mock.MyClient.myDefaultMethod[Ljava.lang.Object;@10cf09e8/invokeSpecial,
>> from org.apache.cxf.microprofile.client.mock.MyClient/2 (unnamed module
>> @14dd9eb7)
>>         at
>> org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)

>> Anyone seen something similar before?

>> Cheers
>> Dennis



Re: CxfTypeSafeClientBuilderTest failing on JDK9+

Posted by Andy McCright <j....@gmail.com>.
Hi Dennis,

I most likely introduced this with my fix for CXF-7922 - in that fix, I
made some changes to internal JDK classes in ClientProxyImpl's
invokeDefaultMethod method.  The MP Rest Client (as well as the CXF proxy
client) should be able to invoke default methods, and there doesn't seem to
be a good way of doing that... Romain wrote a blog post on the subject
here:
https://rmannibucau.wordpress.com/2014/03/27/java-8-default-interface-methods-and-jdk-dynamic-proxies/
- this was the idea behind that change, but I would bet that it is not
allowed with JPMS enabled - and is most likely causing the failure.

It sounds like I need to find a better way to invoke default interface
methods without using JDK internals.  If anyone knows of a better way or
has any hints, please let me know.  In the meantime, I could add something
like "assume Java 8" to skip the test in Java 9+ environments.  What do you
think?

Thanks,

Andy

On Thu, Dec 20, 2018 at 2:33 PM Dennis Kieselhorst <de...@apache.org> wrote:

> Hi,
>
> only CxfTypeSafeClientBuilderTest is missing to have a stable build from
> JDK 9 - 11.
>
> java.lang.reflect.UndeclaredThrowableException
>         at
> org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)
> Caused by: java.lang.IllegalAccessException: access to public member
> failed:
> org.apache.cxf.microprofile.client.mock.MyClient.myDefaultMethod[Ljava.lang.Object;@10cf09e8/invokeSpecial,
> from org.apache.cxf.microprofile.client.mock.MyClient/2 (unnamed module
> @14dd9eb7)
>         at
> org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilderTest.testCanInvokeDefaultInterfaceMethods(CxfTypeSafeClientBuilderTest.java:173)
>
> Anyone seen something similar before?
>
> Cheers
> Dennis
>