Package org.codehaus.groovy.reflection

Examples of org.codehaus.groovy.reflection.CachedClass$BigIntegerCachedClass


            }
            registerMethods(DefaultGroovyStaticMethods.class, false, map);

            for (Iterator it = map.entrySet().iterator(); it.hasNext(); ) {
                Map.Entry e = (Map.Entry) it.next();
                CachedClass cls = (CachedClass) e.getKey();
                ArrayList list = (ArrayList) e.getValue();
                cls.setNewMopMethods(list);
            }
        }

        installMetaClassCreationHandle();
View Full Code Here


            if (answer!=null) return answer;
   
            // We've got a lock on the Class and we need to be sure that we're in
            // the ReflectionCache before we call MetaClass.initialize().
            // There is probably another place to do this, but I want to be sure...
            final CachedClass forEffect = ReflectionCache.getCachedClass(theClass);
           
            answer = metaClassCreationHandle.create(theClass, this);
            answer.initialize();
            if (GroovySystem.isKeepJavaMetaClasses()) {
                constantMetaClassCount++;
View Full Code Here

     * @param isGetter True if it is a getter
     * @return The return value if of a getProperty call or a MissingPropertyException is thrown
     */
    public Object invokeMissingProperty(Object instance, String propertyName, Object optionalValue, boolean isGetter) {
        Class theClass = instance instanceof Class ? (Class)instance : instance.getClass();
        CachedClass superClass = theCachedClass;
        while(superClass != ReflectionCache.OBJECT_CLASS) {
            final MetaBeanProperty property = findPropertyInClassHierarchy(propertyName, superClass);
            if(property != null) {
                addMetaBeanProperty(property);
                if(!isGetter) {
                    property.setProperty(instance, optionalValue);
                    return null;
                }
                else {
                    return property.getProperty(instance);
                }
            }
            superClass = superClass.getCachedSuperClass();
        }
        // got here to property not found, look for getProperty or setProperty overrides
        if(isGetter) {
            final Object[] getPropertyArgs = {propertyName};
            final MetaMethod method = findMethodInClassHeirarchy(GET_PROPERTY_METHOD, getPropertyArgs, theClass);
View Full Code Here

        return super.invokeMissingProperty(instance, propertyName, optionalValue, isGetter);
    }

    private MetaBeanProperty findPropertyInClassHierarchy(String propertyName, CachedClass theClass) {
        MetaBeanProperty property= null;
        final CachedClass superClass = theClass.getCachedSuperClass();
        MetaClass metaClass = this.registry.getMetaClass(superClass.getCachedClass());
        if(metaClass instanceof MutableMetaClass) {
            property = getMetaPropertyFromMutableMetaClass(propertyName,metaClass);
            if(property == null) {
                if(superClass != ReflectionCache.OBJECT_CLASS) {
                    property = findPropertyInClassHierarchy(propertyName, superClass);
View Full Code Here

    }

    public String getMopName() {
        if (mopName == null) {
          String name = getName();
          CachedClass declaringClass = getDeclaringClass();
          if ((getModifiers() & (Modifier.PUBLIC| Modifier.PROTECTED)) == 0)
            mopName = new StringBuffer().append("this$").append(declaringClass.getSuperClassDistance()).append("$").append(name).toString();
          else
            mopName = new StringBuffer().append("super$").append(declaringClass.getSuperClassDistance()).append("$").append(name).toString();
        }
        return mopName;
    }
View Full Code Here

            Method method = methods[i];
            if (Modifier.isStatic(method.getModifiers())) {
                final CachedMethod cachedMethod = CachedMethod.find(method);
                CachedClass[] paramTypes = cachedMethod.getParameterTypes();
                if (paramTypes.length > 0) {
                    CachedClass metaClass = paramTypes[0];
                    Map metaMethodsMap = getMetaMethods(properties, metaClass.getCachedClass());
                    List methodList = getMethodList(metaMethodsMap, method.getName());
                    MetaMethod mmethod = new CategoryMethod(cachedMethod, metaClass.getCachedClass());
                    methodList.add(mmethod);
                    Collections.sort(methodList);
                }
            }
        }
View Full Code Here

    public int getParameterCount() {
        return parameterTypes.length;
    }

    public Class getParameterType(int index) {
        CachedClass c = parameterTypes[index];
        if (c==null) return Object.class;
        return c.getCachedClass();
    }
View Full Code Here

    public MetaMethodIndex(CachedClass theCachedClass) {
        this.theCachedClass = theCachedClass;
        init(DEFAULT_CAPACITY);

        CachedClass last = null;
        if (!theCachedClass.isInterface()) {
            for (CachedClass c = theCachedClass; c != null; c = c.getCachedSuperClass()) {
              final SingleKeyHashMap.Entry e = methodHeaders.getOrPut(c.getCachedClass());
              e.value = new Header (c.getCachedClass(), last == null ? null : last.getCachedClass());
              last = c;
            }
        }
        else {
            final SingleKeyHashMap.Entry e = methodHeaders.getOrPut(Object.class);
View Full Code Here

                    // Note: private methods from parent classes are not shown here,
                    // but when doing the multimethod connection step, we overwrite
                    // methods of the parent class with methods of a subclass and
                    // in that case we want to keep the private methods
                } else {
                    CachedClass methodC = method.getDeclaringClass();
                    CachedClass matchC = match.getDeclaringClass();
                    if (methodC == matchC) {
                        if (isNonRealMethod(method)) {
                            return method;
                        }
                    } else if (!methodC.isAssignableFrom(matchC.getCachedClass())) {
                        return method;
                    }
                }
            }
            return o;
        }

        if (o instanceof FastArray) {
            FastArray list = (FastArray) o;
            int found = findMatchingMethod(list, method);

            if (found == -1) {
                list.add(method);
            } else {
                MetaMethod match = (MetaMethod) list.get(found);
                if (match==method) return o;
                if (match.isPrivate()
                        || (!isNonRealMethod(match) && match.getDeclaringClass().isInterface() && !method.getDeclaringClass().isInterface())) {
                    // do not overwrite interface methods with instance methods
                    // do not overwrite private methods
                    // Note: private methods from parent classes are not shown here,
                    // but when doing the multimethod connection step, we overwrite
                    // methods of the parent class with methods of a subclass and
                    // in that case we want to keep the private methods
                } else {
                    CachedClass  methodC = method.getDeclaringClass();
                    CachedClass matchC = match.getDeclaringClass();
                    if (methodC == matchC) {
                        if (isNonRealMethod(method)) {
                            list.set(found, method);
                        }
                    } else if (!methodC.isAssignableFrom(matchC.getCachedClass())) {
                        list.set(found, method);
                    }
                }
            }
        }
View Full Code Here

            }
        }
        catch (IOException ignored) {}

        for (Map.Entry<CachedClass, List<MetaMethod>> moduleMethods : map.entrySet()) {
            CachedClass cls = moduleMethods.getKey();
            cls.addNewMopMethods( moduleMethods.getValue() );
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.reflection.CachedClass$BigIntegerCachedClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.