Skip to content

Commit b0fcccd

Browse files
authored
Update dependencies (#139)
* adjust to AutomataLib refactorings * bump basic depdency versions * bump checkstyle + cleanups * bump spotbugs + cleanups * bump pmd + cleanups * bump checkerframework + cleanups * fix wrong simplification * improve comments * cleanups * do not fail on javadoc warnings completness of documentation is now checked by checkstyle and we would have to disable failing anyways when moving on to JDK 17
1 parent 9e456ff commit b0fcccd

173 files changed

Lines changed: 801 additions & 702 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.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2424
* The `OTUtils` class no longer provides the `displayHTMLInBrowser` methods in order to not depend on `java.desktop`. If you relied on this functionality, use the `writeHTMLToFile` methods instead and call `Desktop.getDesktop().open(file.toURI())` yourself.
2525
* The classes in the `learnlib-learning-examples` artifact have their package renamed to `de.learnlib.testsupport.example`.
2626
* Some other refactorings include:
27+
* The `AbstractVisualizationTest` has been refactored into the `VisualizationUtils` factory.
2728
* The `learnlib-datastructure-ot`, `learnlib-datastructure-dt`, `learnlib-datastructure-list`, and `learnlib-datastructure-pta` artifacts have been merged into a new `learnlib-datastructures` artifact.
2829
* The `learnlib-oml` artifact (including its packages and class names) has been renamed to `learnlib-lambda`.
2930
* Various counters (especially `*Counter*SUL`s) have been streamlined. In most cases there now exists a single counter that tracks multiple properties.

algorithms/active/aaar/src/main/java/de/learnlib/algorithm/aaar/AbstractAAARLearner.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ public boolean refineHypothesis(DefaultQuery<CI, D> query) {
116116
final D outOld = oracle.answerQuery(testOld);
117117
final D outNew = oracle.answerQuery(testNew);
118118

119-
if (!Objects.equals(outOld, outNew)) { // add new abstraction
119+
if (Objects.equals(outOld, outNew)) {
120+
prefix = prefix.append(r);
121+
wb.append(r);
122+
} else { // add new abstraction
120123
final AI newA = tree.splitLeaf(r, cur, prefix, suffix, outOld);
121124
abs.addSymbol(newA);
122125
rep.addSymbol(cur);
123126
learner.addAlphabetSymbol(cur);
124127
return true;
125-
} else {
126-
prefix = prefix.append(r);
127-
wb.append(r);
128128
}
129129
}
130130

@@ -182,8 +182,8 @@ public L getLearner() {
182182
return this.learner;
183183
}
184184

185-
protected <S1, S2, SP, TP> void copyAbstract(UniversalDeterministicAutomaton<S1, CI, ?, SP, TP> src,
186-
MutableDeterministic<S2, AI, ?, SP, TP> tgt) {
185+
protected <S1, S2, T, SP, TP> void copyAbstract(UniversalDeterministicAutomaton<S1, CI, T, SP, TP> src,
186+
MutableDeterministic<S2, AI, ?, SP, TP> tgt) {
187187
// states
188188
final Map<S2, S1> states = new HashMap<>();
189189
final Map<S1, S2> statesRev = new HashMap<>();
@@ -200,12 +200,15 @@ protected <S1, S2, SP, TP> void copyAbstract(UniversalDeterministicAutomaton<S1,
200200
// transitions
201201
for (Entry<S2, S1> e : states.entrySet()) {
202202
for (CI r : rep) {
203-
final AbstractAbstractionTree<AI, CI, D> tree = getTreeForRepresentative(r);
204-
final AI a = tree.getAbstractSymbol(r);
205-
tgt.setTransition(e.getKey(),
206-
a,
207-
statesRev.get(src.getSuccessor(e.getValue(), r)),
208-
src.getTransitionProperty(e.getValue(), r));
203+
final T trans = src.getTransition(e.getValue(), r);
204+
if (trans != null) {
205+
final AbstractAbstractionTree<AI, CI, D> tree = getTreeForRepresentative(r);
206+
final AI a = tree.getAbstractSymbol(r);
207+
tgt.setTransition(e.getKey(),
208+
a,
209+
statesRev.get(src.getSuccessor(trans)),
210+
src.getTransitionProperty(trans));
211+
}
209212
}
210213
}
211214
}

algorithms/active/aaar/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
requires net.automatalib.common.util;
3636
requires net.automatalib.core;
3737

38-
// make non-static once https://github.com/typetools/checker-framework/issues/4559 is implemented
38+
// annotations are 'provided'-scoped and do not need to be loaded at runtime
3939
requires static org.checkerframework.checker.qual;
4040

4141
exports de.learnlib.algorithm.aaar;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ private Optional<ADTNode<S, I, O>> compute(Map<S, S> mapping) {
194194
final O nextOutput = automaton.getOutput(current, i);
195195

196196
final Map<S, S> nextMapping;
197-
if (!successors.containsKey(nextOutput)) {
197+
if (successors.containsKey(nextOutput)) {
198+
nextMapping = successors.get(nextOutput);
199+
} else {
198200
nextMapping = new HashMap<>();
199201
successors.put(nextOutput, nextMapping);
200-
} else {
201-
nextMapping = successors.get(nextOutput);
202202
}
203203

204204
// invalid input

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ public boolean refineHypothesis(DefaultQuery<I, Word<O>> ce) {
162162
final DefaultQuery<I, Word<O>> currentCE = this.openCounterExamples.poll();
163163
this.allCounterExamples.add(currentCE);
164164

165-
while (this.refineHypothesisInternal(currentCE)) {}
165+
while (this.refineHypothesisInternal(currentCE)) {
166+
// refine exhaustively
167+
}
166168
}
167169

168170
// subtree replacements may reactivate old CEs

algorithms/active/adt/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
requires net.automatalib.util;
4242
requires org.slf4j;
4343

44+
// annotations are 'provided'-scoped and do not need to be loaded at runtime
4445
requires static de.learnlib.tooling.annotation;
45-
// make non-static once https://github.com/typetools/checker-framework/issues/4559 is implemented
4646
requires static org.checkerframework.checker.qual;
4747

4848
exports de.learnlib.algorithm.adt.ads;

algorithms/active/adt/src/test/java/de/learnlib/algorithm/adt/learner/ADTVisualizationTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,36 @@
1616
package de.learnlib.algorithm.adt.learner;
1717

1818
import java.io.IOException;
19+
import java.io.InputStream;
1920
import java.io.StringWriter;
2021

2122
import de.learnlib.oracle.membership.SULAdaptiveOracle;
22-
import de.learnlib.sul.SUL;
23-
import de.learnlib.testsupport.AbstractVisualizationTest;
23+
import de.learnlib.testsupport.VisualizationUtils;
2424
import de.learnlib.testsupport.example.mealy.ExampleCoffeeMachine.Input;
25-
import net.automatalib.alphabet.Alphabet;
25+
import net.automatalib.common.util.IOUtil;
2626
import net.automatalib.serialization.dot.GraphDOT;
27-
import org.checkerframework.checker.initialization.qual.UnderInitialization;
2827
import org.testng.Assert;
2928
import org.testng.annotations.Test;
3029

31-
public class ADTVisualizationTest extends AbstractVisualizationTest<ADTLearner<Input, String>> {
30+
public class ADTVisualizationTest {
3231

33-
@Override
34-
protected ADTLearner<Input, String> getLearnerBuilder(@UnderInitialization ADTVisualizationTest this,
35-
Alphabet<Input> alphabet,
36-
SUL<Input, String> sul) {
37-
return new ADTLearnerBuilder<Input, String>().withAlphabet(alphabet)
38-
.withOracle(new SULAdaptiveOracle<>(sul))
39-
.create();
32+
private final ADTLearner<Input, String> learner;
33+
34+
public ADTVisualizationTest() {
35+
this.learner =
36+
VisualizationUtils.runExperiment((alphabet, sul) -> new ADTLearnerBuilder<Input, String>().withAlphabet(
37+
alphabet).withOracle(new SULAdaptiveOracle<>(sul)).create());
4038
}
4139

4240
@Test
4341
public void testVisualization() throws IOException {
44-
final String expectedADT = resourceAsString("/adt.dot");
42+
try (InputStream is = ADTVisualizationTest.class.getResourceAsStream("/adt.dot")) {
43+
final String expectedADT = IOUtil.toString(IOUtil.asBufferedUTF8Reader(is));
44+
final StringWriter actualADT = new StringWriter();
4545

46-
final StringWriter actualADT = new StringWriter();
47-
GraphDOT.write(super.learner.getADT().getRoot(), actualADT);
46+
GraphDOT.write(this.learner.getADT().getRoot(), actualADT);
4847

49-
Assert.assertEquals(actualADT.toString(), expectedADT);
48+
Assert.assertEquals(actualADT.toString(), expectedADT);
49+
}
5050
}
5151
}

algorithms/active/dhc/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
requires net.automatalib.common.util;
3737
requires net.automatalib.core;
3838

39+
// annotations are 'provided'-scoped and do not need to be loaded at runtime
3940
requires static de.learnlib.tooling.annotation;
40-
// make non-static once https://github.com/typetools/checker-framework/issues/4559 is implemented
4141
requires static org.checkerframework.checker.qual;
4242

4343
exports de.learnlib.algorithm.dhc.mealy;

algorithms/active/dhc/src/test/java/de/learnlib/algorithm/dhc/mealy/MealyDHCTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void testMealyDHCGrid() {
6969
dhc.startLearning();
7070
MealyMachine<?, Character, ?, Integer> hypo = dhc.getHypothesisModel();
7171

72-
Assert.assertEquals(hypo.size(), (xsize * ysize), "Mismatch in size of learned hypothesis");
72+
Assert.assertEquals(hypo.size(), xsize * ysize, "Mismatch in size of learned hypothesis");
7373

7474
}
7575

algorithms/active/kearns-vazirani/src/main/java/de/learnlib/algorithm/kv/dfa/KearnsVaziraniDFA.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ public boolean refineHypothesis(DefaultQuery<I, Boolean> ceQuery) {
106106
return false;
107107
}
108108
if (repeatedCounterexampleEvaluation) {
109-
while (refineHypothesisSingle(input, output)) {}
109+
while (refineHypothesisSingle(input, output)) {
110+
// refine exhaustively
111+
}
110112
}
111113
return true;
112114
}
@@ -188,7 +190,7 @@ private void updateTransitions(List<Long> transList,
188190
long encodedTrans = transList.get(i);
189191

190192
int sourceState = (int) (encodedTrans >> Integer.SIZE);
191-
int transIdx = (int) (encodedTrans);
193+
int transIdx = (int) encodedTrans;
192194

193195
StateInfo<I, Boolean> sourceInfo = stateInfos.get(sourceState);
194196
I symbol = alphabet.getSymbol(transIdx);
@@ -202,7 +204,7 @@ private void updateTransitions(List<Long> transList,
202204
long encodedTrans = transList.get(i);
203205

204206
int sourceState = (int) (encodedTrans >> Integer.SIZE);
205-
int transIdx = (int) (encodedTrans);
207+
int transIdx = (int) encodedTrans;
206208

207209
setTransition(sourceState, transIdx, succs.get(i));
208210
}
@@ -309,8 +311,8 @@ public void addAlphabetSymbol(I symbol) {
309311

310312
// check if we already have information about the symbol (then the transition is defined) so we don't post
311313
// redundant queries
312-
if (this.hypothesis.getInitialState() != null &&
313-
this.hypothesis.getSuccessor(this.hypothesis.getInitialState(), symbol) == null) {
314+
final Integer init = this.hypothesis.getInitialState();
315+
if (init != null && this.hypothesis.getSuccessor(init, symbol) == null) {
314316
// use new list to prevent concurrent modification exception
315317
final List<Word<I>> transAs = new ArrayList<>(this.stateInfos.size());
316318
for (StateInfo<I, Boolean> si : this.stateInfos) {

0 commit comments

Comments
 (0)