You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/08/27 17:01:01 UTC
[GitHub] [netbeans] mbien commented on issue #4545: Incorrect code analysis
mbien commented on issue #4545:
URL: https://github.com/apache/netbeans/issues/4545#issuecomment-1229227791
seems to be specific to final array fields with write ops.
```java
private final static char[] bar1 = {'y', 'n'}; // marked unused
private final static char[] bar2 = new char[2]; // ok
public static void main(String[] args) {
final char[] foo1 = {'y', 'n'}; // marked unused
final char[] foo3 = new char[] {'y', 'n'}; // marked unused
char[] foo2 = {'y', 'n'}; // ok
final char[] foo4 = new char[2]; // ok
char[] foo5; // ok
foo5 = new char[] {'Y', 'n'};
System.out.println(foo1);
System.out.println(foo2);
System.out.println(foo3);
System.out.println(foo4);
System.out.println(foo5);
System.out.println(bar1);
System.out.println(bar2);
}
```
reverting the array handler of #4421 fixes this issue but it would break #4402 again for arrays. Can't come up with a quick way of fixing this atm. Shame we haven't noticed this earlier so we could have simply reverted the PR.
```diff
diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unbalanced.java b/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unbalanced.java
index 51829b5..3c3d3ae 100644
--- a/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unbalanced.java
+++ b/java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unbalanced.java
@@ -152,7 +152,7 @@
if (secondAccess != null) {
record(ctx.getInfo(), var, secondAccess);
}
- } else if (!var.getModifiers().contains(Modifier.FINAL)) {
+ } else {
record(ctx.getInfo(), var, State.WRITE, State.READ);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists