Fork me on GitHub
Adam Helins11:01:37

It's been years since I've done some proper Java so I'm rusted... I'm trying to subclass using gen-class . The Parent has only private CTORs and exposes a public static create method. Using the subclassed Child, I can indeed do (Child/create ...). However, no matter what I do, I always get a Parent back, whereas I obviously want a Child. Any pointers? :thinking_face: 🙏

jumar12:01:51 to make a subclass of a class with only private constructors?

Adam Helins12:01:43

Ah, fair point. Do you know what would happen if the CTORs where public/protected? Since the return type of create , which delegates to the CTORs, is Parent

Adam Helins17:01:30

Yes so I hit a bottleneck I believe. It seems you can subclass but the static method is (I believe) attached to the Parent .


You cannot subclass something with only private constructors 🤷


since you need to call super()


and super needs to match to a constructor you have access to