/** * Looks for a class called 'groovy.runtime.metaclass.CustomMetaClassCreationHandle' and if it * exists uses it as the MetaClassCreationHandle otherwise uses the default * * @see groovy.lang.MetaClassRegistry.MetaClassCreationHandle */ private void installMetaClassCreationHandle() { try { final Class customMetaClassHandle = Class.forName("groovy.runtime.metaclass.CustomMetaClassCreationHandle"); final Constructor customMetaClassHandleConstructor = customMetaClassHandle.getConstructor(new Class[] {}); this.metaClassCreationHandle = (MetaClassCreationHandle) customMetaClassHandleConstructor.newInstance(); } catch (final ClassNotFoundException e) { this.metaClassCreationHandle = new MetaClassCreationHandle(); } catch (final Exception e) { throw new GroovyRuntimeException( "Could not instantiate custom Metaclass creation handle: " + e, e); } }
private void createMetaMethodFromClass(Map<CachedClass, List<MetaMethod>> map, Class aClass) { try { MetaMethod method = (MetaMethod) aClass.newInstance(); final CachedClass declClass = method.getDeclaringClass(); List<MetaMethod> arr = map.get(declClass); if (arr == null) { arr = new ArrayList<MetaMethod>(4); map.put(declClass, arr); } arr.add(method); instanceMethods.add(method); } catch (InstantiationException e) { /* ignore */ } catch (IllegalAccessException e) { /* ignore */ } }