Skip to content

Commit e2b6f50

Browse files
committed
Native code in Prism only loaded/initialised on demand.
Native shared libraries can be absent when using the explicit engine.
1 parent 17806bd commit e2b6f50

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

prism/src/prism/Prism.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,14 +1293,31 @@ public void initialise() throws PrismException
12931293
}
12941294
mainLog.print("Memory limits: cudd=" + getCUDDMaxMem());
12951295
mainLog.println(", java(heap)=" + PrismUtils.convertBytesToMemoryString(Runtime.getRuntime().maxMemory()));
1296+
}
12961297

1297-
// Add/initialise components/libraries
1298-
libraries.add(new JDDLibrary());
1299-
libraries.add(new PrismNativeLibrary());
1300-
for (PrismLibrary lib : libraries) {
1301-
lib.initialise(this);
1298+
/**
1299+
* Ensure that the native libraries are loaded and initialised,
1300+
* and that any relevant settings are passed to them.
1301+
*/
1302+
public void useNative() throws PrismException
1303+
{
1304+
// Add/initialise libraries for native code, if not already done
1305+
if (libraries.stream().noneMatch(JDDLibrary.class::isInstance)) {
1306+
addLibrary(new JDDLibrary());
1307+
}
1308+
if (libraries.stream().noneMatch(PrismNativeLibrary.class::isInstance)) {
1309+
addLibrary(new PrismNativeLibrary());
13021310
}
1303-
setMainLog(mainLog);
1311+
}
1312+
1313+
/**
1314+
* Initialise a freshy created {@link PrismLibrary} and add to the list of libraries.
1315+
*/
1316+
private void addLibrary(PrismLibrary lib) throws PrismException
1317+
{
1318+
lib.initialise(this);
1319+
lib.setMainLog(mainLog);
1320+
libraries.add(lib);
13041321
}
13051322

13061323
/**

prism/src/prism/PrismNativeComponent.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@ public PrismNativeComponent(Prism prism) throws PrismException
3838
{
3939
super(prism);
4040
this.prism = prism;
41+
// Make sure PRISM is set up to use native code.
42+
prism.useNative();
4143
}
4244
}

0 commit comments

Comments
 (0)