/** * Indicates whether some other object is "equal to" this one. * The delegate is used if the class of the parameter and the * current class are equal. In other cases the method will return * false. The exact class is here used, if inheritance is needed, * this method must be overwritten. * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (obj instanceof Proxy) { obj = Proxy.getInvocationHandler(obj); } if (obj instanceof ConversionHandler) { return (((ConversionHandler) obj).getDelegate()).equals(delegate); } else { return false; } }
if (handleCache != null && isDefaultMethod(method) && !defaultOverridden(method)) { VMPlugin plugin = VMPluginFactory.getPlugin(); Object handle = handleCache.get(method); if (!checkMethod(method)) { try { if (method.getDeclaringClass() == GroovyObject.class) { if ("getMetaClass".equals(method.getName())) { return getMetaClass(proxy); } else if ("setMetaClass".equals(method.getName())) { return setMetaClass((MetaClass) args[0]); return invokeCustom(proxy, method, args); } catch (GroovyRuntimeException gre) { throw ScriptBytecodeAdapter.unwrap(gre);
protected boolean checkMethod(Method method) { return isCoreObjectMethod(method); }
/** * This method is a default implementation for the invoke method given in * Invocationhandler. Any call to a method with a declaring class that is * not Object, excluding toString(), is redirected to invokeCustom. * Methods like equals and hashcode are called on the class itself instead * of the delegate because they are considered fundamental methods that should * not be overwritten. The toString() method gets special treatment as it is * deemed to be a method that you might wish to override when called from Groovy. * * In many scenarios, it is better to overwrite the invokeCustom method where * the core Object related methods are filtered out. * * @param proxy the proxy * @param method the method * @param args the arguments * @return the result of the invocation by method or delegate * @throws Throwable if caused by the delegate or the method * @see #invokeCustom(Object, Method, Object[]) * @see InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (!isCoreObjectMethod(method)) { return invokeCustom(proxy, method, args); } try { return method.invoke(this, args); } catch (InvocationTargetException ite) { throw ite.getTargetException(); } }
/** * This method is a default implementation for the invoke method given in * Invocationhandler. Any call to a method with a declaring class that is * not Object, excluding toString(), is redirected to invokeCustom. * Methods like equals and hashcode are called on the class itself instead * of the delegate because they are considered fundamental methods that should * not be overwritten. The toString() method gets special treatment as it is * deemed to be a method that you might wish to override when called from Groovy. * * In many scenarios, it is better to overwrite the invokeCustom method where * the core Object related methods are filtered out. * * @param proxy the proxy * @param method the method * @param args the arguments * @return the result of the invocation by method or delegate * @throws Throwable if caused by the delegate or the method * @see #invokeCustom(Object, Method, Object[]) * @see InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (!checkMethod(method)) { return invokeCustom(proxy, method, args); } try { return method.invoke(this, args); } catch (InvocationTargetException ite) { throw ite.getTargetException(); } }
/** * This method is a default implementation for the invoke method given in * Invocationhandler. Any call to a method with a declaring class that is * not Object, excluding toString(), is redirected to invokeCustom. * Methods like equals and hashcode are called on the class itself instead * of the delegate because they are considered fundamental methods that should * not be overwritten. The toString() method gets special treatment as it is * deemed to be a method that you might wish to override when called from Groovy. * * In many scenarios, it is better to overwrite the invokeCustom method where * the core Object related methods are filtered out. * * @param proxy the proxy * @param method the method * @param args the arguments * @return the result of the invocation by method or delegate * @throws Throwable if caused by the delegate or the method * @see #invokeCustom(Object, Method, Object[]) * @see InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (!isCoreObjectMethod(method)) { return invokeCustom(proxy, method, args); } try { return method.invoke(this, args); } catch (InvocationTargetException ite) { throw ite.getTargetException(); } }
if (!checkMethod(method)) { try { return invokeCustom(proxy, method, args); } catch (GroovyRuntimeException gre) { throw ScriptBytecodeAdapter.unwrap(gre);
/** * Checks whether a method is a core method from java.lang.Object. * Such methods often receive special treatment because they are * deemed fundamental enough to not be tampered with. * call toString() is an exception to allow overriding toString() by a closure specified in the map * * @param method the method to check * @return true if the method is deemed to be a core method */ public static boolean isCoreObjectMethod(Method method) { return ConversionHandler.isCoreObjectMethod(method) && !"toString".equals(method.getName()); } }
/** * Indicates whether some other object is "equal to" this one. * The delegate is used if the class of the parameter and the * current class are equal. In other cases the method will return * false. The exact class is here used, if inheritance is needed, * this method must be overwritten. * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (obj instanceof Proxy) { obj = Proxy.getInvocationHandler(obj); } if (obj instanceof ConversionHandler) { return (((ConversionHandler) obj).getDelegate()).equals(delegate); } else { return false; } }
protected boolean checkMethod(Method method) { return isCoreObjectMethod(method); }
/** * Indicates whether some other object is "equal to" this one. * The delegate is used if the class of the parameter and the * current class are equal. In other cases the method will return * false. The exact class is here used, if inheritance is needed, * this method must be overwritten. * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (obj instanceof Proxy) { obj = Proxy.getInvocationHandler(obj); } if (obj instanceof ConversionHandler) { return (((ConversionHandler) obj).getDelegate()).equals(delegate); } else { return false; } }
protected boolean checkMethod(Method method) { return isCoreObjectMethod(method); }
/** * Indicates whether some other object is "equal to" this one. * The delegate is used if the class of the parameter and the * current class are equal. In other cases the method will return * false. The exact class is here used, if inheritance is needed, * this method must be overwritten. * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (obj instanceof Proxy) { obj = Proxy.getInvocationHandler(obj); } if (obj instanceof ConversionHandler) { return (((ConversionHandler) obj).getDelegate()).equals(delegate); } else { return false; } }
/** * Checks whether a method is a core method from java.lang.Object. * Such methods often receive special treatment because they are * deemed fundamental enough to not be tampered with. * call toString() is an exception to allow overriding toString() by a closure specified in the map * * @param method the method to check * @return true if the method is deemed to be a core method */ public static boolean isCoreObjectMethod(Method method) { return ConversionHandler.isCoreObjectMethod(method) && !"toString".equals(method.getName()); } }
/** * Indicates whether some other object is "equal to" this one. * The delegate is used if the class of the parameter and the * current class are equal. In other cases the method will return * false. The exact class is here used, if inheritance is needed, * this method must be overwritten. * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (obj instanceof Proxy) { obj = Proxy.getInvocationHandler(obj); } if (obj instanceof ConversionHandler) { return (((ConversionHandler) obj).getDelegate()).equals(delegate); } else { return false; } }
/** * Checks whether a method is a core method from java.lang.Object. * Such methods often receive special treatment because they are * deemed fundamental enough to not be tampered with. * call toString() is an exception to allow overriding toString() by a closure specified in the map * * @param method the method to check * @return true if the method is deemed to be a core method */ public static boolean isCoreObjectMethod(Method method) { return ConversionHandler.isCoreObjectMethod(method) && !"toString".equals(method.getName()); } }
if (method.getName().indexOf('$') != -1 || Modifier.isFinal(method.getModifiers()) || ConversionHandler.isCoreObjectMethod(method)) continue; if (map.containsKey(method.getName())) {
if (method.getName().indexOf('$') != -1 || Modifier.isFinal(method.getModifiers()) || (!"toString".equals(method.getName()) && ConversionHandler.isCoreObjectMethod(method)) || containsEquivalentMethod(selectedMethods.values(), method)) continue;
if (method.getName().indexOf('$') != -1 || Modifier.isFinal(method.getModifiers()) || ConversionHandler.isCoreObjectMethod(method) || containsEquivalentMethod(selectedMethods.values(), method)) continue;
if (method.getName().indexOf('$') != -1 || Modifier.isFinal(method.getModifiers()) || ConversionHandler.isCoreObjectMethod(method) || containsEquivalentMethod(selectedMethods.values(), method)) continue;