[java] Resolve #468

- This is still not perfect. There are plenty of scenarios where this
could fail (ie: multidimensional arrays), but is closer to what we want
without a full rewrite.
 - On the future we need to review this rule once again.
This commit is contained in:
Juan Martín Sotuyo Dodero
2017-07-24 17:49:25 -03:00
parent 9143630351
commit df2765152e
2 changed files with 18 additions and 1 deletions

View File

@ -131,7 +131,7 @@ public class ArrayIsStoredDirectlyRule extends AbstractSunSecureRule {
if (val == null) {
continue;
}
ASTPrimarySuffix foo = se.getFirstDescendantOfType(ASTPrimarySuffix.class);
ASTPrimarySuffix foo = e.getFirstDescendantOfType(ASTPrimarySuffix.class);
if (foo != null && foo.isArrayDereference()) {
continue;
}

View File

@ -175,6 +175,23 @@ public class NotificationPacket {
this.message = new String(rawTypeData, StandardCharsets.UTF_8);
}
}
}
]]></code>
</test-code>
<test-code>
<description>#468 False positive when qualifying with this</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
private final int[] a;
public Foo(int[] b) {
this.a = new int[b.length];
for (int i = 0; i < b.length; i++) {
this.a[i] = b[i];
}
}
}
]]></code>
</test-code>