This is how to read more books

Numbers 1 and 2 on that list know where they sit and are probably happy with how much they read (or don’t read). It’s that third number I’ll be writing about in this article, and sharing a simple…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to change everything in a Java class file

The design of Java paired with very powerful tools makes it very easy to change the behavior of every Java application without having the original source code.

Krakatau eruption 2008

I decided to write this guide because it can become extremely handy to have this skill.

A simple example is to completely eliminate one line of code in a class-file.
The possibilities are pretty much endless in regards of making small changes to the line of code or adding new code that has newer been there before.

Let’s eliminate line 81 in the Function.class of the sqlite-jdbc-3.9.1.jar.

Using -roundtrip creates an assembly file that can roundtrip to the original binary.

Not using -roundtrip creates a much more human readable assembly file.

Usually I make the change in the more readable file and then port the change back to the raw file.

The .linenumbertable makes it very easy to find out which lines of the assembly file match the line of code.

Line 81 starts at L48 in the assembly file and ends at L56.

I will replace the original instructions with instruction nop to tell the JVM to do nothing when reaching this line of code.

Creating the class-file from the assembly file.

Putting everything back together in the jar-file.

Checking with JD-GUI if the line of code is really gone.

Add a comment

Related posts:

A new journey

My name is Alexander, and I’m excited to share my journey with you here on Medium. I’m a software architect with almost a decade of experience designing and building complex systems for a variety of…

Born and Again

Poetic interpretation of John 17:17 - Sanctify them by your truth.