Skip to content

Commit e66f87e

Browse files
committed
Removal of the write and read settings using Properties
1 parent c0eca77 commit e66f87e

35 files changed

Lines changed: 534 additions & 922 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

key.core.testgen/src/main/java/de/uka/ilkd/key/settings/TestGenerationSettings.java

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
package de.uka.ilkd.key.settings;
55

66
import java.io.File;
7-
import java.util.Properties;
87

98
import org.jspecify.annotations.NonNull;
9+
import org.jspecify.annotations.NullMarked;
1010
import org.jspecify.annotations.Nullable;
1111

12+
@NullMarked
1213
public class TestGenerationSettings extends AbstractSettings {
1314
// region Default Values for option fields
1415
private static final boolean DEFAULT_APPLYSYMBOLICEX = false;
@@ -85,14 +86,14 @@ public TestGenerationSettings(TestGenerationSettings data) {
8586
}
8687

8788
/**
88-
* @deprecated weigl: This method seems broken. I would expect: clone() = new TGS(this)
89+
* @deprecated weigl: This method seems broken. I would expect: copy() = new TGS(this)
8990
*/
9091
@Deprecated(forRemoval = true)
91-
public TestGenerationSettings clone(TestGenerationSettings data) {
92+
public TestGenerationSettings copy(TestGenerationSettings data) {
9293
return new TestGenerationSettings(data);
9394
}
9495

95-
public TestGenerationSettings clone() {
96+
public TestGenerationSettings copy() {
9697
return new TestGenerationSettings(this);
9798
}
9899

@@ -126,28 +127,6 @@ public boolean includePostCondition() {
126127
return includePostCondition;
127128
}
128129

129-
@Override
130-
public void readSettings(Properties props) {
131-
var prefix = "[" + CATEGORY + "]";
132-
setApplySymbolicExecution(SettingsConverter.read(props,
133-
prefix + PROP_APPLY_SYMBOLIC_EXECUTION, DEFAULT_APPLYSYMBOLICEX));
134-
setMaxUnwinds(SettingsConverter.read(props, prefix + PROP_MAX_UWINDS, DEFAULT_MAXUNWINDS));
135-
setOutputPath(SettingsConverter.read(props, prefix + PROP_OUTPUT_PATH, DEFAULT_OUTPUTPATH));
136-
setRemoveDuplicates(SettingsConverter.read(props,
137-
prefix + PROP_REMOVE_DUPLICATES, DEFAULT_REMOVEDUPLICATES));
138-
setRFL(SettingsConverter.read(props, prefix + PROP_USE_RFL, DEFAULT_USERFL));
139-
setUseJunit(SettingsConverter.read(props, prefix + PROP_USE_JUNIT, DEFAULT_USEJUNIT));
140-
setConcurrentProcesses(SettingsConverter.read(props,
141-
prefix + PROP_CONCURRENT_PROCESSES, DEFAULT_CONCURRENTPROCESSES));
142-
setInvariantForAll(SettingsConverter.read(props,
143-
prefix + PROP_INVARIANT_FOR_ALL, DEFAULT_INVARIANTFORALL));
144-
setOpenjmlPath(
145-
SettingsConverter.read(props, prefix + PROP_OPENJML_PATH, DEFAULT_OPENJMLPATH));
146-
setObjenesisPath(SettingsConverter.read(props, PROP_OBJENESIS_PATH, DEFAULT_OBJENESISPATH));
147-
setIncludePostCondition(SettingsConverter.read(props,
148-
PROP_INCLUDE_POST_CONDITION, DEFAULT_INCLUDEPOSTCONDITION));
149-
}
150-
151130
public boolean removeDuplicates() {
152131
return removeDuplicates;
153132
}
@@ -234,24 +213,6 @@ public boolean useJunit() {
234213
return useJunit;
235214
}
236215

237-
238-
@Override
239-
public void writeSettings(Properties props) {
240-
var prefix = "[" + CATEGORY + "]";
241-
SettingsConverter.store(props, prefix + PROP_APPLY_SYMBOLIC_EXECUTION,
242-
applySymbolicExecution);
243-
SettingsConverter.store(props, prefix + PROP_CONCURRENT_PROCESSES, concurrentProcesses);
244-
SettingsConverter.store(props, prefix + PROP_INVARIANT_FOR_ALL, invariantForAll);
245-
SettingsConverter.store(props, prefix + PROP_MAX_UWINDS, maxUnwinds);
246-
SettingsConverter.store(props, prefix + PROP_OUTPUT_PATH, outputPath);
247-
SettingsConverter.store(props, prefix + PROP_REMOVE_DUPLICATES, removeDuplicates);
248-
SettingsConverter.store(props, prefix + PROP_USE_RFL, useRFL);
249-
SettingsConverter.store(props, prefix + PROP_USE_JUNIT, useJunit);
250-
SettingsConverter.store(props, prefix + PROP_OPENJML_PATH, openjmlPath);
251-
SettingsConverter.store(props, prefix + PROP_OBJENESIS_PATH, objenesisPath);
252-
SettingsConverter.store(props, prefix + PROP_INCLUDE_POST_CONDITION, includePostCondition);
253-
}
254-
255216
@Override
256217
public void readSettings(Configuration props) {
257218
var cat = props.getSection(CATEGORY);
@@ -290,7 +251,7 @@ public void writeSettings(Configuration props) {
290251
}
291252

292253
public void set(TestGenerationSettings settings) {
293-
Properties p = new Properties();
254+
Configuration p = new Configuration();
294255
settings.writeSettings(p);
295256
readSettings(p);
296257
}

key.core.testgen/src/main/java/de/uka/ilkd/key/smt/testgen/AbstractTestGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ public void generateTestCases(final StopRequest stopRequest, final TestGeneratio
154154

155155
// create special smt settings for test case generation
156156
final ProofIndependentSMTSettings piSettings =
157-
ProofIndependentSettings.DEFAULT_INSTANCE.getSMTSettings().clone();
157+
ProofIndependentSettings.DEFAULT_INSTANCE.getSMTSettings().copy();
158158
piSettings.setMaxConcurrentProcesses(settings.getNumberOfProcesses());
159-
final ProofDependentSMTSettings pdSettings = proof.getSettings().getSMTSettings().clone();
159+
final ProofDependentSMTSettings pdSettings = proof.getSettings().getSMTSettings().copy();
160160
final NewSMTTranslationSettings newSettings =
161161
new NewSMTTranslationSettings(proof.getSettings().getNewSMTSettings());
162162
pdSettings.setInvariantForall(settings.invariantForAll());

key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/ModelGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void launch() {
7979
private SolverLauncher prepareLauncher() {
8080
final TestGenerationSettings settings = TestGenerationSettings.getInstance();
8181
final ProofIndependentSMTSettings piSettings =
82-
ProofIndependentSettings.DEFAULT_INSTANCE.getSMTSettings().clone();
82+
ProofIndependentSettings.DEFAULT_INSTANCE.getSMTSettings().copy();
8383

8484

8585
piSettings.setMaxConcurrentProcesses(settings.getNumberOfProcesses());

key.core/src/main/java/de/uka/ilkd/key/nparser/KeyAst.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ public static class File extends KeyAst<KeYParser.FileContext> {
7474
ProofSettings settings = new ProofSettings(ProofSettings.DEFAULT_SETTINGS);
7575

7676
if (ctx.preferences() != null && ctx.preferences().s != null) {
77-
String text = StringUtil.trim(ctx.preferences().s.getText(), '"')
78-
.replace("\\\\:", ":");
79-
settings.loadSettingsFromPropertyString(text);
77+
throw new IllegalStateException("You try to load a KeY file in an deprecated format. " +
78+
"The settings are not a string of properties anymore. Please rewrite to the JSON-like format.");
8079
} else if (ctx.preferences() != null && ctx.preferences().c != null) {
8180
var cb = new ConfigurationBuilder();
8281
var c = (Configuration) ctx.preferences().c.accept(cb);

key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,18 @@ public class Proof implements Named {
115115
* settings valid independent of a proof
116116
*/
117117
private final ProofIndependentSettings pis;
118+
118119
/**
119120
* when different users load and save a proof this vector fills up with Strings containing the
120121
* usernames.
121122
*/
122-
public List<String> userLog;
123+
public List<String> userLog = new ArrayList<>();
123124

124125
/**
125126
* when load and save a proof with different versions of key this vector fills up with Strings
126127
* containing the GIT versions.
127128
*/
128-
public List<String> keyVersionLog;
129+
public List<String> keyVersionLog = new ArrayList<>();
129130

130131
private long autoModeTime = 0;
131132

@@ -167,8 +168,7 @@ public class Proof implements Named {
167168
*/
168169
private Proof(Name name, InitConfig initConfig) {
169170
this.name = name;
170-
assert initConfig != null : "Tried to create proof without valid services.";
171-
this.initConfig = initConfig;
171+
this.initConfig = Objects.requireNonNull(initConfig, "Tried to create proof without valid services.");
172172

173173
if (initConfig.getSettings() == null) {
174174
// if no settings have been assigned yet, take default settings

key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediatePresentationProofFileParser.java

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
* SPDX-License-Identifier: GPL-2.0-only */
44
package de.uka.ilkd.key.proof.io;
55

6-
import java.util.ArrayDeque;
7-
import java.util.ArrayList;
8-
import java.util.LinkedList;
9-
import java.util.List;
10-
116
import de.uka.ilkd.key.axiom_abstraction.predicateabstraction.AbstractPredicateAbstractionLattice;
127
import de.uka.ilkd.key.logic.PosInTerm;
138
import de.uka.ilkd.key.proof.Proof;
149
import de.uka.ilkd.key.proof.io.intermediate.*;
1510
import de.uka.ilkd.key.settings.ProofSettings;
16-
1711
import org.key_project.logic.Name;
1812
import org.key_project.util.collection.ImmutableList;
1913
import org.key_project.util.collection.ImmutableSLList;
2014
import org.key_project.util.collection.Pair;
2115

16+
import java.io.IOException;
17+
import java.io.StringReader;
18+
import java.util.ArrayDeque;
19+
import java.util.LinkedList;
20+
import java.util.List;
21+
2222
/**
2323
* Parses a KeY proof file into an intermediate representation. The parsed intermediate result can
2424
* be processed by {@link IntermediateProofReplayer}. This approach is more flexible than direct
@@ -143,26 +143,16 @@ public void beginExpr(ProofElementID eid, String str) {
143143
TacletInformation tacletInfo = (TacletInformation) ruleInfo;
144144
tacletInfo.ifDirectFormulaList = tacletInfo.ifDirectFormulaList.append(str);
145145
}
146-
case KeY_USER -> { // UserLog
147-
if (proof.userLog == null) {
148-
proof.userLog = new ArrayList<>();
149-
}
150-
proof.userLog.add(str);
151-
}
152-
case KeY_VERSION -> { // Version log
153-
if (proof.keyVersionLog == null) {
154-
proof.keyVersionLog = new ArrayList<>();
155-
}
156-
proof.keyVersionLog.add(str);
157-
}
146+
case KeY_USER -> // UserLog
147+
proof.userLog.add(str);
148+
case KeY_VERSION -> // Version log
149+
proof.keyVersionLog.add(str);
158150
case KeY_SETTINGS -> // ProofSettings
159151
loadPreferences(str);
160152
case BUILT_IN_RULE -> { // BuiltIn rules
161-
{
162-
final AppNodeIntermediate newNode = new AppNodeIntermediate();
163-
currNode.addChild(newNode);
164-
currNode = newNode;
165-
}
153+
final AppNodeIntermediate newNode = new AppNodeIntermediate();
154+
currNode.addChild(newNode);
155+
currNode = newNode;
166156
ruleInfo = new BuiltinRuleInformation(str);
167157
}
168158
case CONTRACT -> ((BuiltinRuleInformation) ruleInfo).currContract = str;
@@ -329,7 +319,11 @@ private BuiltInAppIntermediate constructBuiltInApp() {
329319
*/
330320
private void loadPreferences(String preferences) {
331321
final ProofSettings proofSettings = new ProofSettings(ProofSettings.DEFAULT_SETTINGS);
332-
proofSettings.loadSettingsFromPropertyString(preferences);
322+
try {
323+
proofSettings.loadSettingsFromJSONStream(new StringReader(preferences));
324+
} catch (IOException e) {
325+
throw new RuntimeException(e); // no I/O exception on strings.
326+
}
333327
}
334328

335329
/**

0 commit comments

Comments
 (0)