[fixes #678] @Synchronize an instance method on static variable no longer emits a warning.

This commit is contained in:
Reinier Zwitserloot committed 2020-02-14 01:21:24 +01:00
1 parent 15b09ee274
commit 89f98da78d
16 files changed
+156 -44

No files matched your search

@@ -8,7 +8,7 @@ class SynchronizedName {
}
}
void test4() {
synchronized (this.READ) {
synchronized (SynchronizedName.READ) {
System.out.println("four");
}
}
@@ -2,8 +2,6 @@ class SynchronizedNameStaticToInstanceRef {
private Object read = new Object();
private static Object READ = new Object();
static void test3() {
synchronized (SynchronizedNameStaticToInstanceRef.read) {
System.out.println("three");
}
System.out.println("three");
}
}
@@ -0,0 +1,18 @@
class SynchronizedOnStatic<Z> {
static class Inner {
private static Object LCK = new Object[0];
public void foo() {
synchronized (SynchronizedOnStatic.Inner.LCK) {
System.out.println();
}
}
}
class Inner2 {
private Object LCK = new Object[0];
public void foo() {
synchronized (this.LCK) {
System.out.println();
}
}
}
}
@@ -13,7 +13,7 @@ class SynchronizedName {
}
}
@lombok.Synchronized("READ") void test4() {
synchronized (this.READ)
synchronized (SynchronizedName.READ)
{
System.out.println("four");
}
@@ -7,9 +7,6 @@ class SynchronizedNameStaticToInstanceRef {
super();
}
static @lombok.Synchronized("read") void test3() {
synchronized (SynchronizedNameStaticToInstanceRef.read)
{
System.out.println("three");
}
System.out.println("three");
}
}
@@ -0,0 +1,31 @@
class SynchronizedOnStatic<Z> {
static class Inner {
private static Object LCK = new Object[0];
<clinit>() {
}
Inner() {
super();
}
public @lombok.Synchronized("LCK") void foo() {
synchronized (SynchronizedOnStatic.Inner.LCK)
{
System.out.println();
}
}
}
class Inner2 {
private Object LCK = new Object[0];
Inner2() {
super();
}
public @lombok.Synchronized("LCK") void foo() {
synchronized (this.LCK)
{
System.out.println();
}
}
}
SynchronizedOnStatic() {
super();
}
}
@@ -0,0 +1,16 @@
class SynchronizedOnStatic<Z> {
static class Inner {
private static Object LCK = new Object[0];
@lombok.Synchronized("LCK")
public void foo() {
System.out.println();
}
}
class Inner2 {
private Object LCK = new Object[0];
@lombok.Synchronized("LCK")
public void foo() {
System.out.println();
}
}
}
@@ -1 +1 @@
5 non-static variable read cannot be referenced from a static context
5 The field read is non-static and this cannot be used on this static method
@@ -1 +0,0 @@
8 The static field SynchronizedName.READ should be accessed in a static way
@@ -1 +1 @@
5 The field write does not exist.
5 The field write does not exist
@@ -1 +1 @@
5 Cannot make a static reference to the non-static field SynchronizedNameStaticToInstanceRef.read
5 The field read is non-static and thus cannot be used on this static method
@@ -1 +0,0 @@
5 non-static variable read cannot be referenced from a static context