• love2read 7 days ago

    For an example of how this is used when setup: https://wiki.fabricmc.net/tutorial:mixin_examples

    • Dylan16807 7 days ago

      > ASM is an all purpose Java bytecode manipulation and analysis framework.

      Oh. I was expecting something much more weird from the title, and that's a pretty confusing/misleading name for that.

      • sigy 7 days ago

        I was curious about this as perhaps a new approach to recipe-oriented bytecode injection. But the I looked at the project's (long) history and docs status. It seems that the main contributor has tapered off this project over time, and more specifically hasn't been active since July. (Mumfrey, if you're out there, please tell us what's up)

        So, OP, what made you mention this here now?

        • gabizou 6 days ago

          I would say that the feature set is pretty powerful as is, and it shows in the earlier history (having worked with Mixins since before it was called Mixins). The history reaches further back than the first commit to having been developed for Mumfrey's own modloader (LiteLoader).

          As someone else already replied, Mumfrey still practices private development and only pushes new code after his own extensive testing. He has long periods of "public" inactivity because code refactors and other changes can be delicate given the widespread usage of the library within the Minecraft modding ecosystem, and as such, he doesn't want the distraction that in-development can attract from said community.

          • Starlevel004 7 days ago

            There's a maintained fork here: https://github.com/FabricMC/Mixin

            • asiekierka 7 days ago

              IIRC, at least a few years ago, Mumfrey had a tendency to develop Mixin in private and only push the commit backlog for releases, leading to periods of time where no activity was publicly visible. (Also IIRC, this is part of the reason why the FabricMC fork exists.)

            • saagarjha 7 days ago

              I kind of wish Java just went full Objective-C and provided native APIs to patch and redirect methods. Having everyone ship a bytecode manipulation library just to mock a method or two is quite annoying given how easy it would be for the runtime to offer this directly (and probably more performantly).

              • gabizou 6 days ago

                The applications for Mixin wasn't to mock a method or two, it's to enable full-scale modification of an existing Java application at runtime without recompiling/redistributing the original application. In the case of its origins, modifying Minecraft server to add a non-obfuscated API and implement said API on top of it through Mixins. The way this is achieved is practically at the class load point in time so the runtime costs are reduced to maybe a couple of seconds (as of current writing, Sponge has somewhere around 1.2k mixins overall). Could there be a better native API? I'm hoping so, Java's Class File API (JEP-484) is a pretty good start, but I don't think it's quite enough yet to enable the full functionality of what Mixin does.

                [1]:https://openjdk.org/jeps/484

                • oftenwrong 7 days ago

                  Not sure if this fits, but JDK 24 includes a new API, java.lang.classfile, for classfile manipulation.

                  https://openjdk.org/jeps/484

                  • _old_dude_ 7 days ago

                    Is their a design document, somewhere about this new library ?

                    The jep does not explain how to prepare to new Java bytecodes and future enhancements. Am i suppose to only run with the latest version of Java if i want to use that library ?

                • ddimitrov 7 days ago

                  What is the advantage compared to established AOP libraries, such as AspectJ or BytecodeBuddy?

                • fnord77 7 days ago

                  Isn't composition is superior to mixins for a few reasons, particularly the "Single-responsibility principle" ?

                  • twic 7 days ago

                    The purpose of this library is to make it easier to modify existing code, eg to make existing classes implement new interfaces. In particular, it seems to be used for Minecraft modding.

                    • LelouBil 7 days ago

                      Yes, Minecraft gets more and more data-driven, but for adding completely new features like, a solar system with planets, or turning the player into a robot of something, you'll have to edit some of the built in code.

                      This Mixin library is very useful, since it allows different mods to edit different parts of the same code without interfering for example.

                      It's also very easy to use compared to jvm bytecode manipulation, you just write a normal java function and put an annotation on it, and boom, now it runs right before line X inside of class Y, at runtime !

                    • mudkipdev 7 days ago

                      You're referring to mixins in programming (https://en.wikipedia.org/wiki/Mixin) which isn't related to this library

                      • based2 7 days ago
                      • based2 7 days ago

                        ? alt: Java 23 - Class-File API (Second Preview)

                        https://news.ycombinator.com/item?id=41567720

                        • anonymoushn 7 days ago

                          ah yes ASM, the bytecode manipulator for java. Please look forward to JAVA, my upcoming tool for manipulating assembly code.