Browse Source

Fix 431976: thisJoinPoint considered uninitialized variable

tags/V1_8_0RC3
Andy Clement 10 years ago
parent
commit
331399f82b

+ 13
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java View File

@@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.DeclareAnnotationDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration;
@@ -48,6 +49,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.IPrivilegedHandler;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
@@ -506,6 +508,17 @@ public class AjProblemReporter extends ProblemReporter {
}
super.unusedPrivateType(typeDecl);
}
private final static char[] thisJoinPointName = "thisJoinPoint".toCharArray();
public void uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location) {
if (CharOperation.equals(binding.name,thisJoinPointName)) {
// If in advice, this is not a problem
if (binding.declaringScope!=null && binding.declaringScope.referenceContext() instanceof AdviceDeclaration) {
return;
}
}
super.uninitializedLocalVariable(binding, location);
}
public void abstractMethodInConcreteClass(SourceTypeBinding type) {
if (type.scope!=null && type.scope.referenceContext instanceof AspectDeclaration) {

+ 10
- 0
tests/bugs180/pr431976/Code.java View File

@@ -0,0 +1,10 @@
import org.aspectj.lang.annotation.SuppressAjWarnings;

privileged aspect BugThisJoinPoint {

@SuppressAjWarnings("adviceDidNotMatch")
void around(): execution(boolean forceFocus ()) {
thisJoinPoint.getThis();
}
}


+ 4
- 0
tests/src/org/aspectj/systemtest/ajc180/Ajc180Tests.java View File

@@ -21,6 +21,10 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
*/
public class Ajc180Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void testThisJoinPointNotInitialized_431976() {
runTest("thisJoinPoint not initialized");
}
public void testNullAnnotationMatching_431541() {
runTest("NullAnnotationMatching exception");
}

+ 4
- 0
tests/src/org/aspectj/systemtest/ajc180/ajc180.xml View File

@@ -2,6 +2,10 @@

<suite>

<ajc-test dir="bugs180/pr431976" title="thisJoinPoint not initialized">
<compile options="-1.8" files="Code.java"/>
</ajc-test>

<ajc-test dir="bugs180/pr431541" title="NullAnnotationMatching exception">
<compile options="-1.8" files="Test.aj"/>
</ajc-test>

Loading…
Cancel
Save