diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java index 3963e09f4b..70d6a8b73e 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java @@ -138,6 +138,8 @@ public class Lint { public final Kind missingAspectForReweaving = new Kind("missingAspectForReweaving", "aspect {0} cannot be found when reweaving {1}"); + public final Kind arrayCannotBeVoid = new Kind("arrayCannotBeVoid", "arrays cannot have a void type, but found ''{0}'' in pointcut"); + private static final Trace trace = TraceFactory.getTraceFactory().getTrace(Lint.class); public Lint(World world) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java index 6eab96f150..c5f43da8fc 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/World.java @@ -316,7 +316,15 @@ public ResolvedType resolve(UnresolvedType ty, boolean allowMissing) { synchronized (buildingTypeLock) { if (ty.isArray()) { ResolvedType componentType = resolve(ty.getComponentType(), allowMissing); + if (componentType.isVoid()) { + if (isInJava5Mode() && getLint().adviceDidNotMatch.isEnabled()) { + getLint().arrayCannotBeVoid.signal(ty.toString(), null); + } + ret = new MissingResolvedTypeWithKnownSignature(signature, this); + } + else { ret = new ArrayReferenceType(signature, "[" + componentType.getErasureSignature(), this, componentType); + } } else { ret = resolveToReferenceType(ty, allowMissing); if (!allowMissing && ret.isMissing()) { diff --git a/org.aspectj.matcher/src/main/resources/org/aspectj/weaver/XlintDefault.properties b/org.aspectj.matcher/src/main/resources/org/aspectj/weaver/XlintDefault.properties index f996d040b9..b7a9822463 100644 --- a/org.aspectj.matcher/src/main/resources/org/aspectj/weaver/XlintDefault.properties +++ b/org.aspectj.matcher/src/main/resources/org/aspectj/weaver/XlintDefault.properties @@ -48,3 +48,5 @@ missingAspectForReweaving=error cannotAdviseJoinpointInInterfaceWithAroundAdvice=warning nonReweavableTypeEncountered=error + +arrayCannotBeVoid=warning diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java index cf9a944fb6..550476b4d0 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java @@ -110,6 +110,9 @@ public void testPrimitiveArrays() { ResolvedType[] primitives = world.resolve(primitiveTypes); for (ResolvedType ty : primitives) { UnresolvedType tx = UnresolvedType.forSignature("[" + ty.getSignature()); + // 'void[]' is an illegal type -> skip + if (tx.getSignature().equals("[V")) + continue; ResolvedType aty = world.resolve(tx, true); assertTrue("Couldnt find type " + tx, !aty.isMissing()); modifiersTest(aty, Modifier.PUBLIC | Modifier.FINAL); @@ -128,6 +131,9 @@ public void testPrimitiveArrays() { for (ResolvedType ty1 : primitives) { isCoerceableFromTest(aty, ty1, false); tx = UnresolvedType.forSignature("[" + ty1.getSignature()); + // 'void[]' is an illegal type -> skip + if (tx.getSignature().equals("[V")) + continue; ResolvedType aty1 = getWorld().resolve(tx, true); assertTrue("Couldnt find type " + tx, !aty1.isMissing()); if (ty.equals(ty1)) { @@ -142,6 +148,9 @@ public void testPrimitiveArrays() { // double dimension arrays for (ResolvedType ty : primitives) { UnresolvedType tx = UnresolvedType.forSignature("[[" + ty.getSignature()); + // 'void[][]' is an illegal type -> skip + if (tx.getSignature().equals("[[V")) + continue; ResolvedType aty = world.resolve(tx, true); assertTrue("Couldnt find type " + tx, !aty.isMissing()); modifiersTest(aty, Modifier.PUBLIC | Modifier.FINAL); @@ -160,6 +169,9 @@ public void testPrimitiveArrays() { for (ResolvedType ty1 : primitives) { isCoerceableFromTest(aty, ty1, false); tx = UnresolvedType.forSignature("[[" + ty1.getSignature()); + // 'void[][]' is an illegal type -> skip + if (tx.getSignature().equals("[[V")) + continue; ResolvedType aty1 = getWorld().resolve(tx, true); assertTrue("Couldnt find type " + tx, !aty1.isMissing()); if (ty.equals(ty1)) {