Skip to content

Commit c7d108a

Browse files
committed
add initial checkerframework integration
* cleanup annotations and dependency definitions * add initial checker configuration
1 parent 5eb31af commit c7d108a

178 files changed

Lines changed: 1001 additions & 1098 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

algorithms/active/adt/pom.xml

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ limitations under the License.
3434
</description>
3535

3636
<dependencies>
37-
<!-- LearnLib dependencies -->
37+
<!-- internal -->
3838
<dependency>
3939
<groupId>de.learnlib</groupId>
4040
<artifactId>learnlib-api</artifactId>
@@ -48,7 +48,7 @@ limitations under the License.
4848
<artifactId>learnlib-util</artifactId>
4949
</dependency>
5050

51-
<!-- AutomataLib dependencies -->
51+
<!-- external -->
5252
<dependency>
5353
<groupId>net.automatalib</groupId>
5454
<artifactId>automata-api</artifactId>
@@ -66,49 +66,46 @@ limitations under the License.
6666
<artifactId>automata-commons-util</artifactId>
6767
</dependency>
6868

69-
<dependency>
70-
<groupId>com.github.misberner.buildergen</groupId>
71-
<artifactId>buildergen</artifactId>
72-
</dependency>
7369
<dependency>
7470
<groupId>org.checkerframework</groupId>
7571
<artifactId>checker-qual</artifactId>
7672
</dependency>
7773

78-
<!--
79-
Test dependencies
80-
-->
81-
82-
<!-- TestNG -->
74+
<!-- build -->
8375
<dependency>
84-
<groupId>org.testng</groupId>
85-
<artifactId>testng</artifactId>
76+
<groupId>com.github.misberner.buildergen</groupId>
77+
<artifactId>buildergen</artifactId>
8678
</dependency>
8779

80+
<!-- test -->
8881
<dependency>
89-
<groupId>de.learnlib.testsupport</groupId>
90-
<artifactId>learnlib-learning-examples</artifactId>
82+
<groupId>de.learnlib</groupId>
83+
<artifactId>learnlib-drivers-simulator</artifactId>
84+
<scope>test</scope>
9185
</dependency>
92-
9386
<dependency>
9487
<groupId>de.learnlib.testsupport</groupId>
9588
<artifactId>learnlib-learner-it-support</artifactId>
9689
</dependency>
97-
9890
<dependency>
99-
<groupId>de.learnlib</groupId>
100-
<artifactId>learnlib-drivers-simulator</artifactId>
101-
<scope>test</scope>
91+
<groupId>de.learnlib.testsupport</groupId>
92+
<artifactId>learnlib-learning-examples</artifactId>
10293
</dependency>
10394
<dependency>
10495
<groupId>de.learnlib</groupId>
10596
<artifactId>learnlib-membership-oracles</artifactId>
10697
<scope>test</scope>
10798
</dependency>
99+
108100
<dependency>
109101
<groupId>net.automatalib</groupId>
110102
<artifactId>automata-serialization-dot</artifactId>
111103
<scope>test</scope>
112104
</dependency>
105+
106+
<dependency>
107+
<groupId>org.testng</groupId>
108+
<artifactId>testng</artifactId>
109+
</dependency>
113110
</dependencies>
114111
</project>

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/ads/DefensiveADS.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import net.automatalib.util.automata.ads.ADSUtil;
3737
import net.automatalib.words.Alphabet;
3838
import net.automatalib.words.Word;
39+
import org.checkerframework.checker.nullness.qual.NonNull;
40+
import org.checkerframework.checker.nullness.qual.Nullable;
3941

4042
/**
4143
* A variant of the backtracking ADS search (see {@link net.automatalib.util.automata.ads.ADS}, {@link
@@ -60,11 +62,11 @@ public final class DefensiveADS<S, I, O> {
6062
/**
6163
* The states, whose outgoing {@link #refinementInput}-transitions need to be closed.
6264
*/
63-
private Set<S> refinementStates;
65+
private @Nullable Set<S> refinementStates;
6466
/**
6567
* The output for which the outgoing transitions of {@link #refinementStates} are undefined.
6668
*/
67-
private I refinementInput;
69+
private @Nullable I refinementInput;
6870

6971
private DefensiveADS(final MealyMachine<S, I, ?, O> automaton,
7072
final Alphabet<I> alphabet,
@@ -145,7 +147,8 @@ private Optional<ADTNode<S, I, O>> compute(final Map<S, S> mapping) {
145147
candidateLoop:
146148
while (!splittingWordCandidates.isEmpty()) {
147149

148-
final Word<I> prefix = splittingWordCandidates.poll();
150+
@SuppressWarnings("nullness") // false positive https://github.com/typetools/checker-framework/issues/399
151+
final @NonNull Word<I> prefix = splittingWordCandidates.poll();
149152
final Map<S, S> currentToInitialMapping = mapping.keySet()
150153
.stream()
151154
.collect(Collectors.toMap(x -> automaton.getSuccessor(x,

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/adt/ADTResetNode.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import de.learnlib.api.oracle.SymbolQueryOracle;
2323
import net.automatalib.words.Word;
24+
import org.checkerframework.checker.nullness.qual.Nullable;
2425

2526
/**
2627
* Reset node implementation.
@@ -36,15 +37,15 @@
3637
*/
3738
public class ADTResetNode<S, I, O> implements ADTNode<S, I, O>, Serializable {
3839

39-
final ADTNode<S, I, O> successor;
40-
ADTNode<S, I, O> parent;
40+
private final ADTNode<S, I, O> successor;
41+
private ADTNode<S, I, O> parent;
4142

4243
public ADTResetNode(final ADTNode<S, I, O> successor) {
4344
this.successor = successor;
4445
}
4546

4647
@Override
47-
public I getSymbol() {
48+
public @Nullable I getSymbol() {
4849
return null;
4950
}
5051

@@ -69,7 +70,7 @@ public Map<O, ADTNode<S, I, O>> getChildren() {
6970
}
7071

7172
@Override
72-
public S getHypothesisState() {
73+
public @Nullable S getHypothesisState() {
7374
return null;
7475
}
7576

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/adt/ADTSymbolNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public NodeType getNodeType() {
6161

6262
@Override
6363
public String toString() {
64-
return super.getSymbol().toString();
64+
return String.valueOf(super.getSymbol());
6565
}
6666

6767
}

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/automaton/ADTHypothesis.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import net.automatalib.automata.transducers.MutableMealyMachine;
2222
import net.automatalib.words.Alphabet;
2323
import net.automatalib.words.Word;
24-
import org.checkerframework.checker.nullness.qual.NonNull;
25-
import org.checkerframework.checker.nullness.qual.Nullable;
2624

2725
/**
2826
* Hypothesis model.
@@ -41,13 +39,11 @@ public ADTHypothesis(final Alphabet<I> alphabet) {
4139
super(alphabet);
4240
}
4341

44-
@NonNull
4542
@Override
4643
public ADTState<I, O> getSuccessor(final ADTTransition<I, O> transition) {
4744
return transition.getTarget();
4845
}
4946

50-
@NonNull
5147
public ADTTransition<I, O> createOpenTransition(final ADTState<I, O> source,
5248
final I input,
5349
final ADTNode<ADTState<I, O>, I, O> siftTarget) {
@@ -82,31 +78,31 @@ protected ADTState<I, O> createState(final Void property) {
8278
return new ADTState<>(inputAlphabet.size());
8379
}
8480

85-
@NonNull
8681
@Override
87-
public ADTTransition<I, O> createTransition(final ADTState<I, O> successor, @Nullable final O properties) {
82+
public ADTTransition<I, O> createTransition(final ADTState<I, O> successor, final O properties) {
8883
ADTTransition<I, O> result = new ADTTransition<>();
8984
result.setTarget(successor);
9085
result.setOutput(properties);
9186
return result;
9287
}
9388

9489
@Override
95-
public void setTransitionOutput(final ADTTransition<I, O> transition, @Nullable final O output) {
90+
public void setTransitionOutput(final ADTTransition<I, O> transition, final O output) {
9691
transition.setOutput(output);
9792
}
9893

99-
@Nullable
10094
@Override
10195
public O getTransitionOutput(final ADTTransition<I, O> transition) {
10296
return transition.getOutput();
10397
}
10498

99+
@SuppressWarnings("nullness") // hypothesis is always complete
105100
@Override
106101
public Word<I> transformAccessSequence(final Word<I> word) {
107102
return this.getState(word).getAccessSequence();
108103
}
109104

105+
@SuppressWarnings("nullness") // hypothesis is always complete
110106
@Override
111107
public boolean isAccessSequence(final Word<I> word) {
112108
return this.getState(word).getAccessSequence().equals(word);

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/config/LeafSplitters.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.Iterator;
1919
import java.util.Map;
20+
import java.util.Objects;
2021

2122
import de.learnlib.algorithms.adt.adt.ADTLeafNode;
2223
import de.learnlib.algorithms.adt.adt.ADTNode;
@@ -118,7 +119,7 @@ private static <S, I, O> ADTNode<S, I, O> finalizeSplit(final ADTNode<S, I, O> n
118119
O oldOut = oldIter.next();
119120
O newOut = newIter.next();
120121

121-
while (oldOut.equals(newOut)) {
122+
while (Objects.equals(oldOut, newOut)) {
122123
final ADTNode<S, I, O> next = new ADTSymbolNode<>(previous, suffixIter.next());
123124

124125
previous.getChildren().put(oldOut, next);

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/config/model/extender/DefaultExtender.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.HashMap;
1919
import java.util.Map;
20+
import java.util.Objects;
2021
import java.util.Optional;
2122
import java.util.Set;
2223
import java.util.function.Function;
@@ -88,7 +89,7 @@ public <I, O> ExtensionResult<ADTState<I, O>, I, O> computeExtension(final ADTHy
8889
partialTransitionAnalyzer.closeTransition(s, input);
8990
}
9091

91-
if (!hypothesis.getOutput(s, input).equals(output)) {
92+
if (!Objects.equals(hypothesis.getOutput(s, input), output)) {
9293
final ADTState<I, O> initial = entry.getValue();
9394
final Word<I> as = initial.getAccessSequence();
9495
final Word<O> asOut = hypothesis.computeOutput(as);

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/learner/ADTLearner.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
import net.automatalib.words.Word;
6363
import net.automatalib.words.WordBuilder;
6464
import net.automatalib.words.impl.Alphabets;
65-
import org.checkerframework.checker.nullness.qual.NonNull;
6665

6766
/**
6867
* The main learning algorithm.
@@ -280,7 +279,6 @@ public boolean refineHypothesisInternal(DefaultQuery<I, Word<O>> ceQuery) {
280279
return true;
281280
}
282281

283-
@NonNull
284282
@Override
285283
public MealyMachine<?, I, ?, O> getHypothesisModel() {
286284
return this.hypothesis;

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/model/ExtensionResult.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import de.learnlib.algorithms.adt.api.ADTExtender;
2020
import de.learnlib.api.query.DefaultQuery;
2121
import net.automatalib.words.Word;
22+
import org.checkerframework.checker.nullness.qual.Nullable;
2223

2324
/**
2425
* A class that describes the possible result a {@link ADTExtender} can return. Extending a parent trace can either <ul>
@@ -39,9 +40,8 @@ public class ExtensionResult<S, I, O> {
3940

4041
private static final ExtensionResult<?, ?, ?> EMPTY = new ExtensionResult();
4142

42-
private final DefaultQuery<I, Word<O>> counterExample;
43-
44-
private final ADTNode<S, I, O> replacement;
43+
private final @Nullable DefaultQuery<I, Word<O>> counterExample;
44+
private final @Nullable ADTNode<S, I, O> replacement;
4545

4646
private ExtensionResult() {
4747
this.replacement = null;
@@ -89,7 +89,7 @@ public boolean isCounterExample() {
8989
*
9090
* @return the counterexample
9191
*/
92-
public DefaultQuery<I, Word<O>> getCounterExample() {
92+
public @Nullable DefaultQuery<I, Word<O>> getCounterExample() {
9393
return counterExample;
9494
}
9595

@@ -107,7 +107,7 @@ public boolean isReplacement() {
107107
*
108108
* @return the replacement
109109
*/
110-
public ADTNode<S, I, O> getReplacement() {
110+
public @Nullable ADTNode<S, I, O> getReplacement() {
111111
return replacement;
112112
}
113113
}

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/model/ObservationTree.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.HashMap;
2020
import java.util.Iterator;
2121
import java.util.Map;
22+
import java.util.Objects;
2223
import java.util.Optional;
2324
import java.util.function.Function;
2425

@@ -130,7 +131,7 @@ private FastMealyState<O> addTrace(final FastMealyState<O> state, final Word<I>
130131
nextState = this.observationTree.addState();
131132
this.observationTree.addTransition(iter, nextInput, nextState, nextOuput);
132133
} else {
133-
assert this.observationTree.getOutput(iter, nextInput).equals(nextOuput) : "Inconsistent observations";
134+
assert Objects.equals(nextOuput, this.observationTree.getOutput(iter, nextInput)) : "Inconsistent observations";
134135
nextState = this.observationTree.getSuccessor(iter, nextInput);
135136
}
136137

0 commit comments

Comments
 (0)