SPY-Lab / java-fsm-library

GNU Lesser General Public License v3.0
1 stars 1 forks source link

Bug in reverse function #16

Closed Lamericio closed 7 years ago

Lamericio commented 7 years ago

While i was testing #9 , I noticed that the library crashed on reverse() method call. Both my concat() methods, operating respectively on a collection and on two input automatas, returned the correct object, but when I tried to equal() the result, I got a NullPointerException on reverse() method.

Exception in thread "main" java.lang.NullPointerException at it.univr.fsm.machine.Automaton.reverse(Automaton.java:1089) at it.univr.fsm.machine.Automaton.minimize(Automaton.java:1048) at it.univr.fsm.machine.Automaton.intersection(Automaton.java:358) at it.univr.fsm.machine.Automaton.equals(Automaton.java:1628) at it.univr.fsm.main.Main.main(Main.java:56)

VincenzoArceri commented 7 years ago

The problem was in concat(Automaton first, Automaton second) when you add the initial state of the first automaton:

mappingFirst.put(firstInitialStates, new State("q" + c++, true, false)); newStates.add(firstInitialStates);

You have to add the map associated to firstInitialState, not firstInitalState. The right code is

mappingFirst.put(firstInitialStates, new State("q" + c++, true, false)); newStates.add(mappingFirst.get(firstInitialStates));

I'm going to commit the fix and then I will close the issue.