Calling TheoryManager.retract() before first query causes NPE

Issue #17 new
Michael Lux created an issue

When executing the following test case, everything is fine:

TheoryManager tm = p.getTheoryManager();
Struct clause = new Struct("test", Struct.createTerm("hello"), Struct.createTerm("world"));
tm.assertZ(clause, true, null, true);
assertFalse(p.getTheory().toString().isEmpty());
assertEquals("hello", p.solve("test(X, world); X.").getVarValue("X").toString());
tm.retract(clause);
tm.clearRetractDB();
assertTrue(p.getTheory().toString().isEmpty());
assertFalse(p.solve("test(X, world); X.").isSuccess());

However, if I remove the p.solve(...), then I will get:

java.lang.NullPointerException
    at alice.tuprolog.TheoryManager.retract(TheoryManager.java:120)

I assume that EngineManager.getCurrentContext(); returns null because of some missing initialization of the ExecutionEngine...

Comments (1)

  1. Log in to comment