This is the question from compiler internals perspective.
I am interested in generics, not templates (C++), so I marked the question with C#. Not Java, because AFAIK the generics in both languages differ in implementations.
When I look at languages w/o generics it is pretty straightforward, you can validate the class definition, add it to hierarchy and that's it.
But what to do with generic class, and more importantly how handle references to it? How to make sure that static fields are singular per instantiations (i.e. each time generic parameters are resolved).
Let's say I see a call:
var x = new Foo<Bar>();
Do I add new
Foo_Bar class to hierarchy?
Update: So far I found only 2 relevant posts, however even they don't go into much details in sense "how to do it by yourself":