[JIRA] (IDP-1901) Bug with Java 17 due to WarningIntercept

Ian Young (Jira) jira at shibboleth.atlassian.net
Wed Feb 2 13:02:19 UTC 2022


Ian Young ( https://shibboleth.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ae127cb03-43ed-473d-b6ba-592949cb4be8 ) *commented* on IDP-1901 ( https://shibboleth.atlassian.net/browse/IDP-1901?atlOrigin=eyJpIjoiZTYxOTM5ZmNmY2VhNDEwZThmNDNjYmRhOWNkNTdkM2UiLCJwIjoiaiJ9 )

Re: Bug with Java 17 due to WarningIntercept ( https://shibboleth.atlassian.net/browse/IDP-1901?atlOrigin=eyJpIjoiZTYxOTM5ZmNmY2VhNDEwZThmNDNjYmRhOWNkNTdkM2UiLCJwIjoiaiJ9 )

So we have a short term ( --add-opens ) and medium term (wrapper class) workround for this.

Meanwhile, I’ve bottomed out my own investigation. Here’s a minimum reproduction in Java:

package test;

import java.util.HashMap;

import org.springframework.expression.spel.standard.SpelExpressionParser;

public class SpelTest {

	public static void main( String [] args) {

		var map = new HashMap< String , String >();
		map.put( "key" , "value" );
		var iter = map.entrySet().iterator();
		final Object output = new SpelExpressionParser().parseExpression( "hasNext()" ).getValue(iter);
		System.out.println( "output is " + output);

	}

}

* Under Java 11 and Spring 5.3.14, this warns:
* 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/Users/iay/.m2/repository/org/springframework/spring-core/5.3.14/spring-core-5.3.14.jar) to method java.util.HashMap$HashIterator.hasNext()
WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
output is true

* Under Java 17 and either Spring 5.3.14 or 6.0.0-M2, it fails as expected.

Bottom line as described earlier is that Spring Expressions is trying to access the hasNext() method of the (private) implementation class instead of the hasNext() method of the Iterator interface.

Interestingly, a very similar issue was reported for Spring with regards to properties instead of methods. This was fixed in Spring Framework 5.1.18.

Issue: https://github.com/spring-projects/spring-framework/issues/22242

Fix: https://github.com/spring-projects/spring-framework/commit/dec6d698192df28e6640d8de2c2745f7dd0c146d

It seems reasonable to hope that a similar report for the same behaviour on methods might be accepted, particularly as Spring Framework 6 which requires Java 17 is going to push a lot more systems into the failure more. I will open an issue on spring-framework to report this.

( https://shibboleth.atlassian.net/browse/IDP-1901#add-comment?atlOrigin=eyJpIjoiZTYxOTM5ZmNmY2VhNDEwZThmNDNjYmRhOWNkNTdkM2UiLCJwIjoiaiJ9 ) Add Comment ( https://shibboleth.atlassian.net/browse/IDP-1901#add-comment?atlOrigin=eyJpIjoiZTYxOTM5ZmNmY2VhNDEwZThmNDNjYmRhOWNkNTdkM2UiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100190- sha1:4ce3a7c )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/commits/attachments/20220202/dd25b0f7/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-comment-icon-166f928d-5b49-4e51-8cb2-d67342019871
Type: image/png
Size: 1084 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20220202/dd25b0f7/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-avatar-a705c786-4460-4ce4-a2df-4afb7302e231
Type: image/png
Size: 425 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20220202/dd25b0f7/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-footer-desktop-logo-6aa85a88-d858-44b4-8f0c-e51e714f6b27
Type: image/png
Size: 10805 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20220202/dd25b0f7/attachment-0005.png>


More information about the commits mailing list