mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
Migrate Java code to separate QL repo.
This commit is contained in:
44
java/ql/test/query-tests/NonSynchronizedOverride/Test.java
Normal file
44
java/ql/test/query-tests/NonSynchronizedOverride/Test.java
Normal file
@@ -0,0 +1,44 @@
|
||||
class Super {
|
||||
synchronized void quack() {
|
||||
System.out.println("Quack.");
|
||||
}
|
||||
|
||||
synchronized Super self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
synchronized void foo() {}
|
||||
void bar() {}
|
||||
}
|
||||
|
||||
class Sub extends Super {
|
||||
// NOT OK
|
||||
void quack() {
|
||||
super.quack();
|
||||
super.quack();
|
||||
}
|
||||
|
||||
// OK
|
||||
Sub self() {
|
||||
return (Sub)super.self();
|
||||
}
|
||||
|
||||
// NOT OK
|
||||
void foo() {
|
||||
super.bar();
|
||||
}
|
||||
}
|
||||
|
||||
class A<T> {
|
||||
synchronized void foo() {}
|
||||
}
|
||||
|
||||
class B extends A<Integer> {
|
||||
// NOT OK
|
||||
void foo() {}
|
||||
}
|
||||
|
||||
class C extends A<String> {
|
||||
// NOT OK
|
||||
void foo() {}
|
||||
}
|
||||
Reference in New Issue
Block a user