changes for IDEA-CR-7640

This commit is contained in:
Bas Leijdekkers
2015-12-31 17:12:34 +01:00
parent f73c6b7da2
commit 34408fba3d
3 changed files with 18 additions and 8 deletions
@@ -21,6 +21,7 @@ import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.psiutils.ClassUtils;
import com.siyeh.ig.psiutils.ExpressionUtils;
import com.siyeh.ig.psiutils.ParenthesesUtils;
import com.siyeh.ig.psiutils.TypeUtils;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@@ -40,8 +41,7 @@ public class AtomicFieldUpdaterIssuesInspection extends BaseInspection {
@NotNull
@Override
protected String buildErrorString(Object... infos) {
final String message = (String)infos[0];
return message;
return (String)infos[0];
}
@Override
@@ -70,7 +70,7 @@ public class AtomicFieldUpdaterIssuesInspection extends BaseInspection {
return;
}
final String fieldName = (String)value;
final PsiExpression firstArgument = arguments[0];
final PsiExpression firstArgument = ParenthesesUtils.stripParentheses(arguments[0]);
if (!(firstArgument instanceof PsiClassObjectAccessExpression)) {
return;
}
@@ -1,7 +1,5 @@
<html>
<body>
<html>
<body>
Reports issues on fields of type <b>java.util.concurrent.atomic.AtomicLongFieldUpdater</b>,
<b>java.util.concurrent.atomic.AtomicIntegerFieldUpdater</b> or <b>java.util.concurrent.atomic.AtomicReferenceFieldUpdater</b>.
The issues reported are identical to the runtime problems that can happen with atomic field updaters:
@@ -11,6 +9,4 @@ specified field not found, specified field not accessible, specified field of th
<p>
<small>New in 16</small>
</body>
</html>
</body>
</html>
@@ -38,7 +38,7 @@ public class AtomicFieldUpdaterIssuesInspectionTest extends LightInspectionTestC
"class A {" +
" private static volatile int value = 0;" +
" private static final AtomicIntegerFieldUpdater updater = " +
" AtomicIntegerFieldUpdater.newUpdater(A.class, /*Field 'value' has 'static' modifier*/\"value\"/**/);" +
" AtomicIntegerFieldUpdater.newUpdater((A.class), /*Field 'value' has 'static' modifier*/(\"value\")/**/);" +
"}");
}
@@ -100,6 +100,20 @@ public class AtomicFieldUpdaterIssuesInspectionTest extends LightInspectionTestC
"}");
}
/**
* private fields are not accessible at runtime even from inner classes.
*/
public void testNotAccessible2() {
doTest("import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;" +
"class Z {" +
" private volatile int value = 0;" +
" static class A {\n" +
" private static final AtomicIntegerFieldUpdater updater = \n" +
" AtomicIntegerFieldUpdater.newUpdater(Z.class, /*'private' field 'value' is not accessible from here*/\"value\"/**/);\n" +
" }" +
"}");
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {