You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/12/31 17:19:01 UTC

[groovy] branch master updated (722e6af -> b13fa74)

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

sunlan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from 722e6af  Minor refactoring: simplify code for getting CallType
     new 6f7f56a  Cleanup and format code
     new b13fa74  Minor refactoring: simplify `getLength`

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.


Summary of changes:
 .../groovy/vmplugin/v7/IndyArrayAccess.java        |  42 ++-
 .../v7/IndyGuardsFiltersAndSignatures.java         |  76 +++--
 .../codehaus/groovy/vmplugin/v7/IndyInterface.java | 339 +++++++++++----------
 .../org/codehaus/groovy/vmplugin/v7/IndyMath.java  | 271 ++++++++++------
 .../org/codehaus/groovy/vmplugin/v7/Java7.java     |   7 +-
 .../org/codehaus/groovy/vmplugin/v7/Selector.java  | 248 ++++++++-------
 .../codehaus/groovy/vmplugin/v7/TypeHelper.java    |  31 +-
 .../groovy/vmplugin/v7/TypeTransformers.java       |  58 ++--
 8 files changed, 589 insertions(+), 483 deletions(-)


[groovy] 02/02: Minor refactoring: simplify `getLength`

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

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit b13fa74da65bcb33770217d13b572c265c24fd9c
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Jan 1 00:54:20 2020 +0800

    Minor refactoring: simplify `getLength`
---
 .../org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java
index 34205f7..84310a7 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java
@@ -23,6 +23,7 @@ import org.codehaus.groovy.GroovyBugError;
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
+import java.lang.reflect.Array;
 import java.util.HashMap;
 
 /**
@@ -99,16 +100,11 @@ public class IndyArrayAccess {
     }
 
     private static int getLength(Object array) {
-        if (array instanceof Object[]) return ((Object[]) array).length;
-        if (array instanceof boolean[]) return ((boolean[]) array).length;
-        if (array instanceof byte[]) return ((byte[]) array).length;
-        if (array instanceof char[]) return ((char[]) array).length;
-        if (array instanceof short[]) return ((short[]) array).length;
-        if (array instanceof int[]) return ((int[]) array).length;
-        if (array instanceof long[]) return ((long[]) array).length;
-        if (array instanceof float[]) return ((float[]) array).length;
-        if (array instanceof double[]) return ((double[]) array).length;
-        return 0;
+        if (null == array || !array.getClass().isArray()) {
+            return 0;
+        }
+
+        return Array.getLength(array);
     }
 
     private static int normalizeIndex(Object array, int i) {


[groovy] 01/02: Cleanup and format code

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

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 6f7f56a7e82ae77d9e1a923f591d04d598599e81
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Jan 1 00:50:56 2020 +0800

    Cleanup and format code
---
 .../groovy/vmplugin/v7/IndyArrayAccess.java        |  44 +--
 .../v7/IndyGuardsFiltersAndSignatures.java         |  76 +++--
 .../codehaus/groovy/vmplugin/v7/IndyInterface.java | 339 +++++++++++----------
 .../org/codehaus/groovy/vmplugin/v7/IndyMath.java  | 271 ++++++++++------
 .../org/codehaus/groovy/vmplugin/v7/Java7.java     |   7 +-
 .../org/codehaus/groovy/vmplugin/v7/Selector.java  | 248 ++++++++-------
 .../codehaus/groovy/vmplugin/v7/TypeHelper.java    |  31 +-
 .../groovy/vmplugin/v7/TypeTransformers.java       |  58 ++--
 8 files changed, 592 insertions(+), 482 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java
index dccf0b4..34205f7 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java
@@ -32,7 +32,8 @@ import java.util.HashMap;
  */
 public class IndyArrayAccess {
 
-    private static final MethodHandle notNegative,normalizeIndex;
+    private static final MethodHandle notNegative, normalizeIndex;
+
     static {
         try {
             notNegative = MethodHandles.lookup().findStatic(IndyArrayAccess.class, "notNegative", MethodType.methodType(boolean.class, int.class));
@@ -42,9 +43,10 @@ public class IndyArrayAccess {
         }
     }
 
-    private static final HashMap<Class,MethodHandle> getterMap, setterMap;
+    private static final HashMap<Class, MethodHandle> getterMap, setterMap;
+
     static {
-        getterMap = new HashMap<Class,MethodHandle>();
+        getterMap = new HashMap<Class, MethodHandle>();
         Class[] classes = new Class[]{
                 int[].class, byte[].class, short[].class, long[].class,
                 double[].class, float[].class,
@@ -53,7 +55,7 @@ public class IndyArrayAccess {
             MethodHandle handle = buildGetter(arrayClass);
             getterMap.put(arrayClass, handle);
         }
-        setterMap = new HashMap<Class,MethodHandle>();
+        setterMap = new HashMap<Class, MethodHandle>();
         for (Class arrayClass : classes) {
             MethodHandle handle = buildSetter(arrayClass);
             setterMap.put(arrayClass, handle);
@@ -66,8 +68,8 @@ public class IndyArrayAccess {
 
         fallback = MethodHandles.dropArguments(fallback, 2, int.class);
         MethodType reorderType = fallback.type().
-                                    insertParameterTypes(0, int.class).
-                                    dropParameterTypes(2,3);
+                insertParameterTypes(0, int.class).
+                dropParameterTypes(2, 3);
         fallback = MethodHandles.permuteArguments(fallback, reorderType, 1, 0, 0);
 
         fallback = MethodHandles.foldArguments(fallback, normalizeIndex);
@@ -78,14 +80,14 @@ public class IndyArrayAccess {
         return handle;
     }
 
-    private static MethodHandle buildSetter(Class arrayClass){
+    private static MethodHandle buildSetter(Class arrayClass) {
         MethodHandle set = MethodHandles.arrayElementSetter(arrayClass);
         MethodHandle fallback = MethodHandles.explicitCastArguments(set, set.type().changeParameterType(0, Object.class));
 
         fallback = MethodHandles.dropArguments(fallback, 3, int.class);
         MethodType reorderType = fallback.type().
-                                    insertParameterTypes(0, int.class).
-                                    dropParameterTypes(4,5);
+                insertParameterTypes(0, int.class).
+                dropParameterTypes(4, 5);
         fallback = MethodHandles.permuteArguments(fallback, reorderType, 1, 0, 3, 0);
 
         fallback = MethodHandles.foldArguments(fallback, normalizeIndex);
@@ -97,15 +99,15 @@ public class IndyArrayAccess {
     }
 
     private static int getLength(Object array) {
-        if (array instanceof Object[]) return ((Object[])array).length;
-        if (array instanceof boolean[]) return ((boolean[])array).length;
-        if (array instanceof byte[]) return ((byte[])array).length;
-        if (array instanceof char[]) return ((char[])array).length;
-        if (array instanceof short[]) return ((short[])array).length;
-        if (array instanceof int[]) return ((int[])array).length;
-        if (array instanceof long[]) return ((long[])array).length;
-        if (array instanceof float[]) return ((float[])array).length;
-        if (array instanceof double[]) return ((double[])array).length;
+        if (array instanceof Object[]) return ((Object[]) array).length;
+        if (array instanceof boolean[]) return ((boolean[]) array).length;
+        if (array instanceof byte[]) return ((byte[]) array).length;
+        if (array instanceof char[]) return ((char[]) array).length;
+        if (array instanceof short[]) return ((short[]) array).length;
+        if (array instanceof int[]) return ((int[]) array).length;
+        if (array instanceof long[]) return ((long[]) array).length;
+        if (array instanceof float[]) return ((float[]) array).length;
+        if (array instanceof double[]) return ((double[]) array).length;
         return 0;
     }
 
@@ -120,13 +122,13 @@ public class IndyArrayAccess {
     }
 
     public static boolean notNegative(int index) {
-        return index>=0;
+        return index >= 0;
     }
 
     public static MethodHandle arrayGet(MethodType type) {
         Class key = type.parameterType(0);
         MethodHandle res = getterMap.get(key);
-        if (res!=null) return res;
+        if (res != null) return res;
         res = buildGetter(key);
         res = MethodHandles.explicitCastArguments(res, type);
         return res;
@@ -135,7 +137,7 @@ public class IndyArrayAccess {
     public static MethodHandle arraySet(MethodType type) {
         Class key = type.parameterType(0);
         MethodHandle res = setterMap.get(key);
-        if (res!=null) return res;
+        if (res != null) return res;
         res = buildSetter(key);
         res = MethodHandles.explicitCastArguments(res, type);
         return res;
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyGuardsFiltersAndSignatures.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyGuardsFiltersAndSignatures.java
index 2cffc58..7bca41a 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyGuardsFiltersAndSignatures.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyGuardsFiltersAndSignatures.java
@@ -54,37 +54,35 @@ import static org.codehaus.groovy.vmplugin.v7.IndyInterface.LOOKUP;
 public class IndyGuardsFiltersAndSignatures {
 
     private static final MethodType
-        ZERO_GUARD          = MethodType.methodType(boolean.class),
-        OBJECT_GUARD        = MethodType.methodType(boolean.class, Object.class),
-        CLASS1_GUARD        = MethodType.methodType(boolean.class, Class.class, Object.class),
-        METACLASS1_GUARD    = MethodType.methodType(boolean.class, MetaClass.class, Object.class),
-        
-        GRE_GUARD           = MethodType.methodType(Object.class, GroovyRuntimeException.class),
-        
-        OBJECT_FILTER       = MethodType.methodType(Object.class, Object.class),
-
-        BOUND_INVOKER       = MethodType.methodType(Object.class, Object[].class),
-        ANO_INVOKER         = MethodType.methodType(Object.class, Object.class, Object[].class),
-        INVOKER             = MethodType.methodType(Object.class, Object.class, String.class, Object[].class),
-        GET_INVOKER         = MethodType.methodType(Object.class, String.class)
-        ;
-
-    protected static final MethodHandle 
-        SAME_CLASS,         UNWRAP_METHOD,
-        SAME_MC,            IS_NULL,
-        UNWRAP_EXCEPTION,   META_METHOD_INVOKER,
-        GROOVY_OBJECT_INVOKER, GROOVY_OBJECT_GET_PROPERTY,
-        HAS_CATEGORY_IN_CURRENT_THREAD_GUARD,
-        BEAN_CONSTRUCTOR_PROPERTY_SETTER,
-        META_PROPERTY_GETTER,
-        SLOW_META_CLASS_FIND, META_CLASS_INVOKE_STATIC_METHOD,
-        MOP_GET, MOP_INVOKE_CONSTRUCTOR, MOP_INVOKE_METHOD,
-        INTERCEPTABLE_INVOKER,
-        CLASS_FOR_NAME, BOOLEAN_IDENTITY, 
-        DTT_CAST_TO_TYPE, SAM_CONVERSION,
-        HASHSET_CONSTRUCTOR, ARRAYLIST_CONSTRUCTOR, GROOVY_CAST_EXCEPTION,
-        EQUALS
-        ;
+            ZERO_GUARD = MethodType.methodType(boolean.class),
+            OBJECT_GUARD = MethodType.methodType(boolean.class, Object.class),
+            CLASS1_GUARD = MethodType.methodType(boolean.class, Class.class, Object.class),
+            METACLASS1_GUARD = MethodType.methodType(boolean.class, MetaClass.class, Object.class),
+
+    GRE_GUARD = MethodType.methodType(Object.class, GroovyRuntimeException.class),
+
+    OBJECT_FILTER = MethodType.methodType(Object.class, Object.class),
+
+    BOUND_INVOKER = MethodType.methodType(Object.class, Object[].class),
+            ANO_INVOKER = MethodType.methodType(Object.class, Object.class, Object[].class),
+            INVOKER = MethodType.methodType(Object.class, Object.class, String.class, Object[].class),
+            GET_INVOKER = MethodType.methodType(Object.class, String.class);
+
+    protected static final MethodHandle
+            SAME_CLASS, UNWRAP_METHOD,
+            SAME_MC, IS_NULL,
+            UNWRAP_EXCEPTION, META_METHOD_INVOKER,
+            GROOVY_OBJECT_INVOKER, GROOVY_OBJECT_GET_PROPERTY,
+            HAS_CATEGORY_IN_CURRENT_THREAD_GUARD,
+            BEAN_CONSTRUCTOR_PROPERTY_SETTER,
+            META_PROPERTY_GETTER,
+            SLOW_META_CLASS_FIND, META_CLASS_INVOKE_STATIC_METHOD,
+            MOP_GET, MOP_INVOKE_CONSTRUCTOR, MOP_INVOKE_METHOD,
+            INTERCEPTABLE_INVOKER,
+            CLASS_FOR_NAME, BOOLEAN_IDENTITY,
+            DTT_CAST_TO_TYPE, SAM_CONVERSION,
+            HASHSET_CONSTRUCTOR, ARRAYLIST_CONSTRUCTOR, GROOVY_CAST_EXCEPTION,
+            EQUALS;
 
     static {
         try {
@@ -111,7 +109,7 @@ public class IndyGuardsFiltersAndSignatures {
             CLASS_FOR_NAME = LOOKUP.findStatic(Class.class, "forName", MethodType.methodType(Class.class, String.class, boolean.class, ClassLoader.class));
 
             BOOLEAN_IDENTITY = MethodHandles.identity(Boolean.class);
-            DTT_CAST_TO_TYPE = LOOKUP.findStatic(DefaultTypeTransformation.class, "castToType", MethodType.methodType(Object.class,Object.class,Class.class));
+            DTT_CAST_TO_TYPE = LOOKUP.findStatic(DefaultTypeTransformation.class, "castToType", MethodType.methodType(Object.class, Object.class, Class.class));
             SAM_CONVERSION = LOOKUP.findStatic(CachedSAMClass.class, "coerceToSAM", MethodType.methodType(Object.class, Closure.class, Method.class, Class.class));
             HASHSET_CONSTRUCTOR = LOOKUP.findConstructor(HashSet.class, MethodType.methodType(void.class, Collection.class));
             ARRAYLIST_CONSTRUCTOR = LOOKUP.findConstructor(ArrayList.class, MethodType.methodType(void.class, Collection.class));
@@ -144,22 +142,22 @@ public class IndyGuardsFiltersAndSignatures {
      * {@link GroovyObject#invokeMethod(String, Object)} path as fallback.
      * This method is called by the handle as exception handler in case the
      * selected method causes a MissingMethodExecutionFailed, where
-     * we will just give through the exception, and a normal 
+     * we will just give through the exception, and a normal
      * MissingMethodException where we call {@link GroovyObject#invokeMethod(String, Object)}
      * if receiver class, the type transported by the exception and the name
-     * for the method stored in the exception and our current method name 
+     * for the method stored in the exception and our current method name
      * are equal.
      * Should those conditions not apply we just rethrow the exception.
      */
     public static Object invokeGroovyObjectInvoker(MissingMethodException e, Object receiver, String name, Object[] args) {
         if (e instanceof MissingMethodExecutionFailed) {
-            throw (MissingMethodException)e.getCause();
+            throw (MissingMethodException) e.getCause();
         } else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) {
             //TODO: we should consider calling this one directly for MetaClassImpl,
             //      then we save the new method selection
 
             // in case there's nothing else, invoke the object's own invokeMethod()
-            return ((GroovyObject)receiver).invokeMethod(name, args);
+            return ((GroovyObject) receiver).invokeMethod(name, args);
         } else {
             throw e;
         }
@@ -167,7 +165,7 @@ public class IndyGuardsFiltersAndSignatures {
 
     /**
      * Unwraps a {@link GroovyRuntimeException}.
-     * This method is called by the handle to unwrap internal exceptions 
+     * This method is called by the handle to unwrap internal exceptions
      * of the runtime.
      */
     public static Object unwrap(GroovyRuntimeException gre) throws Throwable {
@@ -179,7 +177,7 @@ public class IndyGuardsFiltersAndSignatures {
      */
     public static boolean isSameMetaClass(MetaClass mc, Object receiver) {
         //TODO: remove this method if possible by switchpoint usage
-        return receiver instanceof GroovyObject && mc==((GroovyObject)receiver).getMetaClass(); 
+        return receiver instanceof GroovyObject && mc == ((GroovyObject) receiver).getMetaClass();
     }
 
     /**
@@ -207,7 +205,7 @@ public class IndyGuardsFiltersAndSignatures {
      * return false if the Object is null.
      */
     public static boolean sameClass(Class c, Object o) {
-        if (o==null) return false;
+        if (o == null) return false;
         return o.getClass() == c;
     }
 }
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
index ef88dc0..1ba019b 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
@@ -39,194 +39,207 @@ import java.util.stream.Stream;
 /**
  * Bytecode level interface for bootstrap methods used by invokedynamic.
  * This class provides a logging ability by using the boolean system property
- * groovy.indy.logging. Other than that this class contains the 
+ * groovy.indy.logging. Other than that this class contains the
  * interfacing methods with bytecode for invokedynamic as well as some helper
  * methods and classes.
  */
 public class IndyInterface {
 
+    /**
+     * flags for method and property calls
+     */
+    public static final int
+            SAFE_NAVIGATION = 1, THIS_CALL = 2,
+            GROOVY_OBJECT = 4, IMPLICIT_THIS = 8,
+            SPREAD_CALL = 16, UNCACHED_CALL = 32;
+
+    /**
+     * Enum for easy differentiation between call types
+     */
+    public enum CallType {
         /**
-         * flags for method and property calls
+         * Method invocation type
          */
-        public static final int 
-            SAFE_NAVIGATION = 1,  THIS_CALL     = 2, 
-            GROOVY_OBJECT   = 4,  IMPLICIT_THIS = 8,
-            SPREAD_CALL     = 16, UNCACHED_CALL = 32;
-
+        METHOD("invoke"),
         /**
-         * Enum for easy differentiation between call types
+         * Constructor invocation type
          */
-        public enum CallType {
-            /**
-             * Method invocation type
-             */
-            METHOD("invoke"),
-            /**
-             * Constructor invocation type
-             */
-            INIT("init"),
-            /**
-             * Get property invocation type
-             */
-            GET("getProperty"),
-            /**
-             * Set property invocation type
-             */
-            SET("setProperty"),
-            /**
-             * Cast invocation type
-             */
-            CAST("cast");
-
-            private static final Map<String, CallType> NAME_CALLTYPE_MAP =
-                    Stream.of(CallType.values()).collect(Collectors.toMap(CallType::getCallSiteName, Function.identity()));
-
-            /**
-             * The name of the call site type
-             */
-            private final String name;
-
-            CallType(String callSiteName) {
-                this.name = callSiteName;
-            }
-
-            /**
-             * Returns the name of the call site type
-             */
-            public String getCallSiteName() {
-                return name;
-            }
-
-            public static CallType fromCallSiteName(String callSiteName) {
-                return NAME_CALLTYPE_MAP.get(callSiteName);
-            }
-        }
-
-        /** Logger */
-        protected static final Logger LOG;
-        /** boolean to indicate if logging for indy is enabled */
-        protected static final boolean LOG_ENABLED;
-        static {
-            boolean enableLogger = false;
-
-            LOG = Logger.getLogger(IndyInterface.class.getName());
-
-            try {
-                if (System.getProperty("groovy.indy.logging")!=null) {
-                    LOG.setLevel(Level.ALL);
-                    enableLogger = true;
-                }
-            } catch (SecurityException e) {
-                // Allow security managers to prevent system property access
-            }
-
-            LOG_ENABLED = enableLogger;
-        }
-        /** LOOKUP constant used for for example unreflect calls */
-        public static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
-        /** handle for the selectMethod method */
-        private static final MethodHandle SELECT_METHOD;
-        static {
-            MethodType mt = MethodType.methodType(Object.class, MutableCallSite.class, Class.class, String.class, int.class, Boolean.class, Boolean.class, Boolean.class, Object.class, Object[].class);
-            try {
-                SELECT_METHOD = LOOKUP.findStatic(IndyInterface.class, "selectMethod", mt);
-            } catch (Exception e) {
-                throw new GroovyBugError(e);
-            }
-        }
-
-        protected static SwitchPoint switchPoint = new SwitchPoint();
-        static {
-            GroovySystem.getMetaClassRegistry().addMetaClassRegistryChangeEventListener(cmcu -> invalidateSwitchPoints());
-        }
-
+        INIT("init"),
         /**
-         * Callback for constant meta class update change
+         * Get property invocation type
          */
-        protected static void invalidateSwitchPoints() {
-            if (LOG_ENABLED) {
-                 LOG.info("invalidating switch point");
-            }
-
-            synchronized(IndyInterface.class) {
-                SwitchPoint old = switchPoint;
-                switchPoint = new SwitchPoint();
-                SwitchPoint.invalidateAll(new SwitchPoint[]{old});
-            }
-        }
-
+        GET("getProperty"),
+        /**
+         * Set property invocation type
+         */
+        SET("setProperty"),
         /**
-         * bootstrap method for method calls from Groovy compiled code with indy 
-         * enabled. This method gets a flags parameter which uses the following 
-         * encoding:<ul>
-         * <li>{@value #SAFE_NAVIGATION} is the flag value for safe navigation see {@link #SAFE_NAVIGATION}</li>
-         * <li>{@value #THIS_CALL} is the flag value for a call on this see {@link #THIS_CALL}</li>
-         * </ul> 
-         * @param caller - the caller
-         * @param callType - the type of the call
-         * @param type - the call site type
-         * @param name - the real method name
-         * @param flags - call flags
-         * @return the produced CallSite
-         * @since Groovy 2.1.0
+         * Cast invocation type
          */
-        public static CallSite bootstrap(Lookup caller, String callType, MethodType type, String name, int flags) {
-            boolean safe = (flags & SAFE_NAVIGATION) != 0;
-            boolean thisCall = (flags & THIS_CALL) != 0;
-            boolean spreadCall = (flags & SPREAD_CALL) != 0;
+        CAST("cast");
 
-            CallType ct = CallType.fromCallSiteName(callType);
-            if (null == ct) throw new GroovyBugError("Unknown call type: " + callType);
+        private static final Map<String, CallType> NAME_CALLTYPE_MAP =
+                Stream.of(CallType.values()).collect(Collectors.toMap(CallType::getCallSiteName, Function.identity()));
 
-            int callID = ct.ordinal();
+        /**
+         * The name of the call site type
+         */
+        private final String name;
 
-            return realBootstrap(caller, name, callID, type, safe, thisCall, spreadCall);
+        CallType(String callSiteName) {
+            this.name = callSiteName;
         }
 
         /**
-         * backing bootstrap method with all parameters
+         * Returns the name of the call site type
          */
-        private static CallSite realBootstrap(Lookup caller, String name, int callID, MethodType type, boolean safe, boolean thisCall, boolean spreadCall) {
-            // since indy does not give us the runtime types
-            // we produce first a dummy call site, which then changes the target to one,
-            // that does the method selection including the direct call to the
-            // real method.
-            MutableCallSite mc = new MutableCallSite(type);
-            MethodHandle mh = makeFallBack(mc,caller.lookupClass(),name,callID,type,safe,thisCall,spreadCall);
-            mc.setTarget(mh);
-            return mc;
+        public String getCallSiteName() {
+            return name;
         }
 
-        /**
-         * Makes a fallback method for an invalidated method selection
-         */
-        protected static MethodHandle makeFallBack(MutableCallSite mc, Class<?> sender, String name, int callID, MethodType type, boolean safeNavigation, boolean thisCall, boolean spreadCall) {
-            MethodHandle mh = MethodHandles.insertArguments(SELECT_METHOD, 0, mc, sender, name, callID, safeNavigation, thisCall, spreadCall, /*dummy receiver:*/ 1);
-            mh =    mh.asCollector(Object[].class, type.parameterCount()).
-                    asType(type);
-            return mh;
+        public static CallType fromCallSiteName(String callSiteName) {
+            return NAME_CALLTYPE_MAP.get(callSiteName);
+        }
+    }
+
+    /**
+     * Logger
+     */
+    protected static final Logger LOG;
+    /**
+     * boolean to indicate if logging for indy is enabled
+     */
+    protected static final boolean LOG_ENABLED;
+
+    static {
+        boolean enableLogger = false;
+
+        LOG = Logger.getLogger(IndyInterface.class.getName());
+
+        try {
+            if (System.getProperty("groovy.indy.logging") != null) {
+                LOG.setLevel(Level.ALL);
+                enableLogger = true;
+            }
+        } catch (SecurityException e) {
+            // Allow security managers to prevent system property access
         }
 
-        /**
-         * Core method for indy method selection using runtime types.
-         */
-        public static Object selectMethod(MutableCallSite callSite, Class sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments) throws Throwable {
-            Selector selector = Selector.getSelector(callSite, sender, methodName, callID, safeNavigation, thisCall, spreadCall, arguments); 
-            selector.setCallSiteTarget();
+        LOG_ENABLED = enableLogger;
+    }
+
+    /**
+     * LOOKUP constant used for for example unreflect calls
+     */
+    public static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
+    /**
+     * handle for the selectMethod method
+     */
+    private static final MethodHandle SELECT_METHOD;
+
+    static {
+        MethodType mt = MethodType.methodType(Object.class, MutableCallSite.class, Class.class, String.class, int.class, Boolean.class, Boolean.class, Boolean.class, Object.class, Object[].class);
+        try {
+            SELECT_METHOD = LOOKUP.findStatic(IndyInterface.class, "selectMethod", mt);
+        } catch (Exception e) {
+            throw new GroovyBugError(e);
+        }
+    }
+
+    protected static SwitchPoint switchPoint = new SwitchPoint();
 
-            MethodHandle call = selector.handle.asSpreader(Object[].class, arguments.length);
-            call = call.asType(MethodType.methodType(Object.class,Object[].class));
-            return call.invokeExact(arguments);
+    static {
+        GroovySystem.getMetaClassRegistry().addMetaClassRegistryChangeEventListener(cmcu -> invalidateSwitchPoints());
+    }
+
+    /**
+     * Callback for constant meta class update change
+     */
+    protected static void invalidateSwitchPoints() {
+        if (LOG_ENABLED) {
+            LOG.info("invalidating switch point");
         }
 
-        /**
-         * @since 2.5.0
-         */
-         public static CallSite staticArrayAccess(MethodHandles.Lookup lookup, String name, MethodType type) {
-            if (type.parameterCount()==2) {
-                return new ConstantCallSite(IndyArrayAccess.arrayGet(type));
-            } else {
-                return new ConstantCallSite(IndyArrayAccess.arraySet(type));
-            }
-         }
+        synchronized (IndyInterface.class) {
+            SwitchPoint old = switchPoint;
+            switchPoint = new SwitchPoint();
+            SwitchPoint.invalidateAll(new SwitchPoint[]{old});
+        }
+    }
+
+    /**
+     * bootstrap method for method calls from Groovy compiled code with indy
+     * enabled. This method gets a flags parameter which uses the following
+     * encoding:<ul>
+     * <li>{@value #SAFE_NAVIGATION} is the flag value for safe navigation see {@link #SAFE_NAVIGATION}</li>
+     * <li>{@value #THIS_CALL} is the flag value for a call on this see {@link #THIS_CALL}</li>
+     * </ul>
+     *
+     * @param caller   - the caller
+     * @param callType - the type of the call
+     * @param type     - the call site type
+     * @param name     - the real method name
+     * @param flags    - call flags
+     * @return the produced CallSite
+     * @since Groovy 2.1.0
+     */
+    public static CallSite bootstrap(Lookup caller, String callType, MethodType type, String name, int flags) {
+        boolean safe = (flags & SAFE_NAVIGATION) != 0;
+        boolean thisCall = (flags & THIS_CALL) != 0;
+        boolean spreadCall = (flags & SPREAD_CALL) != 0;
+
+        CallType ct = CallType.fromCallSiteName(callType);
+        if (null == ct) throw new GroovyBugError("Unknown call type: " + callType);
+
+        int callID = ct.ordinal();
+
+        return realBootstrap(caller, name, callID, type, safe, thisCall, spreadCall);
+    }
+
+    /**
+     * backing bootstrap method with all parameters
+     */
+    private static CallSite realBootstrap(Lookup caller, String name, int callID, MethodType type, boolean safe, boolean thisCall, boolean spreadCall) {
+        // since indy does not give us the runtime types
+        // we produce first a dummy call site, which then changes the target to one,
+        // that does the method selection including the direct call to the
+        // real method.
+        MutableCallSite mc = new MutableCallSite(type);
+        MethodHandle mh = makeFallBack(mc, caller.lookupClass(), name, callID, type, safe, thisCall, spreadCall);
+        mc.setTarget(mh);
+        return mc;
+    }
+
+    /**
+     * Makes a fallback method for an invalidated method selection
+     */
+    protected static MethodHandle makeFallBack(MutableCallSite mc, Class<?> sender, String name, int callID, MethodType type, boolean safeNavigation, boolean thisCall, boolean spreadCall) {
+        MethodHandle mh = MethodHandles.insertArguments(SELECT_METHOD, 0, mc, sender, name, callID, safeNavigation, thisCall, spreadCall, /*dummy receiver:*/ 1);
+        mh = mh.asCollector(Object[].class, type.parameterCount()).
+                asType(type);
+        return mh;
+    }
+
+    /**
+     * Core method for indy method selection using runtime types.
+     */
+    public static Object selectMethod(MutableCallSite callSite, Class sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments) throws Throwable {
+        Selector selector = Selector.getSelector(callSite, sender, methodName, callID, safeNavigation, thisCall, spreadCall, arguments);
+        selector.setCallSiteTarget();
+
+        MethodHandle call = selector.handle.asSpreader(Object[].class, arguments.length);
+        call = call.asType(MethodType.methodType(Object.class, Object[].class));
+        return call.invokeExact(arguments);
+    }
+
+    /**
+     * @since 2.5.0
+     */
+    public static CallSite staticArrayAccess(MethodHandles.Lookup lookup, String name, MethodType type) {
+        if (type.parameterCount() == 2) {
+            return new ConstantCallSite(IndyArrayAccess.arrayGet(type));
+        } else {
+            return new ConstantCallSite(IndyArrayAccess.arraySet(type));
+        }
+    }
 }
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyMath.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyMath.java
index 67a6712..8b2dd7b 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyMath.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyMath.java
@@ -37,108 +37,109 @@ import static org.codehaus.groovy.vmplugin.v7.TypeHelper.replaceWithMoreSpecific
 /**
  * This class contains math operations used by indy instead of the normal
  * meta method and call site caching system. The goal is to avoid boxing, thus
- * use primitive types for parameters and return types where possible. 
- * WARNING: This class is for internal use only. Do not use it outside of the 
+ * use primitive types for parameters and return types where possible.
+ * WARNING: This class is for internal use only. Do not use it outside of the
  * org.codehaus.groovy.vmplugin.v7 package of groovy-core.
  */
 public class IndyMath {
-    
-    private static final MethodType 
-        IV   = MethodType.methodType(Void.TYPE, int.class),
-        II   = MethodType.methodType(int.class, int.class),
-        IIV  = MethodType.methodType(Void.TYPE, int.class, int.class),
-        III  = MethodType.methodType(int.class, int.class, int.class),
-        LV   = MethodType.methodType(Void.TYPE, long.class),
-        LL   = MethodType.methodType(long.class, long.class),
-        LLV  = MethodType.methodType(Void.TYPE, long.class, long.class),
-        LLL  = MethodType.methodType(long.class, long.class, long.class),
-        DV   = MethodType.methodType(Void.TYPE, double.class),
-        DD   = MethodType.methodType(double.class, double.class),
-        DDV  = MethodType.methodType(Void.TYPE, double.class, double.class),
-        DDD  = MethodType.methodType(double.class, double.class, double.class),
-        GV  = MethodType.methodType(Void.TYPE, BigDecimal.class),
-        GGV  = MethodType.methodType(Void.TYPE, BigDecimal.class, BigDecimal.class),
-        OOV  = MethodType.methodType(Void.TYPE, Object.class, Object.class);
+
+    private static final MethodType
+            IV = MethodType.methodType(Void.TYPE, int.class),
+            II = MethodType.methodType(int.class, int.class),
+            IIV = MethodType.methodType(Void.TYPE, int.class, int.class),
+            III = MethodType.methodType(int.class, int.class, int.class),
+            LV = MethodType.methodType(Void.TYPE, long.class),
+            LL = MethodType.methodType(long.class, long.class),
+            LLV = MethodType.methodType(Void.TYPE, long.class, long.class),
+            LLL = MethodType.methodType(long.class, long.class, long.class),
+            DV = MethodType.methodType(Void.TYPE, double.class),
+            DD = MethodType.methodType(double.class, double.class),
+            DDV = MethodType.methodType(Void.TYPE, double.class, double.class),
+            DDD = MethodType.methodType(double.class, double.class, double.class),
+            GV = MethodType.methodType(Void.TYPE, BigDecimal.class),
+            GGV = MethodType.methodType(Void.TYPE, BigDecimal.class, BigDecimal.class),
+            OOV = MethodType.methodType(Void.TYPE, Object.class, Object.class);
 
     private static void makeMapEntry(String method, MethodType[] keys, MethodType[] values) throws NoSuchMethodException, IllegalAccessException {
-        Map<MethodType,MethodHandle> xMap = new HashMap();
+        Map<MethodType, MethodHandle> xMap = new HashMap();
         methods.put(method, xMap);
-        for (int i=0; i<keys.length; i++) {
+        for (int i = 0; i < keys.length; i++) {
             xMap.put(keys[i], LOOKUP.findStatic(IndyMath.class, method, values[i]));
         }
     }
-    
-    private static Map<String, Map<MethodType,MethodHandle>> methods = new HashMap();
+
+    private static Map<String, Map<MethodType, MethodHandle>> methods = new HashMap();
+
     static {
         try {
-            
-            MethodType[] keys = new MethodType[]{IIV,LLV,DDV};
-            MethodType[] values = new MethodType[]{III,LLL,DDD};
-            makeMapEntry("minus",keys,values);
-            makeMapEntry("plus",keys,values);
-            makeMapEntry("multiply",keys,values);
-            
+
+            MethodType[] keys = new MethodType[]{IIV, LLV, DDV};
+            MethodType[] values = new MethodType[]{III, LLL, DDD};
+            makeMapEntry("minus", keys, values);
+            makeMapEntry("plus", keys, values);
+            makeMapEntry("multiply", keys, values);
+
             keys = new MethodType[]{DDV};
             values = new MethodType[]{DDD};
-            makeMapEntry("div",keys,values);
-            
-            keys = new MethodType[]{IV,LV,DV};
-            values = new MethodType[]{II,LL,DD};
-            makeMapEntry("next",keys,values);
-            makeMapEntry("previous",keys,values);
-            
-            keys = new MethodType[]{IIV,LLV};
-            values = new MethodType[]{III,LLL};
-            makeMapEntry("mod",keys,values);
-            makeMapEntry("or",keys,values);
-            makeMapEntry("xor",keys,values);
-            makeMapEntry("and",keys,values);
-            makeMapEntry("leftShift",keys,values);
-            makeMapEntry("rightShift",keys,values);
-            
+            makeMapEntry("div", keys, values);
+
+            keys = new MethodType[]{IV, LV, DV};
+            values = new MethodType[]{II, LL, DD};
+            makeMapEntry("next", keys, values);
+            makeMapEntry("previous", keys, values);
+
+            keys = new MethodType[]{IIV, LLV};
+            values = new MethodType[]{III, LLL};
+            makeMapEntry("mod", keys, values);
+            makeMapEntry("or", keys, values);
+            makeMapEntry("xor", keys, values);
+            makeMapEntry("and", keys, values);
+            makeMapEntry("leftShift", keys, values);
+            makeMapEntry("rightShift", keys, values);
+
         } catch (Exception e) {
             throw new GroovyBugError(e);
         }
     }
-    
+
     /**
      * Choose a method to replace the originally chosen metaMethod to have a
-     * more efficient call path. 
+     * more efficient call path.
      */
     public static boolean chooseMathMethod(Selector info, MetaMethod metaMethod) {
-        Map<MethodType,MethodHandle> xmap = methods.get(info.name);
-        if (xmap==null) return false;
+        Map<MethodType, MethodHandle> xmap = methods.get(info.name);
+        if (xmap == null) return false;
+
+        MethodType type = replaceWithMoreSpecificType(info.args, info.targetType);
+        type = widenOperators(type);
 
-        MethodType type = replaceWithMoreSpecificType(info.args, info.targetType); 
-        type = widenOperators(type); 
-        
         MethodHandle handle = xmap.get(type);
-        if (handle==null) return false;
-        
+        if (handle == null) return false;
+
         info.handle = handle;
         return true;
     }
-    
+
     /**
      * Widens the operators. For math operations like a+b we generally
      * execute them using a conversion to certain types. If a for example
-     * is an int and b a byte, we do the operation using integer math. This 
+     * is an int and b a byte, we do the operation using integer math. This
      * method gives a simplified MethodType that contains the two operators
      * with this widening according to Groovy rules applied. That means both
-     * parameters in the MethodType will have the same type. 
+     * parameters in the MethodType will have the same type.
      */
     private static MethodType widenOperators(MethodType mt) {
-        if (mt.parameterCount()==2) {
+        if (mt.parameterCount() == 2) {
             Class leftType = mt.parameterType(0);
             Class rightType = mt.parameterType(1);
-            
+
             if (isIntCategory(leftType) && isIntCategory(rightType)) return IIV;
             if (isLongCategory(leftType) && isLongCategory(rightType)) return LLV;
             if (isBigDecCategory(leftType) && isBigDecCategory(rightType)) return GGV;
             if (isDoubleCategory(leftType) && isDoubleCategory(rightType)) return DDV;
-            
+
             return OOV;
-        } else if (mt.parameterCount()==1) {
+        } else if (mt.parameterCount() == 1) {
             Class leftType = mt.parameterType(0);
             if (isIntCategory(leftType)) return IV;
             if (isLongCategory(leftType)) return LV;
@@ -147,44 +148,124 @@ public class IndyMath {
         }
         return mt;
     }
-    
+
     // math methods used by indy
-    
+
     // int x int
-    public static int plus(int a, int b) {return a+b;}
-    public static int minus(int a, int b) {return a-b;}
-    public static int multiply(int a, int b) {return a*b;}
-    public static int mod(int a, int b) {return a%b;}
-    public static int or(int a, int b) {return a|b;}
-    public static int xor(int a, int b) {return a^b;}
-    public static int and(int a, int b) {return a&b;}
-    public static int leftShift(int a, int b) {return a<<b;}
-    public static int rightShift(int a, int b) {return a>>b;}
-    
+    public static int plus(int a, int b) {
+        return a + b;
+    }
+
+    public static int minus(int a, int b) {
+        return a - b;
+    }
+
+    public static int multiply(int a, int b) {
+        return a * b;
+    }
+
+    public static int mod(int a, int b) {
+        return a % b;
+    }
+
+    public static int or(int a, int b) {
+        return a | b;
+    }
+
+    public static int xor(int a, int b) {
+        return a ^ b;
+    }
+
+    public static int and(int a, int b) {
+        return a & b;
+    }
+
+    public static int leftShift(int a, int b) {
+        return a << b;
+    }
+
+    public static int rightShift(int a, int b) {
+        return a >> b;
+    }
+
     // long x long
-    public static long plus(long a, long b) {return a+b;}
-    public static long minus(long a, long b) {return a-b;}
-    public static long multiply(long a, long b) {return a*b;}
-    public static long mod(long a, long b) {return a%b;}
-    public static long or(long a, long b) {return a|b;}
-    public static long xor(long a, long b) {return a^b;}
-    public static long and(long a, long b) {return a&b;}
-    public static long leftShift(long a, long b) {return a<<b;}
-    public static long rightShift(long a, long b) {return a>>b;}
-    
+    public static long plus(long a, long b) {
+        return a + b;
+    }
+
+    public static long minus(long a, long b) {
+        return a - b;
+    }
+
+    public static long multiply(long a, long b) {
+        return a * b;
+    }
+
+    public static long mod(long a, long b) {
+        return a % b;
+    }
+
+    public static long or(long a, long b) {
+        return a | b;
+    }
+
+    public static long xor(long a, long b) {
+        return a ^ b;
+    }
+
+    public static long and(long a, long b) {
+        return a & b;
+    }
+
+    public static long leftShift(long a, long b) {
+        return a << b;
+    }
+
+    public static long rightShift(long a, long b) {
+        return a >> b;
+    }
+
     // double x double
-    public static double plus(double a, double b) {return a+b;}
-    public static double minus(double a, double b) {return a-b;}
-    public static double multiply(double a, double b) {return a*b;}
-    public static double div(double a, double b){return a/b;}
-    
+    public static double plus(double a, double b) {
+        return a + b;
+    }
+
+    public static double minus(double a, double b) {
+        return a - b;
+    }
+
+    public static double multiply(double a, double b) {
+        return a * b;
+    }
+
+    public static double div(double a, double b) {
+        return a / b;
+    }
+
     // next & previous
-    public static int next(int i) {return i+1;}
-    public static long next(long l) {return l+1;}
-    public static double next(double d) {return d+1;}
-    public static int previous(int i) {return i-1;}
-    public static long previous(long l) {return l-1;}
-    public static double previous(double d) {return d-1;}
+    public static int next(int i) {
+        return i + 1;
+    }
+
+    public static long next(long l) {
+        return l + 1;
+    }
+
+    public static double next(double d) {
+        return d + 1;
+    }
+
+    public static int previous(int i) {
+        return i - 1;
+    }
+
+    public static long previous(long l) {
+        return l - 1;
+    }
+
+    public static double previous(double d) {
+        return d - 1;
+    }
 
     /*
      further operations to be handled here maybe:
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/Java7.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/Java7.java
index bc93bbd..ac829db 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/Java7.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/Java7.java
@@ -31,14 +31,15 @@ import java.security.PrivilegedAction;
 
 /**
  * Java 7 based functions.
- *
+ * <p>
  * For crude customization, you can add your own methods to your own version and place it on the classpath ahead of this one.
  */
 public class Java7 extends Java6 {
     private static class LookupHolder {
         private static final Constructor<MethodHandles.Lookup> LOOKUP_Constructor;
+
         static {
-            Constructor<MethodHandles.Lookup> con = null;
+            Constructor<MethodHandles.Lookup> con;
             try {
                 con = MethodHandles.Lookup.class.getDeclaredConstructor(Class.class, int.class);
             } catch (NoSuchMethodException e) {
@@ -69,7 +70,7 @@ public class Java7 extends Java6 {
 
     @Override
     public void invalidateCallSites() {
-    	IndyInterface.invalidateSwitchPoints();
+        IndyInterface.invalidateSwitchPoints();
     }
 
     @Override
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
index 55d4ee1..663d254 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
@@ -101,7 +101,7 @@ import static org.codehaus.groovy.vmplugin.v7.IndyInterface.switchPoint;
 public abstract class Selector {
     public Object[] args, originalArguments;
     public MetaMethod method;
-    public MethodType targetType,currentType;
+    public MethodType targetType, currentType;
     public String name;
     public MethodHandle handle;
     public boolean useMetaClass = false, cache = true;
@@ -115,7 +115,9 @@ public abstract class Selector {
     public boolean catchException = true;
     public CallType callType;
 
-    /** Cache values for read-only access */
+    /**
+     * Cache values for read-only access
+     */
     private static final CallType[] CALL_TYPE_VALUES = CallType.values();
 
     /**
@@ -124,31 +126,36 @@ public abstract class Selector {
     public static Selector getSelector(MutableCallSite callSite, Class sender, String methodName, int callID, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments) {
         CallType callType = CALL_TYPE_VALUES[callID];
         switch (callType) {
-            case INIT: return new InitSelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments);
-            case METHOD: return new MethodSelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments);
-            case GET: 
+            case INIT:
+                return new InitSelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments);
+            case METHOD:
+                return new MethodSelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments);
+            case GET:
                 return new PropertySelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments);
             case SET:
                 throw new GroovyBugError("your call tried to do a property set, which is not supported.");
-            case CAST:  return new CastSelector(callSite, arguments);
-            default: throw new GroovyBugError("unexpected call type");
+            case CAST:
+                return new CastSelector(callSite, arguments);
+            default:
+                throw new GroovyBugError("unexpected call type");
         }
     }
+
     abstract void setCallSiteTarget();
 
     /**
-     * Helper method to transform the given arguments, consisting of the receiver 
+     * Helper method to transform the given arguments, consisting of the receiver
      * and the actual arguments in an Object[], into a new Object[] consisting
-     * of the receiver and the arguments directly. Before the size of args was 
+     * of the receiver and the arguments directly. Before the size of args was
      * always 2, the returned Object[] will have a size of 1+n, where n is the
      * number arguments.
      */
     private static Object[] spread(Object[] args, boolean spreadCall) {
         if (!spreadCall) return args;
         Object[] normalArguments = (Object[]) args[1];
-        Object[] ret = new Object[normalArguments.length+1];
+        Object[] ret = new Object[normalArguments.length + 1];
         ret[0] = args[0];
-        System.arraycopy(normalArguments, 0, ret, 1, ret.length-1);
+        System.arraycopy(normalArguments, 0, ret, 1, ret.length - 1);
         return ret;
     }
 
@@ -188,26 +195,26 @@ public abstract class Selector {
         }
 
         private void castAndSetGuards() {
-            handle =  MethodHandles.explicitCastArguments(handle,targetType);
+            handle = MethodHandles.explicitCastArguments(handle, targetType);
             setGuards(args[0]);
             doCallSiteTargetSet();
         }
 
         private void handleNullWithoutBoolean() {
-            if (handle!=null || args[0]!=null) return;
+            if (handle != null || args[0] != null) return;
 
             if (staticTargetType.isPrimitive()) {
-                handle = MethodHandles.insertArguments(GROOVY_CAST_EXCEPTION,1,staticTargetType);
+                handle = MethodHandles.insertArguments(GROOVY_CAST_EXCEPTION, 1, staticTargetType);
                 // need to call here here because we used the static target type
                 // it won't be done otherwise because handle.type() == callSite.type()
-                castAndSetGuards(); 
+                castAndSetGuards();
             } else {
-               handle = MethodHandles.identity(staticSourceType);
+                handle = MethodHandles.identity(staticSourceType);
             }
         }
 
         private void handleInstanceCase() {
-            if (handle!=null) return;
+            if (handle != null) return;
 
             if (staticTargetType.isAssignableFrom(args[0].getClass())) {
                 handle = MethodHandles.identity(staticSourceType);
@@ -221,7 +228,7 @@ public abstract class Selector {
         }
 
         private void handleCollections() {
-            if (handle!=null) return;
+            if (handle != null) return;
 
             if (!(args[0] instanceof Collection)) return;
             if (isAbstractClassOf(HashSet.class, staticTargetType)) {
@@ -232,33 +239,33 @@ public abstract class Selector {
         }
 
         private void handleSAM() {
-            if (handle!=null) return;
+            if (handle != null) return;
 
             if (!(args[0] instanceof Closure)) return;
             Method m = CachedSAMClass.getSAMMethod(staticTargetType);
-            if (m==null) return;
+            if (m == null) return;
             //TODO: optimize: add guard based on type Closure
             handle = MethodHandles.insertArguments(SAM_CONVERSION, 1, m, staticTargetType);
         }
 
         private void castToTypeFallBack() {
-            if (handle!=null) return;
+            if (handle != null) return;
 
             // generic fallback to castToType
             handle = MethodHandles.insertArguments(DTT_CAST_TO_TYPE, 1, staticTargetType);
         }
 
         private void handleBoolean() {
-            if (handle!=null) return;
+            if (handle != null) return;
 
             // boolean->boolean, Boolean->boolean, boolean->Boolean
             // is handled by compiler
             // that leaves (T)Z and (T)Boolean, where T is the static type
             // but runtime type of T might be Boolean
 
-            boolean primitive = staticTargetType==boolean.class;
-            if (!primitive && staticTargetType!=Boolean.class) return;
-            if (args[0]==null) {
+            boolean primitive = staticTargetType == boolean.class;
+            if (!primitive && staticTargetType != Boolean.class) return;
+            if (args[0] == null) {
                 if (primitive) {
                     handle = MethodHandles.constant(boolean.class, false);
                     handle = MethodHandles.dropArguments(handle, 0, staticSourceType);
@@ -268,7 +275,7 @@ public abstract class Selector {
             } else if (args[0] instanceof Boolean) {
                 // give value through or unbox
                 handle = BOOLEAN_IDENTITY;
-            } else { 
+            } else {
                 //call asBoolean
                 name = "asBoolean";
                 super.setCallSiteTarget();
@@ -299,14 +306,14 @@ public abstract class Selector {
             Object receiver = getCorrectedReceiver();
             if (receiver instanceof GroovyObject) {
                 Class aClass = receiver.getClass();
-                Method reflectionMethod = null;
                 try {
-                    reflectionMethod = aClass.getMethod("getProperty", String.class);
+                    Method reflectionMethod = aClass.getMethod("getProperty", String.class);
                     if (!reflectionMethod.isSynthetic() && !isMarkedInternal(reflectionMethod)) {
                         handle = MethodHandles.insertArguments(GROOVY_OBJECT_GET_PROPERTY, 1, name);
                         return;
                     }
-                } catch (ReflectiveOperationException e)  {}
+                } catch (ReflectiveOperationException ignored) {
+                }
             } else if (receiver instanceof Class) {
                 handle = MOP_GET;
                 handle = MethodHandles.insertArguments(handle, 2, name);
@@ -314,9 +321,9 @@ public abstract class Selector {
                 return;
             }
 
-            if (method!=null || mci==null) return;
+            if (method != null || mci == null) return;
             Class chosenSender = this.sender;
-            if (mci.getTheClass()!= chosenSender && GroovyCategorySupport.hasCategoryInCurrentThread()) {
+            if (mci.getTheClass() != chosenSender && GroovyCategorySupport.hasCategoryInCurrentThread()) {
                 chosenSender = mci.getTheClass();
             }
             MetaProperty res = mci.getEffectiveGetMetaProperty(chosenSender, receiver, name, false);
@@ -341,7 +348,7 @@ public abstract class Selector {
                 }
             } else {
                 handle = META_PROPERTY_GETTER.bindTo(res);
-            } 
+            }
         }
 
         private boolean isMarkedInternal(Method reflectionMethod) {
@@ -355,21 +362,21 @@ public abstract class Selector {
          */
         @Override
         public void setHandleForMetaMethod() {
-            if (handle!=null) return;
+            if (handle != null) return;
             super.setHandleForMetaMethod();
-            if (handle != null && insertName && handle.type().parameterCount()==2) {
+            if (handle != null && insertName && handle.type().parameterCount() == 2) {
                 handle = MethodHandles.insertArguments(handle, 1, name);
             }
         }
 
         /**
-         * The MOP requires all get property operations to go through 
-         * {@link GroovyObject#getProperty(String)}. We do this in case 
+         * The MOP requires all get property operations to go through
+         * {@link GroovyObject#getProperty(String)}. We do this in case
          * no property was found before.
          */
         @Override
-        public void setMetaClassCallHandleIfNedded(boolean standardMetaClass) {
-            if (handle!=null) return;
+        public void setMetaClassCallHandleIfNeeded(boolean standardMetaClass) {
+            if (handle != null) return;
             useMetaClass = true;
             if (LOG_ENABLED) LOG.info("set meta class invocation path for property get.");
             handle = MethodHandles.insertArguments(MOP_GET, 2, this.name);
@@ -407,7 +414,7 @@ public abstract class Selector {
          */
         @Override
         public void chooseMeta(MetaClassImpl mci) {
-            if (mci==null) return;
+            if (mci == null) return;
             if (LOG_ENABLED) LOG.info("getting constructor");
             Object[] newArgs = removeRealReceiver(args);
             method = mci.retrieveConstructor(newArgs);
@@ -425,7 +432,7 @@ public abstract class Selector {
          */
         @Override
         public void setHandleForMetaMethod() {
-            if (method==null) return;
+            if (method == null) return;
             if (method instanceof MetaConstructor) {
                 if (LOG_ENABLED) LOG.info("meta method is MetaConstructor instance");
                 MetaConstructor mc = (MetaConstructor) method;
@@ -449,7 +456,7 @@ public abstract class Selector {
                 MethodHandle con = BEAN_CONSTRUCTOR_PROPERTY_SETTER.bindTo(mc);
                 // inner class case
                 MethodType foldTargetType = MethodType.methodType(Object.class);
-                if (args.length==3) {
+                if (args.length == 3) {
                     con = MethodHandles.dropArguments(con, 1, targetType.parameterType(1));
                     foldTargetType = foldTargetType.insertParameterTypes(0, targetType.parameterType(1));
                 }
@@ -461,7 +468,7 @@ public abstract class Selector {
         }
 
         /**
-         * In case of a bean constructor we don't do any varags or implicit null argument 
+         * In case of a bean constructor we don't do any varags or implicit null argument
          * transformations. Otherwise we do the same as for {@link MethodSelector#correctParameterLength()}
          */
         @Override
@@ -484,12 +491,12 @@ public abstract class Selector {
          * Set MOP based constructor invocation path.
          */
         @Override
-        public void setMetaClassCallHandleIfNedded(boolean standardMetaClass) {
-            if (handle!=null) return;
+        public void setMetaClassCallHandleIfNeeded(boolean standardMetaClass) {
+            if (handle != null) return;
             useMetaClass = true;
             if (LOG_ENABLED) LOG.info("set meta class invocation path");
             handle = MOP_INVOKE_CONSTRUCTOR.bindTo(mc);
-            handle = handle.asCollector(Object[].class, targetType.parameterCount()-1);
+            handle = handle.asCollector(Object[].class, targetType.parameterCount() - 1);
             handle = MethodHandles.dropArguments(handle, 0, Class.class);
             if (LOG_ENABLED) LOG.info("create collector for arguments");
         }
@@ -501,9 +508,10 @@ public abstract class Selector {
      * calls as well as getProperty calls.
      */
     private static class MethodSelector extends Selector {
-        private static final Object[] SINGLE_NULL_ARRAY = { null };
+        private static final Object[] SINGLE_NULL_ARRAY = {null};
         protected MetaClass mc;
         private boolean isCategoryMethod;
+
         public MethodSelector(MutableCallSite callSite, Class sender, String methodName, CallType callType, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object[] arguments) {
             this.callType = callType;
             this.targetType = callSite.type();
@@ -513,7 +521,7 @@ public abstract class Selector {
             this.callSite = callSite;
             this.sender = sender;
             this.safeNavigationOrig = safeNavigation;
-            this.safeNavigation = safeNavigation && arguments[0]==null;
+            this.safeNavigation = safeNavigation && arguments[0] == null;
             this.thisCall = thisCall;
             this.spread = spreadCall;
             this.cache = !spread;
@@ -529,7 +537,7 @@ public abstract class Selector {
                                 "\n\t\tthisCall: " + thisCall +
                                 "\n\t\tspreadCall: " + spreadCall +
                                 "\n\t\twith " + arguments.length + " arguments");
-                for (int i=0; i<arguments.length; i++) {
+                for (int i = 0; i < arguments.length; i++) {
                     msg.append("\n\t\t\targument[").append(i).append("] = ");
                     if (arguments[i] == null) {
                         msg.append("null");
@@ -544,12 +552,12 @@ public abstract class Selector {
         /**
          * Sets the null constant for safe navigation.
          * In case of foo?.bar() and foo being null, we don't call the method,
-         * instead we simply return null. This produces a handle, which will 
+         * instead we simply return null. This produces a handle, which will
          * return the constant.
          */
         public boolean setNullForSafeNavigation() {
             if (!safeNavigation) return false;
-            handle = MethodHandles.dropArguments(NULL_REF,0,targetType.parameterArray());
+            handle = MethodHandles.dropArguments(NULL_REF, 0, targetType.parameterArray());
             if (LOG_ENABLED) LOG.info("set null returning handle for safe navigation");
             return true;
         }
@@ -568,7 +576,8 @@ public abstract class Selector {
                 ClassLoader cl = c.getClassLoader();
                 try {
                     Class.forName(c.getName(), true, cl);
-                } catch (ClassNotFoundException e) {}
+                } catch (ClassNotFoundException ignored) {
+                }
                 mc = GroovySystem.getMetaClassRegistry().getMetaClass(c);
                 this.cache &= !ClassInfo.getClassInfo(c).hasPerInstanceMetaClasses();
             } else {
@@ -586,7 +595,7 @@ public abstract class Selector {
          * or the meta class is an AdaptingMetaClass.
          */
         public void chooseMeta(MetaClassImpl mci) {
-            if (mci==null) return;
+            if (mci == null) return;
             Object receiver = getCorrectedReceiver();
             Object[] newArgs = removeRealReceiver(args);
             if (receiver instanceof Class) {
@@ -594,16 +603,19 @@ public abstract class Selector {
                 if (!mci.hasCustomStaticInvokeMethod()) method = mci.retrieveStaticMethod(name, newArgs);
             } else {
                 String changedName = name;
-                if (receiver instanceof GeneratedClosure && changedName.equals("call")) {changedName = "doCall";}
-                if (!mci.hasCustomInvokeMethod()) method = mci.getMethodWithCaching(selectionBase, changedName, newArgs, false);
+                if (receiver instanceof GeneratedClosure && changedName.equals("call")) {
+                    changedName = "doCall";
+                }
+                if (!mci.hasCustomInvokeMethod())
+                    method = mci.getMethodWithCaching(selectionBase, changedName, newArgs, false);
             }
-            if (LOG_ENABLED) LOG.info("retrieved method from meta class: "+method);
+            if (LOG_ENABLED) LOG.info("retrieved method from meta class: " + method);
         }
 
         /**
          * Creates a MethodHandle using a before selected MetaMethod.
          * If the MetaMethod has reflective information available, then
-         * we will use that information to create the target MethodHandle. 
+         * we will use that information to create the target MethodHandle.
          * If that is not the case we will produce a handle, which will use the
          * MetaMethod itself for invocation.
          */
@@ -622,9 +634,9 @@ public abstract class Selector {
             }
 
             boolean isCategoryTypeMethod = metaMethod instanceof NewInstanceMetaMethod;
-            if (LOG_ENABLED) LOG.info("meta method is category type method: "+isCategoryTypeMethod);
+            if (LOG_ENABLED) LOG.info("meta method is category type method: " + isCategoryTypeMethod);
             boolean isStaticCategoryTypeMethod = metaMethod instanceof NewStaticMetaMethod;
-            if (LOG_ENABLED) LOG.info("meta method is static category type method: "+isCategoryTypeMethod);
+            if (LOG_ENABLED) LOG.info("meta method is static category type method: " + isCategoryTypeMethod);
 
             if (metaMethod instanceof ReflectionMetaMethod) {
                 if (LOG_ENABLED) LOG.info("meta method is reflective method");
@@ -649,7 +661,7 @@ public abstract class Selector {
                         // or it might be an object (static method invocation on instance)
                         // Object.class handles both cases at once
                         handle = MethodHandles.dropArguments(handle, 0, Object.class);
-                    } 
+                    }
                 } catch (IllegalAccessException e) {
                     throw new GroovyBugError(e);
                 }
@@ -663,7 +675,7 @@ public abstract class Selector {
                     skipSpreadCollector = true;
                 } else {
                     // wrap arguments from call site in Object[]
-                    handle = handle.asCollector(Object[].class, targetType.parameterCount()-1);
+                    handle = handle.asCollector(Object[].class, targetType.parameterCount() - 1);
                 }
                 currentType = removeWrapper(targetType);
                 if (LOG_ENABLED) LOG.info("bound method name to META_METHOD_INVOKER");
@@ -671,7 +683,7 @@ public abstract class Selector {
         }
 
         private MethodHandle correctClassForNameAndUnReflectOtherwise(Method m) throws IllegalAccessException {
-            if (m.getDeclaringClass()==Class.class && m.getName().equals("forName") && m.getParameterTypes().length==1) {
+            if (m.getDeclaringClass() == Class.class && m.getName().equals("forName") && m.getParameterTypes().length == 1) {
                 return MethodHandles.insertArguments(CLASS_FOR_NAME, 1, true, sender.getClassLoader());
             } else {
                 return LOOKUP.unreflect(m);
@@ -683,8 +695,8 @@ public abstract class Selector {
          */
         private MethodType removeWrapper(MethodType targetType) {
             Class[] types = targetType.parameterArray();
-            for (int i=0; i<types.length; i++) {
-                if (types[i]==Wrapper.class) {
+            for (int i = 0; i < types.length; i++) {
+                if (types[i] == Wrapper.class) {
                     targetType = targetType.changeParameterType(i, Object.class);
                 }
             }
@@ -696,8 +708,8 @@ public abstract class Selector {
          * This method is called only if no handle has been created before. This
          * is usually the case if the method selection failed.
          */
-        public void setMetaClassCallHandleIfNedded(boolean standardMetaClass) {
-            if (handle!=null) return;
+        public void setMetaClassCallHandleIfNeeded(boolean standardMetaClass) {
+            if (handle != null) return;
             useMetaClass = true;
             if (LOG_ENABLED) LOG.info("set meta class invocation path");
             Object receiver = getCorrectedReceiver();
@@ -716,7 +728,7 @@ public abstract class Selector {
                 }
             }
             handle = MethodHandles.insertArguments(handle, 1, name);
-            if (!spread) handle = handle.asCollector(Object[].class, targetType.parameterCount()-1);
+            if (!spread) handle = handle.asCollector(Object[].class, targetType.parameterCount() - 1);
             if (LOG_ENABLED) LOG.info("bind method name and create collector for arguments");
         }
 
@@ -729,37 +741,37 @@ public abstract class Selector {
         public void correctWrapping() {
             if (useMetaClass) return;
             Class[] pt = handle.type().parameterArray();
-            if (currentType!=null) pt = currentType.parameterArray();
-            for (int i=1; i<args.length; i++) {
+            if (currentType != null) pt = currentType.parameterArray();
+            for (int i = 1; i < args.length; i++) {
                 if (args[i] instanceof Wrapper) {
                     Class type = pt[i];
                     MethodType mt = MethodType.methodType(type, Wrapper.class);
                     handle = MethodHandles.filterArguments(handle, i, UNWRAP_METHOD.asType(mt));
-                    if (LOG_ENABLED) LOG.info("added filter for Wrapper for argument at pos "+i);
+                    if (LOG_ENABLED) LOG.info("added filter for Wrapper for argument at pos " + i);
                 }
             }
         }
 
         /**
          * Handles cases in which we have to correct the length of arguments
-         * using the parameters. This might be needed for vargs and for one 
-         * parameter calls without arguments (null is used then).  
+         * using the parameters. This might be needed for vargs and for one
+         * parameter calls without arguments (null is used then).
          */
         public void correctParameterLength() {
-            if (handle==null) return;
+            if (handle == null) return;
 
             Class[] params = handle.type().parameterArray();
-            if (currentType!=null) params = currentType.parameterArray();
+            if (currentType != null) params = currentType.parameterArray();
             if (!isVargs) {
                 if (spread && useMetaClass) return;
-                if (params.length==2 && args.length==1) {
+                if (params.length == 2 && args.length == 1) {
                     handle = MethodHandles.insertArguments(handle, 1, SINGLE_NULL_ARRAY);
                 }
                 return;
             }
 
-            Class lastParam = params[params.length-1];
-            Object lastArg = unwrapIfWrapped(args[args.length-1]);
+            Class lastParam = params[params.length - 1];
+            Object lastArg = unwrapIfWrapped(args[args.length - 1]);
             if (params.length == args.length) {
                 // may need rewrap
                 if (lastArg == null) return;
@@ -773,7 +785,7 @@ public abstract class Selector {
                 // job before already, so the only case for this here is, that
                 // we have no argument for the array, meaning params.length is
                 // args.length+1. In that case we have to fill in an empty array
-                handle = MethodHandles.insertArguments(handle, params.length-1, Array.newInstance(lastParam.getComponentType(), 0));
+                handle = MethodHandles.insertArguments(handle, params.length - 1, Array.newInstance(lastParam.getComponentType(), 0));
                 if (LOG_ENABLED) LOG.info("added empty array for missing vargs part");
             } else { //params.length < args.length
                 // we depend on the method selection having done a good 
@@ -795,12 +807,12 @@ public abstract class Selector {
             if (useMetaClass) return;
 
             Class[] parameters = handle.type().parameterArray();
-            if (currentType!=null) parameters = currentType.parameterArray();
+            if (currentType != null) parameters = currentType.parameterArray();
             if (args.length != parameters.length) {
                 throw new GroovyBugError("At this point argument array length and parameter array length should be the same");
             }
-            for (int i=0; i<args.length; i++) {
-                if (parameters[i]==Object.class) continue; 
+            for (int i = 0; i < args.length; i++) {
+                if (parameters[i] == Object.class) continue;
                 Object arg = unwrapIfWrapped(args[i]);
                 // we have to handle here different cases in which we do no
                 // transformations. We depend on our method selection to have
@@ -813,15 +825,15 @@ public abstract class Selector {
                 // these. This is also handled already. What is left is the 
                 // GString conversion and the number conversions.
 
-                if (arg==null) continue;
+                if (arg == null) continue;
                 Class got = arg.getClass();
 
                 // equal class, nothing to do
-                if (got==parameters[i]) continue;
+                if (got == parameters[i]) continue;
 
                 Class wrappedPara = TypeHelper.getWrapperClass(parameters[i]);
                 // equal class with one maybe a primitive, the later explicitCastArguments will solve this case
-                if (wrappedPara==TypeHelper.getWrapperClass(got)) continue;
+                if (wrappedPara == TypeHelper.getWrapperClass(got)) continue;
 
                 // equal in terms of an assignment in Java. That means according to Java widening rules, or
                 // a subclass, interface, superclass relation, this case then handles also 
@@ -830,7 +842,8 @@ public abstract class Selector {
 
                 // to aid explicitCastArguments we convert to the wrapper type to let is only unbox
                 handle = TypeTransformers.addTransformer(handle, i, arg, wrappedPara);
-                if (LOG_ENABLED) LOG.info("added transformer at pos "+i+" for type "+got+" to type "+wrappedPara);
+                if (LOG_ENABLED)
+                    LOG.info("added transformer at pos " + i + " for type " + got + " to type " + wrappedPara);
             }
         }
 
@@ -840,7 +853,7 @@ public abstract class Selector {
          * invocation on NullObject instead.
          */
         public void correctNullReceiver() {
-            if (args[0]!=null) return;
+            if (args[0] != null) return;
             handle = handle.bindTo(NullObject.getNullObject());
             handle = MethodHandles.dropArguments(handle, 0, targetType.parameterType(0));
             if (LOG_ENABLED) LOG.info("binding null object receiver and dropping old receiver");
@@ -848,19 +861,19 @@ public abstract class Selector {
 
         public void correctSpreading() {
             if (!spread || useMetaClass || skipSpreadCollector) return;
-            handle = handle.asSpreader(Object[].class, args.length-1);
+            handle = handle.asSpreader(Object[].class, args.length - 1);
         }
 
         /**
-         * Adds the standard exception handler.  
+         * Adds the standard exception handler.
          */
         public void addExceptionHandler() {
             //TODO: if we would know exactly which paths require the exceptions
             //      and which paths not, we can sometimes save this guard 
-            if (handle==null || !catchException) return;
+            if (handle == null || !catchException) return;
             Class returnType = handle.type().returnType();
-            if (returnType!=Object.class) {
-                MethodType mtype = MethodType.methodType(returnType, GroovyRuntimeException.class); 
+            if (returnType != Object.class) {
+                MethodType mtype = MethodType.methodType(returnType, GroovyRuntimeException.class);
                 handle = MethodHandles.catchException(handle, GroovyRuntimeException.class, UNWRAP_EXCEPTION.asType(mtype));
             } else {
                 handle = MethodHandles.catchException(handle, GroovyRuntimeException.class, UNWRAP_EXCEPTION);
@@ -871,8 +884,8 @@ public abstract class Selector {
         /**
          * Sets all argument and receiver guards.
          */
-        public void setGuards (Object receiver) {
-            if (handle==null) return;
+        public void setGuards(Object receiver) {
+            if (handle == null) return;
             if (!cache) return;
 
             MethodHandle fallback = makeFallBack(callSite, sender, name, callType.ordinal(), targetType, safeNavigationOrig, thisCall, spread);
@@ -880,15 +893,15 @@ public abstract class Selector {
             // special guards for receiver
             if (receiver instanceof GroovyObject) {
                 GroovyObject go = (GroovyObject) receiver;
-                MetaClass mc = (MetaClass) go.getMetaClass();
-                MethodHandle test = SAME_MC.bindTo(mc); 
+                MetaClass mc = go.getMetaClass();
+                MethodHandle test = SAME_MC.bindTo(mc);
                 // drop dummy receiver
-                test = test.asType(MethodType.methodType(boolean.class,targetType.parameterType(0)));
+                test = test.asType(MethodType.methodType(boolean.class, targetType.parameterType(0)));
                 handle = MethodHandles.guardWithTest(test, handle, fallback);
                 if (LOG_ENABLED) LOG.info("added meta class equality check");
             } else if (receiver instanceof Class) {
                 MethodHandle test = EQUALS.bindTo(receiver);
-                test = test.asType(MethodType.methodType(boolean.class,targetType.parameterType(0)));
+                test = test.asType(MethodType.methodType(boolean.class, targetType.parameterType(0)));
                 handle = MethodHandles.guardWithTest(test, handle, fallback);
                 if (LOG_ENABLED) LOG.info("added class equality check");
             }
@@ -916,20 +929,20 @@ public abstract class Selector {
 
             // guards for receiver and parameter
             Class[] pt = handle.type().parameterArray();
-            for (int i=0; i<args.length; i++) {
+            for (int i = 0; i < args.length; i++) {
                 Object arg = args[i];
-                MethodHandle test = null;
-                if (arg==null) {
+                MethodHandle test;
+                if (arg == null) {
                     test = IS_NULL.asType(MethodType.methodType(boolean.class, pt[i]));
-                    if (LOG_ENABLED) LOG.info("added null argument check at pos "+i);
-                } else { 
+                    if (LOG_ENABLED) LOG.info("added null argument check at pos " + i);
+                } else {
                     Class argClass = arg.getClass();
                     if (pt[i].isPrimitive()) continue;
                     //if (Modifier.isFinal(argClass.getModifiers()) && TypeHelper.argumentClassIsParameterClass(argClass,pt[i])) continue;
                     test = SAME_CLASS.
-                                bindTo(argClass).
-                                asType(MethodType.methodType(boolean.class, pt[i]));
-                    if (LOG_ENABLED) LOG.info("added same class check at pos "+i);
+                            bindTo(argClass).
+                            asType(MethodType.methodType(boolean.class, pt[i]));
+                    if (LOG_ENABLED) LOG.info("added same class check at pos " + i);
                 }
                 Class[] drops = new Class[i];
                 System.arraycopy(pt, 0, drops, 0, drops.length);
@@ -956,12 +969,12 @@ public abstract class Selector {
         public void setSelectionBase() {
             if (thisCall) {
                 selectionBase = sender;
-            } else if (args[0]==null) {
+            } else if (args[0] == null) {
                 selectionBase = NullObject.class;
             } else {
                 selectionBase = mc.getTheClass();
             }
-            if (LOG_ENABLED) LOG.info("selection base set to "+selectionBase);
+            if (LOG_ENABLED) LOG.info("selection base set to " + selectionBase);
         }
 
         /**
@@ -970,7 +983,7 @@ public abstract class Selector {
         public boolean setInterceptor() {
             if (!(this.args[0] instanceof GroovyInterceptable)) return false;
             handle = MethodHandles.insertArguments(INTERCEPTABLE_INVOKER, 1, this.name);
-            handle = handle.asCollector(Object[].class, targetType.parameterCount()-1); 
+            handle = handle.asCollector(Object[].class, targetType.parameterCount() - 1);
             handle = handle.asType(targetType);
             return true;
         }
@@ -987,20 +1000,20 @@ public abstract class Selector {
         public void setCallSiteTarget() {
             if (!setNullForSafeNavigation() && !setInterceptor()) {
                 getMetaClass();
-                if (LOG_ENABLED) LOG.info("meta class is "+mc);
+                if (LOG_ENABLED) LOG.info("meta class is " + mc);
                 setSelectionBase();
                 MetaClassImpl mci = getMetaClassImpl(mc, callType != CallType.GET);
                 chooseMeta(mci);
                 setHandleForMetaMethod();
-                setMetaClassCallHandleIfNedded(mci!=null);
+                setMetaClassCallHandleIfNeeded(mci != null);
                 correctParameterLength();
                 correctCoerce();
                 correctWrapping();
                 correctNullReceiver();
                 correctSpreading();
 
-                if (LOG_ENABLED) LOG.info("casting explicit from "+handle.type()+" to "+targetType);
-                handle =  MethodHandles.explicitCastArguments(handle,targetType);
+                if (LOG_ENABLED) LOG.info("casting explicit from " + handle.type() + " to " + targetType);
+                handle = MethodHandles.explicitCastArguments(handle, targetType);
 
                 addExceptionHandler();
             }
@@ -1025,7 +1038,7 @@ public abstract class Selector {
      */
     public Object getCorrectedReceiver() {
         Object receiver = args[0];
-        if (receiver==null) {
+        if (receiver == null) {
             if (LOG_ENABLED) LOG.info("receiver is null");
             receiver = NullObject.getNullObject();
         }
@@ -1048,11 +1061,12 @@ public abstract class Selector {
     private static MetaClassImpl getMetaClassImpl(MetaClass mc, boolean includeEMC) {
         Class mcc = mc.getClass();
         boolean valid = mcc == MetaClassImpl.class ||
-                         mcc == AdaptingMetaClass.class ||
-                         mcc == ClosureMetaClass.class ||
-                         (includeEMC && mcc == ExpandoMetaClass.class);
+                mcc == AdaptingMetaClass.class ||
+                mcc == ClosureMetaClass.class ||
+                (includeEMC && mcc == ExpandoMetaClass.class);
         if (!valid) {
-            if (LOG_ENABLED) LOG.info("meta class is neither MetaClassImpl, nor AdoptingMetaClass, nor ClosureMetaClass, normal method selection path disabled.");
+            if (LOG_ENABLED)
+                LOG.info("meta class is neither MetaClassImpl, nor AdoptingMetaClass, nor ClosureMetaClass, normal method selection path disabled.");
             return null;
         }
         if (LOG_ENABLED) LOG.info("meta class is a recognized MetaClassImpl");
@@ -1064,7 +1078,7 @@ public abstract class Selector {
      * by producing a new array.
      */
     private static Object[] removeRealReceiver(Object[] args) {
-        Object[] ar = new Object[args.length-1];
+        Object[] ar = new Object[args.length - 1];
         System.arraycopy(args, 1, ar, 0, args.length - 1);
         return ar;
     }
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/TypeHelper.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/TypeHelper.java
index 0106d10..fcd0738 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/TypeHelper.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/TypeHelper.java
@@ -25,12 +25,12 @@ import java.math.BigInteger;
 
 /**
  * This class contains helper methods for converting and comparing types.
- * WARNING: This class is for internal use only. do not use it outside of its 
- * package and not outside groovy-core. 
+ * WARNING: This class is for internal use only. do not use it outside of its
+ * package and not outside groovy-core.
  */
 public class TypeHelper {
     /**
-     * Get wrapper class for a given class. 
+     * Get wrapper class for a given class.
      * If the class is for a primitive number type, then the wrapper class
      * will be returned. If it is no primitive number type, we return the
      * class itself.
@@ -57,7 +57,7 @@ public class TypeHelper {
     }
 
     /**
-     * Realizes an unsharp equal for the class. 
+     * Realizes an unsharp equal for the class.
      * In general we return true if the provided arguments are the same. But
      * we will also return true if our argument class is a wrapper for
      * the parameter class. For example the parameter is an int and the
@@ -65,8 +65,7 @@ public class TypeHelper {
      */
     protected static boolean argumentClassIsParameterClass(Class argumentClass, Class parameterClass) {
         if (argumentClass == parameterClass) return true;
-        if (getWrapperClass(parameterClass) == argumentClass) return true;
-        return false;
+        return getWrapperClass(parameterClass) == argumentClass;
     }
 
     /**
@@ -75,9 +74,9 @@ public class TypeHelper {
      * the argument is null.
      */
     protected static MethodType replaceWithMoreSpecificType(Object[] args, MethodType callSiteType) {
-        for (int i=0; i<args.length; i++) {
+        for (int i = 0; i < args.length; i++) {
             // if argument null, take the static type
-            if (args[i]==null) continue;
+            if (args[i] == null) continue;
             if (callSiteType.parameterType(i).isPrimitive()) continue;
             Class argClass = args[i].getClass();
             callSiteType = callSiteType.changeParameterType(i, argClass);
@@ -86,27 +85,27 @@ public class TypeHelper {
     }
 
     protected static boolean isIntCategory(Class x) {
-        return x==Integer.class    ||  x==int.class    ||
-                x==Byte.class       ||  x==byte.class   ||
-                x==Short.class      ||  x==short.class;
+        return x == Integer.class || x == int.class ||
+                x == Byte.class || x == byte.class ||
+                x == Short.class || x == short.class;
     }
 
     protected static boolean isLongCategory(Class x) {
-        return  x==Long.class       ||  x==long.class   ||
+        return x == Long.class || x == long.class ||
                 isIntCategory(x);
     }
 
     private static boolean isBigIntCategory(Class x) {
-        return  x==BigInteger.class || isLongCategory(x);
+        return x == BigInteger.class || isLongCategory(x);
     }
 
     protected static boolean isBigDecCategory(Class x) {
-        return  x==BigDecimal.class || isBigIntCategory(x);
+        return x == BigDecimal.class || isBigIntCategory(x);
     }
 
     protected static boolean isDoubleCategory(Class x) {
-        return  x==Float.class      ||  x==float.class  ||
-                x==Double.class     ||  x==double.class ||
+        return x == Float.class || x == float.class ||
+                x == Double.class || x == double.class ||
                 isBigDecCategory(x);
     }
 }
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/TypeTransformers.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/TypeTransformers.java
index 01c200d..b945056 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/TypeTransformers.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/TypeTransformers.java
@@ -44,25 +44,26 @@ import java.util.Map;
  * This class contains several transformers for used during method invocation.
  */
 public class TypeTransformers {
-	private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
-    private static final MethodHandle 
-        TO_STRING, TO_BYTE,   TO_INT,     TO_LONG,    TO_SHORT,
-        TO_FLOAT,  TO_DOUBLE, TO_BIG_INT, AS_ARRAY,
-        TO_REFLECTIVE_PROXY, TO_GENERATED_PROXY, TO_SAMTRAIT_PROXY,
-        DOUBLE_TO_BIG_DEC, DOUBLE_TO_BIG_DEC_WITH_CONVERSION, LONG_TO_BIG_DEC, BIG_INT_TO_BIG_DEC;
+    private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
+    private static final MethodHandle
+            TO_STRING, TO_BYTE, TO_INT, TO_LONG, TO_SHORT,
+            TO_FLOAT, TO_DOUBLE, TO_BIG_INT, AS_ARRAY,
+            TO_REFLECTIVE_PROXY, TO_GENERATED_PROXY, TO_SAMTRAIT_PROXY,
+            DOUBLE_TO_BIG_DEC, DOUBLE_TO_BIG_DEC_WITH_CONVERSION, LONG_TO_BIG_DEC, BIG_INT_TO_BIG_DEC;
+
     static {
         try {
-            TO_STRING   = LOOKUP.findVirtual(Object.class, "toString",      MethodType.methodType(String.class));
-            TO_BYTE     = LOOKUP.findVirtual(Number.class, "byteValue",     MethodType.methodType(Byte.TYPE));
-            TO_SHORT    = LOOKUP.findVirtual(Number.class, "shortValue",    MethodType.methodType(Short.TYPE));
-            TO_INT      = LOOKUP.findVirtual(Number.class, "intValue",      MethodType.methodType(Integer.TYPE));
-            TO_LONG     = LOOKUP.findVirtual(Number.class, "longValue",     MethodType.methodType(Long.TYPE));
-            TO_FLOAT    = LOOKUP.findVirtual(Number.class, "floatValue",    MethodType.methodType(Float.TYPE));
-            TO_DOUBLE   = LOOKUP.findVirtual(Number.class, "doubleValue",   MethodType.methodType(Double.TYPE));
+            TO_STRING = LOOKUP.findVirtual(Object.class, "toString", MethodType.methodType(String.class));
+            TO_BYTE = LOOKUP.findVirtual(Number.class, "byteValue", MethodType.methodType(Byte.TYPE));
+            TO_SHORT = LOOKUP.findVirtual(Number.class, "shortValue", MethodType.methodType(Short.TYPE));
+            TO_INT = LOOKUP.findVirtual(Number.class, "intValue", MethodType.methodType(Integer.TYPE));
+            TO_LONG = LOOKUP.findVirtual(Number.class, "longValue", MethodType.methodType(Long.TYPE));
+            TO_FLOAT = LOOKUP.findVirtual(Number.class, "floatValue", MethodType.methodType(Float.TYPE));
+            TO_DOUBLE = LOOKUP.findVirtual(Number.class, "doubleValue", MethodType.methodType(Double.TYPE));
 
             // BigDecimal conversion is done by using the double value
             DOUBLE_TO_BIG_DEC = LOOKUP.findConstructor(BigDecimal.class, MethodType.methodType(Void.TYPE, Double.TYPE));
-            DOUBLE_TO_BIG_DEC_WITH_CONVERSION  = MethodHandles.filterReturnValue(TO_DOUBLE, DOUBLE_TO_BIG_DEC);
+            DOUBLE_TO_BIG_DEC_WITH_CONVERSION = MethodHandles.filterReturnValue(TO_DOUBLE, DOUBLE_TO_BIG_DEC);
 
             // BigDecimal conversion is done by using the double value
             LONG_TO_BIG_DEC = LOOKUP.findConstructor(BigDecimal.class, MethodType.methodType(Void.TYPE, Long.TYPE));
@@ -73,13 +74,13 @@ public class TypeTransformers {
 
             // BigInteger conversion is done by using the string representation
             MethodHandle tmp = LOOKUP.findConstructor(BigInteger.class, MethodType.methodType(Void.TYPE, String.class));
-            TO_BIG_INT  = MethodHandles.filterReturnValue(TO_STRING, tmp);
+            TO_BIG_INT = MethodHandles.filterReturnValue(TO_STRING, tmp);
 
             // generic array to array conversion
             AS_ARRAY = LOOKUP.findStatic(DefaultTypeTransformation.class, "asArray", MethodType.methodType(Object.class, Object.class, Class.class));
 
             // reflective proxy generation, since we need a ConvertedClosure but have only a normal Closure, we need to create that wrapper object as well
-            MethodHandle newProxyInstance = LOOKUP.findStatic(Proxy.class, "newProxyInstance", 
+            MethodHandle newProxyInstance = LOOKUP.findStatic(Proxy.class, "newProxyInstance",
                     MethodType.methodType(Object.class, ClassLoader.class, Class[].class, InvocationHandler.class));
             MethodHandle newConvertedClosure = LOOKUP.findConstructor(ConvertedClosure.class, MethodType.methodType(Void.TYPE, Closure.class, String.class));
             // prepare target newProxyInstance for fold to drop additional arguments needed by newConvertedClosure
@@ -106,7 +107,7 @@ public class TypeTransformers {
                 MethodHandle map = LOOKUP.findStatic(Collections.class, "singletonMap",
                         MethodType.methodType(Map.class, Object.class, Object.class));
                 newProxyInstance = LOOKUP.findVirtual(ProxyGenerator.class, "instantiateAggregate",
-                        MethodType.methodType(GroovyObject.class,Map.class, List.class));
+                        MethodType.methodType(GroovyObject.class, Map.class, List.class));
                 newOrder = newProxyInstance.type().dropParameterTypes(1, 2);
                 newOrder = newOrder.insertParameterTypes(0, Map.class, Object.class, Object.class);
                 tmp = MethodHandles.permuteArguments(newProxyInstance, newOrder, 3, 0, 4);
@@ -124,7 +125,7 @@ public class TypeTransformers {
      * array transformations and number based transformations
      */
     protected static MethodHandle addTransformer(MethodHandle handle, int pos, Object arg, Class parameter) {
-        MethodHandle transformer=null;
+        MethodHandle transformer = null;
         if (arg instanceof GString) {
             transformer = TO_STRING;
         } else if (arg instanceof Closure) {
@@ -132,15 +133,16 @@ public class TypeTransformers {
         } else if (Number.class.isAssignableFrom(parameter)) {
             transformer = selectNumberTransformer(parameter, arg);
         } else if (parameter.isArray()) {
-            transformer =  MethodHandles.insertArguments(AS_ARRAY, 1, parameter);
+            transformer = MethodHandles.insertArguments(AS_ARRAY, 1, parameter);
         }
-        if (transformer==null) throw new GroovyBugError("Unknown transformation for argument "+arg+" at position "+pos+" with "+arg.getClass()+" for parameter of type "+parameter);
+        if (transformer == null)
+            throw new GroovyBugError("Unknown transformation for argument " + arg + " at position " + pos + " with " + arg.getClass() + " for parameter of type " + parameter);
         return applyUnsharpFilter(handle, pos, transformer);
     }
 
     /**
      * creates a method handle able to transform the given Closure into a SAM type
-     * if the given parameter is a SAM type 
+     * if the given parameter is a SAM type
      */
     private static MethodHandle createSAMTransform(Object arg, Class parameter) {
         Method method = CachedSAMClass.getSAMMethod(parameter);
@@ -169,10 +171,10 @@ public class TypeTransformers {
             // input is the closure, the method name, the class loader and the 
             // class[]. All of that but the closure must be provided here  
             MethodHandle ret = TO_REFLECTIVE_PROXY;
-            ret = MethodHandles.insertArguments(ret, 1, 
-                        method.getName(),
-                        arg.getClass().getClassLoader(),
-                        new Class[]{parameter});
+            ret = MethodHandles.insertArguments(ret, 1,
+                    method.getName(),
+                    arg.getClass().getClassLoader(),
+                    new Class[]{parameter});
             return ret;
         } else {
             // the following code will basically do this:
@@ -193,7 +195,7 @@ public class TypeTransformers {
     /**
      * Apply a transformer as filter.
      * The filter may not match exactly in the types. In this case needed
-     * additional type transformations are done by {@link MethodHandle#asType(MethodType)} 
+     * additional type transformations are done by {@link MethodHandle#asType(MethodType)}
      */
     public static MethodHandle applyUnsharpFilter(MethodHandle handle, int pos, MethodHandle transformer) {
         MethodType type = transformer.type();
@@ -215,7 +217,7 @@ public class TypeTransformers {
             return TO_BYTE;
         } else if (param == Character.class || param == Integer.class) {
             return TO_INT;
-        } else  if (param == Long.class) {
+        } else if (param == Long.class) {
             return TO_LONG;
         } else if (param == Float.class) {
             return TO_FLOAT;
@@ -236,7 +238,7 @@ public class TypeTransformers {
         } else if (param == Short.class) {
             return TO_SHORT;
         } else {
-             return null;
+            return null;
         }
     }
 }