mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-17 15:50:53 +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
34 lines
1.1 KiB
Java
34 lines
1.1 KiB
Java
import valuebased.classes.OpenValueBased;
|
|
class One extends OpenValueBased { }
|
|
class Two extends One { }
|
|
class Three extends Two { }
|
|
class ComplexVBHierarchy extends Three { }
|
|
|
|
class Main {
|
|
final ComplexVBHierarchy vb = new ComplexVBHierarchy();
|
|
{
|
|
final ComplexVBHierarchy localVb = new ComplexVBHierarchy();
|
|
final Object objectVb = new ComplexVBHierarchy();
|
|
|
|
synchronized (<warning descr="Attempt to synchronize on an instance of a value-based class">vb</warning>) {}
|
|
synchronized (<warning descr="Attempt to synchronize on an instance of a value-based class">localVb</warning>) {}
|
|
synchronized (<warning descr="Attempt to synchronize on an instance of a value-based class">objectVb</warning>) {}
|
|
synchronized (ComplexVBHierarchy.class) {}
|
|
f(vb);
|
|
g(vb);
|
|
}
|
|
|
|
void f(ComplexVBHierarchy vb) {
|
|
synchronized (<warning descr="Attempt to synchronize on an instance of a value-based class">vb</warning>) {}
|
|
}
|
|
|
|
void g(Object vb) {
|
|
synchronized (vb) {}
|
|
}
|
|
|
|
@SuppressWarnings("synchronization")
|
|
void h(ComplexVBHierarchy vb) {
|
|
synchronized (vb) {}
|
|
}
|
|
}
|