You can try your tests with a little bit of private API:
optw = model.optimizer.get_weights()
model.compile(optimizer="Adam", loss='mean_squared_error')     # re-compile
print('re-compile')
model.optimizer._create_all_weights(model.trainable_variables)
model.optimizer.set_weights(optw)