if (! (reference instanceof Ivy)) { throw new BuildException("ivy internal problem: bad ivy instance class: "+reference.getClass()); } return (Ivy)reference;
return (Ivy)instances.get(Ivy.class);
    protected Ivy getIvyInstance() {        ensureMessageInitialised();        Object reference = getProject().getReference("ivy.instance");        if (reference == null) {            Message.verbose("no ivy instance found: auto configuring ivy");            IvyConfigure configure = new IvyConfigure();            configure.setProject(getProject());            configure.execute();            reference = getProject().getReference("ivy.instance");            if (reference == null) {                throw new BuildException("ivy internal problem: impossible to get ivy instance !");            }        }         if (! (reference instanceof Ivy)) {            throw new BuildException("ivy internal problem: bad ivy instance class: "+reference.getClass());        }        return (Ivy)reference;    }