Tuesday, 13 August 2013

Constructor must call super() or this() before return in method

Constructor must call super() or this() before return in method

I am getting this error:
Exception in thread "Thread-0" java.lang.VerifyError: Constructor must
call super() or this() before return in method
JGame.Util.KeyboardMap.<init>()V at offset 0
at JGame.Room.Room.keyboardEventTests(Room.java:81)
at JGame.Room.Room.run(Room.java:54)
at java.lang.Thread.run(Thread.java:722)
When my application loads, it calls this method right away
(KeyboardMap.map is an empty HashMap).
Here is the Method (Line 54 calls this method this.keyboardEventTests();):
protected void keyboardEventTests(){
for(Map.Entry ap : KeyboardMap.map.entrySet()){ // Line 81
Mapping mp = (Mapping)ap.getValue();
if(mp.doing){
mp.run();
}
}
}
And here is the KeyboardMap class.
package JGame.Util;
import java.util.HashMap;
import java.util.Map;
public class KeyboardMap{
public static Map<String, Mapping> map = new HashMap<>();
public static void set(String key, Boolean value, Runnable run){
Mapping mp = new Mapping();
mp.doing = value;
mp.run = run;
KeyboardMap.map.put(key, mp);
}
public static Mapping get(String key){
return KeyboardMap.map.get(key);
}
}
Why am I getting that error, and how can I get rid of it?

No comments:

Post a Comment