Using good ol' Java collections usually works great in WO templates.
However, in the past years the JDK has been increasingly introducing the pattern of factory methods that return private implementions of public interfaces. Examples of commonly used methods that do this are List.of() and Collectors.toList().
This poses a problem for us WO-folks, especially in templating, since when KVC encounters a class like this (a private class implementing a public interface) it will fail to locate the correct method to invoke, causing an exception.
Examples:
var size1 = NSKeyValueCoding.Utility.valueForKey( new ArrayList<>(), "size" );
var size2 = NSKeyValueCoding.Utility.valueForKey( List.of(), "size" );
var filteredList = people()
.stream()
.filter( p -> p.name().startsWith( "H" ) )
.toList();
var size3 = NSKeyValueCoding.Utility.valueForKey( filteredList, "size" );
Obtaining size1 will work fine since ArrayList is a public class - but the same will fail for size2 and size3 with an IllegalAccessException.
I occasionally worked around this by wrapping collections in a public class like ArrayList when returning from a method I expected to use in a WO template - but obviously, that's no solution and quite the bother.
To make life easier, I've added a hack in wonder-slim to fix this: ERXKVCReflectionHack.
This is a small modification to KVC's default way of invoking methods, making an inaccessible method accessible on it's first invocation. If you're not using wonder-slim, you can drop this class into your own project to fix this - or add it to the actual original Project Wonder if you're brave enough. I have a general policy of not changing Wonder myself since I rarely use it, meaning I can't contribute much actual testing. Unfortunately, the best way to know if a hacky fix works is really to see it running in production without problems for a while (this one's been in use in all of my projects for a couple of months).
While the patch works we'll probably have to update it soon since we're using terminally deprecated functionality from sun.misc.Unsafe to replace a private static final field in KVC's default implementation. But that's for later.
ng-objects has a more generic fix in progress that attempts to properly locate an interface method to invoke when encountering an inaccessible method. Using this method in WO's KVC would involve some hacking, but I'll probably look into it once the time arrives (as in; when the functionality we're using in Unsafe gets removed).
| 🤸♀️ wonder-slim | Simplify class structure for ERExtensions' dynamic element patches | Jun 27 |
| 💋 parslips | Move Inline Binding Shortcuts preferences to the Zombies category | Jun 27 |
| 💋 parslips | Reload tag aliases when a parsley-tag-aliases.properties changes | Jun 27 |
| 🌿 parsley | Add a note on parsley directly registering wonder elements | Jun 27 |
| 🌿 parsley | Removed the "not in 5.4" tag comments. No one cares. | Jun 27 |
| 💋 parslips | Bump wonder-slim project template to 8.0.3 | Jun 26 |
| 🤸♀️ wonder-slim | Update parsley v1.6.0 -> v1.6.1-SNAPSHOT | Jun 26 |
| ⚙️️ wonder-slim-deployment | Update wonder-slim v8.0.2 -> v8.0.3 | Jun 26 |
| 👨⚕️ examiner | Update wonder-slim v8.0.2 -> v8.0.3, parsley v1.5.0 -> v1.6.0 | Jun 26 |
| 💋 parslips | Add changelog entry for the shared tag registry | Jun 26 |
| 🤸♀️ wonder-slim | 8.0.3 | Jun 26 |
| 🌿 parsley | 1.6.0 | Jun 26 |
| 🌿 parsley | 1.5.0 | Jun 18 |
| 🤸♀️ wonder-slim | 8.0.2 | Jun 18 |
| 🦡 vermilingua | 1.1.5 | Jun 15 |
| 🤸♀️ wonder-slim | 8.0.1 | Jun 1 |
| 🌿 parsley | 1.4.2 | Jun 1 |
| 🦡 vermilingua | 1.1.4 | Apr 24 |
| 🚀 ng-objects | 0.1.1 | Apr 22 |
| 🦡 vermilingua | 1.1.3 | Apr 15 |
| 🌿 parsley | Switch components bypass tag-alias resolution (runtime dynamicElementWithName) | Jun 27 |
| 🧩 apiext-format | Root <wo class> uses the simple class name (Obj-C relic) — reconcile with FQN class references | Jun 25 |
| 🧩 apiext-format | Value sets — allowed values for a binding (literal enums and dynamic sources) | Jun 25 |
| 🧩 apiext-format | Declare the primary HTML element an element renders as | Jun 25 |
| 🧩 apiext-format | Review, document, and possibly redesign the binding-validation syntax | Jun 25 |
| 🧩 apiext-format | Element/component use scope (access control / visibility) | Jun 25 |
| 🤸♀️ wonder-slim | bfcache: stale page on back/forward after an ajax update | Jun 22 |
| 🦡 vermilingua | Write a file to the WOA containing some info about the build | Jun 22 |
| 🤖 modulo | Audit and complete the set of adaptor headers modulo injects | Jun 19 |
| 🦡 vermilingua | Non-clean rebuilds leave deleted/renamed resources in the .woa | Jun 15 |