I am proud, This weekend I did some productive work. I was able to code Chip 8 emulator in Java over a night 😉 I have always been fascinated by them and finally I was able to get the damn thing to work! For those of you who are not familiar with software emulator, It is a software which can emulate the functionality of other hardware or software components. Notable examples are video game emulators(Dosbox/NES Emulator), general purpose software emulators(QEmu)
This time we will look at an extreme consequence of Java’s Type Erasure. This example shows what can happen to the semantics of Java language by Type Erasure without some compiler massage. Unlike other articles, It makes more sense to explain the behavior along side of the code. So I keep the abstract of the article simple. Below we have a class called Number<T> which has a protected field number of type T and with methods setNumber(T) and T getNumber(). Based on this class, I have created a new subclass called NumberString which extends from Number<String> and provides a method setNumber(String).
Read on →