Skip to content

Instantly share code, notes, and snippets.

@agarciadom
Created March 21, 2013 19:48
Show Gist options
  • Select an option

  • Save agarciadom/5216113 to your computer and use it in GitHub Desktop.

Select an option

Save agarciadom/5216113 to your computer and use it in GitHub Desktop.
Small experiment for finding out the definition of the PCI mutation operator. I don't really see how downcasting in Java will change the behaviour in most cases: non-static methods are resolved using the actual type instead of the declared type, after all.
class Parent {
@Override
public String toString() {
return "Parent";
}
}
class Child extends Parent {
@Override
public String toString() {
return "Child";
}
}
public class PCIMutationTest {
public static void main(String[] args) {
Child c = new Child();
Parent p = c;
System.out.println(p.toString());
System.out.println(c.toString());
System.out.println(((Child)p).toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment