You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2026/01/15 14:53:27 UTC

(groovy) branch GROOVY-11841 created (now a75e87f122)

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a change to branch GROOVY-11841
in repository https://gitbox.apache.org/repos/asf/groovy.git


      at a75e87f122 remove boundless property name map

This branch includes the following new commits:

     new bebc51f327 GROOVY-11841: use `ConcurrentHashMap` for mutable property index maps
     new a75e87f122 remove boundless property name map

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(groovy) 02/02: remove boundless property name map

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY-11841
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit a75e87f1222c57dcfd7a19d18dc4c247fe109fa0
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Jan 15 08:52:51 2026 -0600

    remove boundless property name map
---
 src/main/java/groovy/lang/MetaClassImpl.java | 29 ++++++----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java b/src/main/java/groovy/lang/MetaClassImpl.java
index 61e6a2c0d5..10b98fd6fa 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -109,7 +109,6 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 import java.util.function.BiConsumer;
 
 import static groovy.lang.Tuple.tuple;
@@ -270,10 +269,8 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
     @Override
     public List<MetaMethod> respondsTo(final Object obj, final String name) {
         Object o = getMethods(getTheClass(), name, false);
-        if (o instanceof FastArray) {
-            @SuppressWarnings("unchecked")
-            List<MetaMethod> l = ((FastArray) o).toList();
-            return l;
+        if (o instanceof FastArray array) {
+            return (List<MetaMethod>) array.toList();
         }
         return Collections.singletonList((MetaMethod) o);
     }
@@ -2512,27 +2509,17 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
             Object propertyMethods = filterPropertyMethod(isThis ? e.methods : e.methodsForSuper, isGetter, isBooleanGetter);
             if (propertyMethods == null) continue;
 
-            String propName = getPropName(methodName);
-            if (propertyMethods instanceof MetaMethod) {
-                createMetaBeanProperty(target, propName, isGetter, (MetaMethod) propertyMethods);
+            String propertyName = BeanUtils.decapitalize(methodName.substring(isBooleanGetter ? 2 : 3));
+            if (propertyMethods instanceof MetaMethod propertyMethod) {
+                createMetaBeanProperty(target, propertyName, isGetter, propertyMethod);
             } else {
                 for (MetaMethod m : (Iterable<MetaMethod>) propertyMethods) {
-                    createMetaBeanProperty(target, propName, isGetter, m);
+                    createMetaBeanProperty(target, propertyName, isGetter, m);
                 }
             }
         }
     }
 
-    private static final ConcurrentMap<String, String> PROP_NAMES = new ConcurrentHashMap<>(1024);
-
-    private static String getPropName(String methodName) {
-        return PROP_NAMES.computeIfAbsent(methodName, k -> {
-            // assume "is" or "[gs]et"
-            return BeanUtils.decapitalize(methodName.startsWith("is")
-                    ? methodName.substring(2) : methodName.substring(3));
-        });
-    }
-
     private static MetaProperty makeReplacementMetaProperty(MetaProperty mp, String propName, boolean isGetter, MetaMethod propertyMethod) {
         if (mp == null) {
             if (isGetter) {
@@ -3837,10 +3824,6 @@ out:    if (metaClass instanceof MetaClassImpl metaClassImpl) {
             return null;
         }
 
-        public ParameterTypes getParamTypes() {
-            return null;
-        }
-
         @Override
         public Object invoke(Object object, Object[] arguments) {
             return null;


(groovy) 01/02: GROOVY-11841: use `ConcurrentHashMap` for mutable property index maps

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY-11841
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit bebc51f3274b35d608bbbbdef6aabb2683e64610
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Jan 15 08:51:59 2026 -0600

    GROOVY-11841: use `ConcurrentHashMap` for mutable property index maps
---
 src/main/java/groovy/lang/MetaClassImpl.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java b/src/main/java/groovy/lang/MetaClassImpl.java
index 3995facfe9..61e6a2c0d5 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -154,12 +154,13 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
     protected final boolean isMap;
     protected final MetaMethodIndex metaMethodIndex;
 
-    private static Map<String, MetaProperty> subMap(Map<CachedClass, LinkedHashMap<String, MetaProperty>> map, CachedClass key) {
+    private static Map<String, MetaProperty> subMap(Map<CachedClass, Map<String, MetaProperty>> map, CachedClass key) {
         return map.computeIfAbsent(key, k -> new LinkedHashMap<>());
     }
-    private final Map<CachedClass, LinkedHashMap<String, MetaProperty>> classPropertyIndexForSuper = new LinkedHashMap<>();
-    private final Map<CachedClass, LinkedHashMap<String, MetaProperty>> classPropertyIndex = new LinkedHashMap<>();
-    private final Map<String, MetaProperty> staticPropertyIndex = new LinkedHashMap<>();
+    private final Map<CachedClass, Map<String, MetaProperty>> classPropertyIndexForSuper = new ConcurrentHashMap<>();
+    private final Map<CachedClass, Map<String, MetaProperty>> classPropertyIndex = new ConcurrentHashMap<>();
+    private final Map<String, MetaProperty> staticPropertyIndex = new ConcurrentHashMap<>();
+
     private final Map<String, MetaMethod> listeners = new LinkedHashMap<>();
     private final List<MetaMethod> allMethods = new ArrayList<>();
     private final Set<MetaMethod> newGroovyMethodsSet = new LinkedHashSet<>();
@@ -2486,7 +2487,7 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
         }
     }
 
-    private void applyStrayPropertyMethods(Iterable<CachedClass> classes, Map<CachedClass, LinkedHashMap<String, MetaProperty>> propertyIndex, boolean isThis) {
+    private void applyStrayPropertyMethods(Iterable<CachedClass> classes, Map<CachedClass, Map<String, MetaProperty>> propertyIndex, boolean isThis) {
         for (CachedClass cc : classes) {
             applyStrayPropertyMethods(cc, subMap(propertyIndex, cc), isThis);
         }