Generics problem when extending

I have a particle system class:

public class ParticleSystem<P extends Particle>{
    ...
}

I then try to extend this class with an internal ParticleImpl class:

public class BasicParticleSystem extends ParticleSystem<ParticleImpl>{ // <-- Error

    ...

    private class ParticleImpl extends Particle{
        ...
    }

}

However, the compiler complains that “ParticleImpl cannot be resolved to a type”. Eclipse proposes importing the class manually, but does not do anything when I choose that option.

EDIT:
I found a solution. Manually importing the inner class and changing the visibility makes it compile:

import blah.BasicParticleSystem.ParticleImpl;

public class BasicParticleSystem extends ParticleSystem<ParticleImpl>{

    ...

    class ParticleImpl extends Particle{

        ...

    }
}

It’s still weird as hell.

I think it’s an issue of inner classes typically being considered part of the outer class so its visibility is sort of wonky. So you have to explicitly make it visible so that the compiler can check whether it matches the Generic’s constraints.

Edit: I misunderstood the problem when I wrote my response. Changed it complety! xD

UprightPath is correct, it’s a visibility problem, if you want to skip the import statement you can use the inner class’s full name like so:


public class BasicParticleSystem extends ParticleSystem<BasicParticleSystem.ParticleImpl> {
	class ParticleImpl extends Particle {
	}
}