/** * Sometimes the intertyped method requires a bridge method alongside it. For example if the method 'N SomeI<N>.m()' is put onto * an interface 'interface I<N extends Number>' and then a concrete implementation is 'class C implements I<Float>' then the ITD * on the interface will be 'Number m()', whereas the ITD on the 'topmostimplementor' will be 'Float m()'. A bridge method needs * to be created in the topmostimplementor 'Number m()' that delegates to 'Float m()' */ public static ResolvedMember bridgerToInterMethod(ResolvedMember meth, UnresolvedType aspectType) { int modifiers = makePublicNonFinal(meth.getModifiers()); ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, aspectType, modifiers, meth.getReturnType(), NameMangler.interMethod(meth.getModifiers(), aspectType, meth.getDeclaringType(), meth.getName()), meth.getParameterTypes(), meth.getExceptions()); rmi.setTypeVariables(meth.getTypeVariables()); return rmi; }
/** * This method goes on the target type of the inter-type method. (and possibly the topmost-implementors, if the target type is * an interface). The implementation will call the interMethodDispatch method on the aspect. */ public static ResolvedMember interMethod(ResolvedMember meth, UnresolvedType aspectType, boolean onInterface) { if (Modifier.isPublic(meth.getModifiers()) && !onInterface) { return meth; } int modifiers = makePublicNonFinal(meth.getModifiers()); if (onInterface) { modifiers |= Modifier.ABSTRACT; } ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, meth.getDeclaringType(), modifiers, meth.getReturnType(), NameMangler.interMethod(meth.getModifiers(), aspectType, meth.getDeclaringType(), meth.getName()), meth.getParameterTypes(), meth.getExceptions()); rmi.setParameterNames(meth.getParameterNames()); rmi.setTypeVariables(meth.getTypeVariables()); return rmi; }
/** * This method goes on the target type of the inter-type method. (and possibly the topmost-implementors, if the target type is * an interface). The implementation will call the interMethodDispatch method on the aspect. */ public static ResolvedMember interMethodBridger(ResolvedMember meth, UnresolvedType aspectType, boolean onInterface) { // if (Modifier.isPublic(meth.getModifiers()) && !onInterface) // return meth; int modifiers = makePublicNonFinal(meth.getModifiers()) | BRIDGE; if (onInterface) { modifiers |= Modifier.ABSTRACT; } ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, meth.getDeclaringType(), modifiers, meth.getReturnType(), NameMangler.interMethod(meth.getModifiers(), aspectType, meth.getDeclaringType(), meth.getName()), meth.getParameterTypes(), meth.getExceptions()); rmi.setTypeVariables(meth.getTypeVariables()); return rmi; }