2018-04-07

GitHub project: mikenakis-bytecode

A lightweight framework for manipulating JVM bytecode.



The mikenakis-bytecode Logo, an old-fashioned coffee grinder.
by Mike Nakis, based on original work by Gregory Sujkowski from the Noun Project.
Used under CC BY License.



What is the license of mikenakis-bytecode?


This creative work is explicitly published under No License. This means that I remain the exclusive copyright holder of this creative work, and you may not do anything with it other than view its source code and admire it. More information here: michael.gr - Open Source but No License.

If you would like to do anything more with this creative work, please contact me.

What are the benefits of mikenakis-bytecode over javassist, ASM, and the like?


There are no benefits other than that the interface seems more simple, elegant and intuitive to me; of course, my opinion is biased, because I wrote it. So, let's just say that `mikenakis-bytecode` exists simply because I wanted to write it. For fun. That's how I roll.

What does mikenakis-bytecode have to offer?


`mikenakis-bytecode` was built with a simple philosophy: the framework should contain the bare minimum of features that are necessary in order to manipulate bytecode in an easy and error-free way, and these features should be simple, intuitive, and elegant, so that if you already know JVM bytecode and you just want a framework to work with it, all features of the framework should be self-explanatory so that you do not have learn the framework before you can begin using it.

For example, `mikenakis-bytecode` enables you to work with the contents of an individual class-file, but it is not concerned with relationships between class files. So, types referenced by the type being examined (like supertype, implemented interfaces, etc.) are simply identified by strings containing fully qualified type names. The framework does not offer any kind of abstraction for groups or hierarchies of classes, because that would have greatly increased not only the complexity of the implementation of the framework, but also the complexity of its interface: there would be a lot that you would have to learn before you could start using it.

As another example, `mikenakis-bytecode` facilitates easy generation of valid class files by completely shielding the programmer from having to deal with bytecode offsets. To achieve this, mikenakis-bytecode makes exclusive use of instruction references instead. This means that you can simply code a jump to a certain instruction, and `mikenakis-bytecode` will determine whether a 'short' or a 'long' form of a jump instruction should be used, and if necessary it will replace a short conditional jump with an inverted conditional short jump around an unconditional long jump.

Similarly, when it comes to coding stack frames, `mikenakis-bytecode` will not automatically generate stack frame entries for you, (because that's quite difficult,) but it will allow you to specify stack frames that simply reference target instructions, and it will pick the right subtype based on how long the actual offset to the target instruction turns out to be.

How does working with mikenakis-bytecode look like?


If you want to get an idea of how it looks like to be working with mikenakis-bytecode, you can see how it is used in these projects:
  1. For dumping the contents of class files in my mikenakis-classdump project
    (https://github.com/mikenakis/mikenakis-classdump)
  2. For dependency analysis in my mikenakis-testana project
    (https://github.com/mikenakis/mikenakis-testana)
  3. For simple bytecode manipulation in my mikenakis-rumination project
    (https://github.com/mikenakis/mikenakis-rumination),

2 comments:

  1. Second the replies above, some more background info is required here. But as I may suggest, you're practicing to combine both Java and Blender for the first time, huh? If so, I got you, because I try the same thing, but it's still unclear to me at some level. Things come easy to me as we speak of Blender, but Java is quite new thing to me. Like, errrr, new-new, I've started just 2 months ago with it. Despite the term is short, I may suggest you to find the solution at least for function's import with this resource to learn java https://explainjava.com/install-update-remove-java/ Maybe, you won't need to browse the whole resource from scratch, but nevertheless it will come in use in order to keep some basic things in mind, to not to forget anything. But we should know what the thing you're exactly doing in order to give some more comprehensive solutions

    ReplyDelete