Thanks, Eric, for the suggestion. Using "list.size()" helped me fix the warning.

________________________________
From: Milles, Eric (TR Technology) <[email protected]>
Sent: Tuesday, February 24, 2026 7:28 PM
To: [email protected] <[email protected]>
Cc: Anjan Baradwaj <[email protected]>
Subject: Re: Illegal reflective access (ArrayList.size) – Fixed in any Groovy 
3.x/4.x version?

CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.

If you use code such as "def list = new ArrayList(); print(list.size)" it will 
produce the warning within the Java9 class, where the field lookup is performed.

The solution to this from your perspective is to use the size method, aka 
"list.size()".

If you suspect such field usage exists within the Groovy runtime, it would be 
helpful to find it so we can make a similar change.  We do have one or two test 
cases that do this on purpose to exercise the warning.
CONFIDENTIALITY NOTICE: The information contained in this electronic message is 
intended to be viewed only by the individual or entity to which it is 
addressed. It may contain information that is privileged, confidential, and 
exempt from disclosure under applicable law. If the reader of this message is 
not the intended recipient, you are hereby notified that any dissemination, 
distribution or duplication of this message is strictly prohibited. If this 
electronic message has been received in error, please notify sender immediately 
by return email and delete the original message and any copies of it from your 
computer system. Thank you.

Reply via email to