From 93b7bedd6e367f07cf74782b6d367b9f6f418698 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 22 May 2008 18:26:18 +0000 Subject: [PATCH] 233497: dont produce SIOOBE if a classfile from the aspectpath isn't at a place that includes its package prefix --- weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java | 13 ++++++++++--- 1 file 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); -- 2.39.5