~ubuntu-branches/ubuntu/jaunty/aspectj/jaunty

« back to all changes in this revision

Viewing changes to org.aspectj/modules/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch, Michael Koch, Thomas Girard, Mark Howard
  • Date: 2008-01-05 23:31:47 UTC
  • mfrom: (1.1.2 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080105233147-r425rd8nymruj6fk
Tags: 1.5.4-1
[ Michael Koch ]
* New upstream version. Closes: #459363
* Updated Standards-Version to 3.7.3.
* Added myself to Uploaders.

[ Thomas Girard ]
* Add Homepage: control field, and convert XS-Vcs-* to Vcs-*.

[ Mark Howard ]
* debian/watch: added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
520
520
                                return true;
521
521
                                //throw new BCException("no match for " + member + " in " + gen);
522
522
                        } else if (member.getKind() == Member.STATIC_INITIALIZATION) {
523
 
                                gen.forcePublic();
524
 
                                return true;
 
523
                                return gen.forcePublic();
525
524
                        } else {
526
525
                                throw new RuntimeException("unimplemented");
527
526
                        }
1088
1087
                clazz.addMethodGen(bridgeMethod);
1089
1088
        }
1090
1089
        
 
1090
        // Unlike toString() on a member, this does not include the declaring type
 
1091
        private String stringifyMember(ResolvedMember member) {
 
1092
                StringBuffer buf = new StringBuffer();
 
1093
        buf.append(member.getReturnType().getName());
 
1094
        buf.append(' ');
 
1095
                buf.append(member.getName());
 
1096
        if (member.getKind() != Member.FIELD) {
 
1097
                buf.append("(");
 
1098
                UnresolvedType[] params = member.getParameterTypes();
 
1099
            if (params.length != 0) {
 
1100
                buf.append(params[0]);
 
1101
                        for (int i=1, len = params.length; i < len; i++) {
 
1102
                    buf.append(", ");
 
1103
                            buf.append(params[i].getName());
 
1104
                        }
 
1105
            }
 
1106
                buf.append(")");
 
1107
        }
 
1108
        return buf.toString();
 
1109
        }
 
1110
        
1091
1111
    private boolean mungeMethodDelegate(BcelClassWeaver weaver, MethodDelegateTypeMunger munger) {
1092
1112
        ResolvedMember introduced = munger.getSignature();
1093
1113
 
1103
1123
 
1104
1124
        boolean shouldApply = munger.matches(weaver.getLazyClassGen().getType(), aspectType);
1105
1125
        if (shouldApply) {
 
1126
                
 
1127
                // If no implementation class was specified, the intention was that the types matching the pattern
 
1128
                // already implemented the interface, let's check that now!
 
1129
                if (munger.getImplClassName()==null) {
 
1130
                        boolean isOK = false;
 
1131
                        List/*LazyMethodGen*/ existingMethods = gen.getMethodGens();
 
1132
                        for (Iterator i = existingMethods.iterator(); i.hasNext() && !isOK;) {
 
1133
                            LazyMethodGen m = (LazyMethodGen) i.next();
 
1134
                            if (m.getName().equals(introduced.getName()) &&  
 
1135
                                m.getParameterSignature().equals(introduced.getParameterSignature()) &&
 
1136
                                m.getReturnType().equals(introduced.getReturnType())) {
 
1137
                                isOK = true;
 
1138
                            }
 
1139
                        }        
 
1140
                        if (!isOK) {
 
1141
                                // the class does not implement this method, they needed to supply a default impl class
 
1142
                                IMessage msg = new Message("@DeclareParents: No defaultImpl was specified but the type '"+gen.getName()+
 
1143
                                                "' does not implement the method '"+stringifyMember(introduced)+"' defined on the interface '"+introduced.getDeclaringType()+"'",
 
1144
                                                weaver.getLazyClassGen().getType().getSourceLocation(),true,new ISourceLocation[]{munger.getSourceLocation()});
 
1145
                                weaver.getWorld().getMessageHandler().handleMessage(msg);
 
1146
                                return false;
 
1147
                        }
 
1148
                        
 
1149
                        return true;
 
1150
                }
 
1151
                
 
1152
                
 
1153
                
1106
1154
            LazyMethodGen mg = new LazyMethodGen(
1107
1155
                    introduced.getModifiers() - Modifier.ABSTRACT,
1108
1156
                    BcelWorld.makeBcelType(introduced.getReturnType()),