Skip to content

Commit 2bc3a36

Browse files
committed
fixing a NPE bug in JavaProfile
solution by Alexander Weigl
1 parent 3bb4332 commit 2bc3a36

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/SimplifyTermStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public Strategy<Goal> create(Proof proof, StrategyProperties sp) {
117117
*/
118118
@Override
119119
public StrategySettingsDefinition getSettingsDefinition() {
120-
return JavaProfile.DEFAULT.getSettingsDefinition();
120+
return JavaProfile.getDefault().getSettingsDefinition();
121121
}
122122
}
123123
}

key.core/src/main/java/de/uka/ilkd/key/proof/init/JavaProfile.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,24 @@ public class JavaProfile extends AbstractProfile {
4848
public static JavaProfile defaultInstance;
4949
public static JavaProfile defaultInstancePermissions;
5050

51-
public static final StrategyFactory DEFAULT = new JavaCardDLStrategyFactory();
51+
/**
52+
* The default strategy factory to be used if no other strategy factory is
53+
* specified.
54+
*
55+
* Caution: This used to be constructed at class load time, but cyclic reference between
56+
* clauses made the field be read while the class was not yet fully initialized leading to
57+
* null pointer exceptions. So we now use lazy initialization.
58+
*
59+
* (solution suggested by AW)
60+
*/
61+
private static StrategyFactory DEFAULT;
62+
63+
public static StrategyFactory getDefault() {
64+
if (DEFAULT == null) {
65+
DEFAULT = new JavaCardDLStrategyFactory();
66+
}
67+
return DEFAULT;
68+
}
5269

5370
private boolean permissions = false;
5471

@@ -121,7 +138,7 @@ protected ImmutableList<TermLabelConfiguration> computeTermLabelConfiguration()
121138
@Override
122139
protected ImmutableSet<StrategyFactory> getStrategyFactories() {
123140
ImmutableSet<StrategyFactory> set = super.getStrategyFactories();
124-
set = set.add(DEFAULT);
141+
set = set.add(getDefault());
125142
return set;
126143
}
127144

key.ui/src/main/java/de/uka/ilkd/key/gui/StrategySelectionView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public final class StrategySelectionView extends JPanel implements TabPanel {
6363
/**
6464
* The always used {@link StrategyFactory}.
6565
*/
66-
private static final StrategyFactory FACTORY = JavaProfile.DEFAULT;
66+
private static final StrategyFactory FACTORY = JavaProfile.getDefault();
6767

6868
/**
6969
* The {@link StrategySettingsDefinition} of {@link #FACTORY} which defines the UI controls to

0 commit comments

Comments
 (0)