mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-31 02:50:55 +07:00
This renames ValueBasedWarningsInspection to SynchronizeOnValueBasedClassInspection and alters the logic, it checks first the original type of the monitor and if it's not a value-based class then it employs DFA to infer the type more precisely and checks the inferred type if it differs from the type of the monitor. This solution is more robust, because DFA might fail sometimes. This patch also adds the suppressId to SynchronizeOnValueBasedClassInspection in order to support the new javac warning category. Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com> GitOrigin-RevId: f7c3520b84bf6f9080280dc2689ff4f63ac4be09
33 lines
906 B
Java
33 lines
906 B
Java
import valuebased.classes.AbstractValueBased;
|
|
|
|
class AC extends AbstractValueBased {
|
|
final AC ac = new AC();
|
|
final Object objectAc = new AC();
|
|
{
|
|
final AC localAc = new AC();
|
|
|
|
synchronized (<warning descr="Attempt to synchronize on an instance of a value-based class">ac</warning>) {}
|
|
synchronized (<warning descr="Attempt to synchronize on an instance of a value-based class">objectAc</warning>) {}
|
|
synchronized (<warning descr="Attempt to synchronize on an instance of a value-based class">localAc</warning>) {}
|
|
synchronized (AC.class) {}
|
|
|
|
synchronized (new Object()) {}
|
|
|
|
f(ac);
|
|
g(ac);
|
|
}
|
|
|
|
void f(AC ac) {
|
|
synchronized (<warning descr="Attempt to synchronize on an instance of a value-based class">ac</warning>) {}
|
|
}
|
|
|
|
void g(Object ac) {
|
|
synchronized (ac) {}
|
|
}
|
|
|
|
@SuppressWarnings("synchronization")
|
|
void h(AC ac) {
|
|
synchronized (ac) {}
|
|
}
|
|
}
|