lundi 21 septembre 2015

Call non-abstract method of abstract class without its instance

Consider this code:

public interface IRegistryClass
{
    public IRegistryClass get();
}

public abstract class Skill implements IRegistryClass
{
    @Override
    public Skill get()
    {
        return new SkillFake();
    }

    private final class SkillFake extends Skill
    {}
}

Would it be possible to call skill#get() when being ONLY supplied with Skill.class?

Regular Java won't allow to class#newInstance() abstract classes. Question is: Is there a way?

Note: I can't have static keyword. I need inheritance on this one.





Aucun commentaire:

Enregistrer un commentaire