Browse Source

233497: dont produce SIOOBE if a classfile from the aspectpath isn't at a place that includes its package prefix

tags/V1_6_1x
aclement 16 years ago
parent
commit
93b7bedd6e
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java

+ 10
- 3
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java View File

@@ -277,19 +277,26 @@ public class BcelWeaver implements IWeaver {
for (int i = 0; i < classFiles.length; i++) {
FileInputStream fis = new FileInputStream(classFiles[i]);
byte[] bytes = FileUtil.readAsByteArray(fis);
addIfAspect(bytes,classFiles[i].getAbsolutePath(),addedAspects);
addIfAspect(bytes,classFiles[i].getAbsolutePath(),addedAspects,dir);
fis.close();
}
return addedAspects;
}
private void addIfAspect(byte[] bytes, String name, List toList) throws IOException {
private void addIfAspect(byte[] bytes, String name, List toList, File dir) throws IOException {
ClassParser parser = new ClassParser(new ByteArrayInputStream(bytes),name);
JavaClass jc = parser.parse();
ResolvedType type = world.addSourceObjectType(jc).getResolvedTypeX();
String typeName = type.getName().replace('.', File.separatorChar);
int end = name.indexOf(typeName);
String binaryPath = name.substring(0,end-1);
String binaryPath = null;
// if end is -1 then something wierd happened, the class file is not in the correct place, something like
// bin/A.class when the declaration for A specifies it is in a package.
if (end==-1) {
binaryPath = dir.getAbsolutePath();
} else {
binaryPath = name.substring(0,end-1);
}
type.setBinaryPath(binaryPath);
if (type.isAspect()) {
toList.add(type);

Loading…
Cancel
Save