MG, > On 1 Aug 2020, at 14:59, MG <mg...@arscreat.com> wrote: > What was the reason again Groovy does not add getSize() here... ?-)
Consistency I guess. Having a List.size would lead to a request to add Map.size, which alas would clash with Map['size']. All the best, OC > On 01/08/2020 04:06, Paul King wrote: >> What Daniel said is correct. Also if there was an accessible getSize() >> method, you could use just ".size". >> >> Cheers, Paul. >> >> On Sat, Aug 1, 2020 at 11:19 AM Daniel Sun <sun...@apache.org >> <mailto:sun...@apache.org>> wrote: >> >> The parentheses of methods without parameters could not be ommitted. >> >> `[1, 2, 3].size` is accessing the private field `size` of `ArrayList`, so >> illegal reflective access warning will be thrown. >> >> Cheers, >> Daniel Sun >> On 2020/08/01 00:49:54, paul <pl.grue...@gmail.com >> <mailto:pl.grue...@gmail.com>> wrote: >> > Hi all, >> > >> > (on latest groovy 3.0.5 and OpenJDK 14) omitting the empty parentheses to >> > the .size() call works, but throws an illegal reflective access warning: >> > >> > ``` >> > groovy:000> [1,2,3].size >> > WARNING: An illegal reflective access operation has occurred >> > WARNING: Illegal reflective access by >> > org.codehaus.groovy.reflection.ReflectionUtils >> > (file:/home/paul/.sdkman/candidates/groovy/3.0.5/lib/groovy-3.0.5.jar >> > <file:///home/paul/.sdkman/candidates/groovy/3.0.5/lib/groovy-3.0.5.jar>) >> > to field java.util.ArrayList.size >> > WARNING: Please consider reporting this to the maintainers of >> > org.codehaus.groovy.reflection.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 >> > ===> 3 >> > ``` >> > >> > Curiously, the size() method seems to be the only parameter-less method >> > where I can >> > omit the empty parentheses – all others throw a MissingPropertyException >> > (as expected). >> > >> > What is the desired behaviour, and why is it even working (albeit with >> > warnings) with .size ? >> > >> > >> > best >> > paul >> > -- >> > typed with Neo 2 -- an ergonomically optimized keyboard layout >> > for German, English, programming, and science >> > ❤ http://neo-layout.org <http://neo-layout.org/> >> > ❤ https://useplaintext.email <https://useplaintext.email/> >> > ❤ YY-MM-DD dates (ISO 8601/RFC 3339) >> > � UTF-8 encoding >> > >