]> source.dussan.org Git - aspectj.git/commitdiff
233497: dont produce SIOOBE if a classfile from the aspectpath isn't at a place that...
authoraclement <aclement>
Thu, 22 May 2008 18:26:18 +0000 (18:26 +0000)
committeraclement <aclement>
Thu, 22 May 2008 18:26:18 +0000 (18:26 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java

index e329c2af92926756e0fbef5377b103970efde68c..8b84bf555be8c486f5f4c3df92fdf385b40a88be 100644 (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);