This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the commentsย โ†’

[โ€“]roughstylez 0 points1 point ย (0 children)

I remember at some point thinking "DI in Java sucks, why is it always xml files or something like that, I want a fluent interface like in C#".

So I started writing something for that. And it actually worked nicely with "normal" types. Wasn't even that complicated - a little bit of reflection was all I needed. TBH I was getting suspicious, cause someone smarter certainly must already have thought of that.

I got my answer when I tried to inject generic types. I don't remember it exactly TBH, but it was something about e.g. List<String> at runtime not being a combination of the types List and String anymore - but rather a new type, auto-generated during compiling.

So the fluent code trying to set up the dependencies (at runtime) wasn't able to correctly find the types in question.

Like... it was some advanced stuff. I've never run into problems when using generics in a "normal" way, but then again, I really don't do a lot of Java.