Hello all,
While working on GROOVY-11294, I was investigating approaches for creating an
immutable list from an array and have some questions...
Java's List.of() usually doesn't allow nulls but can on 16+ by using
Stream.toList(). I've used the VMPlugin system to handle this with appropriate
f
Can you just wrap what is presently returned with a call to
Collections.unmodifiableList or Collections.unmodifiableMap?
If the return values of toList() or toMap() from a record do not link to any
internal state, what is the concern if they are mutable or not?
From: Oscar N
Sent: Monday, Jan
Wrapping in Collections.unmodifiableList is an option, although using List.of()
when possible should yield better performance as it has stronger immutability
guarantees at the JVM level (uses @jdk.internal.vm.annotation.Stable on its
internal backing fields).
You are right that it doesn't link
The exercise is an interesting one: how to add support for something like
`List.of(...)` for Java 8-21 when the method exists only for 9+ and some
behavior you seek in only in 16+.
However, is it worthwhile in this case to add new `ScriptBytecodeAdapter`
methods to support this for records inst
The new Class File API is for reading not writing, correct? With that in mind,
I think only the ASM decompile package (org.codehaus.groovy.ast.decompiled) is
under consideration. There are already 2 paths taken by ClassNodeResolver
tryAsLoaderClassOrScript. Adding a third option there that is
Indeed, that is the crux of my earlier questions. I've got it working at
runtime, however I'm unsure of which approach to take for compile-time.
Adding new `ScriptBytecodeAdapter`/`InvokerHelper` methods that call a
`VMPlugin` method allows for optimising other scenarios, such as
`DefaultGroovy
There are many bytecode lib in the Java world, an abstract layer for handling
bytecode can prevent Groovy from the change of implementation. It is similar to
system with data persistence layer which provides unified API to access
databases, e.g. MySQL, PostgreSQL, Oracle, etc. If database change