I am currently writing a compiler for java. The JLS says “The class hierarchy must be acyclic.” but what about the case where:
B extends A
C extends A
D extends B
D extends C
This is an acyclic graph but invalid how can i detect this case? I am currently using a BFS and whenever i see a back-edge i know there is a cycle but the BFS algorithm doesn’t detect the case mentioned above.
Dinherits from more than one class and multiple inheritance is not allowed in Java. This is how you detect it.