Closed Trinsdar closed 2 years ago
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.
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.