private static CachedConstructor findDefaultConstructor(CachedClass mixinClass) { for (CachedConstructor constr : mixinClass.getConstructors()) { if (!Modifier.isPublic(constr.getModifiers())) continue; CachedClass[] classes = constr.getParameterTypes(); if (classes.length == 0) return constr; } throw new GroovyRuntimeException( "No default constructor for class " + mixinClass.getName() + "! Can't be mixed in."); }
public int hashCode() { int result = super.hashCode(); result = 31 * result + (emc != null ? emc.hashCode() : 0); result = 31 * result + (mixinClass != null ? mixinClass.hashCode() : 0); result = 31 * result + (constructor != null ? constructor.hashCode() : 0); return result; }
public synchronized Object getMixinInstance(Object object) { Object mixinInstance = get(object); if (mixinInstance == null) { mixinInstance = constructor.invoke(MetaClassHelper.EMPTY_ARRAY); new MixedInMetaClass(mixinInstance, object); put(object, mixinInstance); } return mixinInstance; }