Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to inject super class and inject new constructors #11

Closed
Trinsdar opened this issue Jun 27, 2022 · 1 comment
Closed

Ability to inject super class and inject new constructors #11

Trinsdar opened this issue Jun 27, 2022 · 1 comment
Labels
wontfix This will not be worked on

Comments

@Trinsdar
Copy link

currently I have found mixins really lack in 2 areas: you can't make a class extend another class, and you can't add new constructors to a class. would also be preferable if those features could also do something like interface injection does, though that part should maybe be in a different lib.

@LlamaLad7 LlamaLad7 added the wontfix This will not be worked on label Jul 10, 2022
@LlamaLad7
Copy link
Owner

you can't make a class extend another class

This is by design. Not only would it not be a good idea compatibility-wise, but it would wreck things like super calls and fixing such calls would require a fairly expensive analysis and transformation step. There's almost never an absolute need to do this and whatever functionality it would allow can almost always be achieved some other way.

you can't add new constructors to a class

This is also by design. Constructors in java are a source-only construct. The bytecode contains only complete initiailizers, which in addition to the code from the corresponding constructor, contains all field initializers and initialization blocks. Extracting these duplicated elements to copy into your new constructor is a nigh-on impossible task, and if that did not happen, you'd have to initialize all the fields yourself, at which point you might as well just allocate an instance with Unsafe and do your stuff manually.

TL;DR: These are both incredibly tricky (and arguably not worth it) to do properly, and even if this functionality were to be implemented, it would be far better placed in Mixin itself, so I'm going to class this issue as out of scope.

@LlamaLad7 LlamaLad7 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants