aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoraclement <aclement>2008-05-22 18:26:18 +0000
committeraclement <aclement>2008-05-22 18:26:18 +0000
commit93b7bedd6e367f07cf74782b6d367b9f6f418698 (patch)
treea4995c9ed05cb0930b2739d61cf34f3ccaea24fd /weaver
parentf0142758d0b83904bd648dddf270199777d5ec6c (diff)
downloadaspectj-93b7bedd6e367f07cf74782b6d367b9f6f418698.tar.gz
aspectj-93b7bedd6e367f07cf74782b6d367b9f6f418698.zip
233497: dont produce SIOOBE if a classfile from the aspectpath isn't at a place that includes its package prefix
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
index e329c2af9..8b84bf555 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
@@ -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);