java

Adam Helins 2023-01-06T11:50:37.839819Z

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? 🤔 🙏

jumar 2023-01-06T12:21:51.801279Z

https://stackoverflow.com/a/3952820/1184752 to make a subclass of a class with only private constructors?

Adam Helins 2023-01-06T12:56:43.331659Z

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 Helins 2023-01-06T17:07:30.838869Z

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

emccue 2023-01-08T00:52:06.906879Z

You cannot subclass something with only private constructors 🤷

emccue 2023-01-08T00:52:16.711229Z

since you need to call super()

emccue 2023-01-08T00:52:30.473169Z

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