public UnresolvedType getReturnType() { return realMember.getReturnType(); }
private String stringifyMember(ResolvedMember member) { StringBuffer buf = new StringBuffer(); buf.append(member.getReturnType().getName()); buf.append(' '); buf.append(member.getName()); if (member.getKind() != Member.FIELD) { buf.append("("); UnresolvedType[] params = member.getParameterTypes(); if (params.length != 0) { buf.append(params[0]); for (int i = 1, len = params.length; i < len; i++) { buf.append(", "); buf.append(params[i].getName()); } } buf.append(")"); } return buf.toString(); }
private static void setParams(IProgramElement pe, ResolvedMember sig) { // do it for itds too UnresolvedType[] ts = sig.getParameterTypes(); pe.setParameterNames(Collections.<String>emptyList()); // TODO should be doing param names? if (ts == null) { pe.setParameterSignatures(Collections.<char[]>emptyList(), Collections.<String>emptyList()); } else { List<char[]> paramSigs = new ArrayList<char[]>(); for (int i = 0; i < ts.length; i++) { paramSigs.add(ts[i].getSignature().toCharArray()); } pe.setParameterSignatures(paramSigs, Collections.<String>emptyList()); } pe.setCorrespondingType(sig.getReturnType().getName()); }
/** * This static method goes on the aspect that declares the inter-type field */ public static ResolvedMember interFieldSetDispatcher(ResolvedMember field, UnresolvedType aspectType) { ResolvedMember rm = new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, UnresolvedType.VOID, NameMangler.interFieldSetDispatcher(aspectType, field.getDeclaringType(), field.getName()), Modifier.isStatic(field .getModifiers()) ? new UnresolvedType[] { field.getReturnType() } : new UnresolvedType[] { field.getDeclaringType(), field.getReturnType() }); rm.setTypeVariables(field.getTypeVariables()); return rm; }
protected LazyMethodGen makeMethodGen(LazyClassGen gen, ResolvedMember member) { try { Type returnType = BcelWorld.makeBcelType(member.getReturnType()); Type[] parameterTypes = BcelWorld.makeBcelTypes(member.getParameterTypes()); LazyMethodGen ret = new LazyMethodGen(member.getModifiers(), returnType, member.getName(), parameterTypes, UnresolvedType.getNames(member .getExceptions()), gen); // 43972 : Static crosscutting makes interfaces unusable for javac // ret.makeSynthetic(); return ret; } catch (ClassFormatException cfe) { throw new RuntimeException("Problem with makeMethodGen for method "+member.getName()+" in type "+gen.getName()+" ret="+member.getReturnType(),cfe); } }
public static ResolvedMember superAccessMethod(UnresolvedType baseType, ResolvedMember method) { UnresolvedType[] paramTypes = method.getParameterTypes(); // if (!method.isStatic()) { // paramTypes = UnresolvedType.insert(method.getDeclaringType(), paramTypes); // } return new ResolvedMemberImpl(Member.METHOD, baseType, Modifier.PUBLIC, method.getReturnType(), NameMangler.superDispatchMethod(baseType, method.getName()), paramTypes, method.getExceptions()); }
protected FieldGen makeFieldGen(LazyClassGen gen, ResolvedMember member) { return new FieldGen(member.getModifiers(), BcelWorld.makeBcelType(member.getReturnType()), member.getName(), gen.getConstantPool()); }
protected static LazyMethodGen makeBridgeMethod(LazyClassGen gen, ResolvedMember member) { // remove abstract modifier int mods = member.getModifiers(); if (Modifier.isAbstract(mods)) { mods = mods - Modifier.ABSTRACT; } LazyMethodGen ret = new LazyMethodGen(mods, BcelWorld.makeBcelType(member.getReturnType()), member.getName(), BcelWorld.makeBcelTypes(member.getParameterTypes()), UnresolvedType.getNames(member.getExceptions()), gen); // 43972 : Static crosscutting makes interfaces unusable for javac // ret.makeSynthetic(); return ret; }
public static ResolvedMember privilegedAccessMethodForMethod(UnresolvedType aspectType, ResolvedMember method) { return new ResolvedMemberImpl(Member.METHOD, method.getDeclaringType(), Modifier.PUBLIC | (Modifier.isStatic(method.getModifiers()) ? Modifier.STATIC : 0), method.getReturnType(), NameMangler.privilegedAccessMethodForMethod(method.getName(), method.getDeclaringType(), aspectType), method.getParameterTypes(), method.getExceptions()); }
/** * This static method goes on the aspect that declares the inter-type field */ public static ResolvedMember interFieldGetDispatcher(ResolvedMember field, UnresolvedType aspectType) { ResolvedMember rm = new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, field.getReturnType(), NameMangler.interFieldGetDispatcher(aspectType, field.getDeclaringType(), field.getName()), Modifier.isStatic(field .getModifiers()) ? UnresolvedType.NONE : new UnresolvedType[] { field.getDeclaringType() }, UnresolvedType.NONE); rm.setTypeVariables(field.getTypeVariables()); return rm; }
public static ResolvedMember inlineAccessMethodForMethod(UnresolvedType aspectType, ResolvedMember method) { UnresolvedType[] paramTypes = method.getParameterTypes(); if (!Modifier.isStatic(method.getModifiers())) { paramTypes = UnresolvedType.insert(method.getDeclaringType(), paramTypes); } return new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, // ??? what about privileged and super access // ???Modifier.PUBLIC | (method.isStatic() ? Modifier.STATIC : 0), method.getReturnType(), NameMangler.inlineAccessMethodForMethod(method.getName(), method.getDeclaringType(), aspectType), paramTypes, method.getExceptions()); }
/** * This field goes on top-most implementers of the interface the field is declared onto */ public static ResolvedMember interFieldInterfaceField(ResolvedMember field, UnresolvedType onClass, UnresolvedType aspectType, boolean newStyle) { String name = null; if (newStyle) { name = field.getName(); } else { name = NameMangler.interFieldInterfaceField(aspectType, field.getDeclaringType(), field.getName()); } return new ResolvedMemberImpl(Member.FIELD, onClass, makePublicNonFinal(field.getModifiers()), field.getReturnType(), name, UnresolvedType.NONE, UnresolvedType.NONE); }
/** * This instance method goes on the interface the field is declared onto as well as its top-most implementors */ public static ResolvedMember interFieldInterfaceSetter(ResolvedMember field, ResolvedType onType, UnresolvedType aspectType) { int modifiers = Modifier.PUBLIC; if (onType.isInterface()) { modifiers |= Modifier.ABSTRACT; } ResolvedMember rm = new ResolvedMemberImpl(Member.METHOD, onType, modifiers, UnresolvedType.VOID, NameMangler.interFieldInterfaceSetter(aspectType, field.getDeclaringType(), field.getName()), new UnresolvedType[] { field.getReturnType() }, UnresolvedType.NONE); rm.setTypeVariables(field.getTypeVariables()); return rm; }
private static ResolvedMember addCookieTo(ResolvedMember ret, UnresolvedType aspectType) { UnresolvedType[] params = ret.getParameterTypes(); UnresolvedType[] freshParams = UnresolvedType.add(params, aspectType); return new ResolvedMemberImpl(ret.getKind(), ret.getDeclaringType(), ret.getModifiers(), ret.getReturnType(), ret.getName(), freshParams, ret.getExceptions()); }
/** * This instance method goes on the interface the field is declared onto as well as its top-most implementors */ public static ResolvedMember interFieldInterfaceGetter(ResolvedMember field, ResolvedType onType, UnresolvedType aspectType) { int modifiers = Modifier.PUBLIC; if (onType.isInterface()) { modifiers |= Modifier.ABSTRACT; } ResolvedMember rm = new ResolvedMemberImpl(Member.METHOD, onType, modifiers, field.getReturnType(), NameMangler.interFieldInterfaceGetter(aspectType, field.getDeclaringType(), field.getName()), UnresolvedType.NONE, UnresolvedType.NONE); rm.setTypeVariables(field.getTypeVariables()); return rm; }
/** * This static method goes on the declaring aspect of the inter-type method. The implementation calls the interMethodBody() * method on the aspect. */ public static ResolvedMember interMethodDispatcher(ResolvedMember meth, UnresolvedType aspectType) { UnresolvedType[] paramTypes = meth.getParameterTypes(); if (!Modifier.isStatic(meth.getModifiers())) { paramTypes = UnresolvedType.insert(meth.getDeclaringType(), paramTypes); } ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, meth.getReturnType(), NameMangler.interMethodDispatcher(aspectType, meth.getDeclaringType(), meth.getName()), paramTypes, meth.getExceptions()); rmi.setParameterNames(meth.getParameterNames()); rmi.setTypeVariables(meth.getTypeVariables()); return rmi; }
/** * This field goes on the class the field is declared onto. Field names for ITDs onto interfaces are handled below. */ public static ResolvedMember interFieldClassField(ResolvedMember field, UnresolvedType aspectType, boolean newStyle) { int modifiers = (newStyle ? makeNonFinal(field.getModifiers()) : makePublicNonFinal(field.getModifiers())); String name = null; if (newStyle) { name = field.getName(); } else { name = NameMangler.interFieldClassField(field.getModifiers(), aspectType, field.getDeclaringType(), field.getName()); } return new ResolvedMemberImpl(Member.FIELD, field.getDeclaringType(), modifiers, field.getReturnType(), name, UnresolvedType.NONE, UnresolvedType.NONE); }
/** * 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 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; }
private void addMethodDispatch(LazyClassGen gen, ResolvedMember method, ResolvedMember accessMethod) { LazyMethodGen mg = makeMethodGen(gen, accessMethod); InstructionList il = new InstructionList(); InstructionFactory fact = gen.getFactory(); Type[] paramTypes = BcelWorld.makeBcelTypes(method.getParameterTypes()); int pos = 0; if (!Modifier.isStatic(method.getModifiers())) { il.append(InstructionConstants.ALOAD_0); pos++; } for (int i = 0, len = paramTypes.length; i < len; i++) { Type paramType = paramTypes[i]; il.append(InstructionFactory.createLoad(paramType, pos)); pos += paramType.getSize(); } il.append(Utility.createInvoke(fact, (BcelWorld) aspectType.getWorld(), method)); il.append(InstructionFactory.createReturn(BcelWorld.makeBcelType(method.getReturnType()))); mg.getBody().insert(il); gen.addMethodGen(mg); }