String calleeSuper = "ctors.CalleeSuperB";
TypeRegistry r = getTypeRegistry(caller + "," + callee + "," + calleeSuper);
ReloadableType rcaller = r.addType(caller, loadBytesForClass(caller));
ReloadableType rcalleeSuper = r.addType(calleeSuper, loadBytesForClass(calleeSuper));
ReloadableType rcallee = r.addType(callee, loadBytesForClass(callee));
Result res = null;
// Use the code 'untouched'
Object callerInstance = rcaller.getClazz().newInstance();
res = runOnInstance(rcaller.getClazz(), callerInstance, "runA");
assertEquals("callee", res.returnValue.toString());
// Reload the code, a new constructor in the callee and runB() invokes it
rcalleeSuper.loadNewVersion("002", retrieveRename(calleeSuper, calleeSuper + "2"));
rcaller.loadNewVersion("002", retrieveRename(caller, caller + "2", "ctors.CalleeB2:ctors.CalleeB"));
rcallee.loadNewVersion("002", retrieveRename(callee, callee + "2", "ctors.CalleeSuperB2:ctors.CalleeSuperB"));
// The new runB() method will include a call 'new Callee("abcde")'
// Without a rewrite, it will cause this problem:
// Caused by: java.lang.NoSuchMethodError: ctors.Callee.<init>(Ljava/lang/String;)V
// at ctors.Caller__E002.runB(Caller2.java:10)
// This new Callee constructor also invokes a constructor in the supertype that wasn't there initially
res = runOnInstance(rcaller.getClazz(), callerInstance, "runB");
assertEquals("callee", res.returnValue.toString());
assertContains("Super number was 32768", res.toString());
assertContains("abcde", res.toString());
}