-1

I have a jar, which contains a line of code which compares two doubles, one having the value of 0.7, but I need to be able to change that to 0.0.

I cannot use reflection or anything like that because of the fact that this is a compiled jar file (not open source) but changing this value is crucial, because if it stays at 0.7 there is a huge lag problem.

I was thinking of editing bytecode, but cannot find any good software to do so.

I appreciate any help with this.

  • If the jar is not open source then you should ask to the makers and pay then to change according your specifications. – Jorge Campos Feb 17 '15 at 18:14
  • @JorgeCampos That is not possible as the maker is dead. –  Feb 17 '15 at 18:16
  • Are you sure there is nobody working on the project anymore? If so you should search for a replacement. – Clashsoft Feb 17 '15 at 19:42
  • @Clashsoft There is no replacement, and if there was then no one would still do it. –  Feb 19 '15 at 15:44

3 Answers3

1

Look into how to decompile the program Java classes, and then re-compile the software yourself.

How do I "decompile" Java class files?

From another similar question: (Change string constant in a compiled class)

If you have the sources for this class, then my approach is:

  • Get the JAR file
  • Get the source for the single class
  • Compile the source with the JAR on the classpath (that way, you don't have to compile anything else; it doesn't hurt that the JAR already contains the binary). You can use the latest Java version for this; just downgrade the compiler using -source and -target.
  • Replace the class file in the JAR with the new one using jar u or an Ant task
Community
  • 1
  • 1
Connorelsea
  • 2,308
  • 6
  • 26
  • 47
0

If you can decompile the class, you can make the change and recompile it. Then roll up the jarfile with your patched class. It depends on the class and the JDK used to compile it how easy this will be.

References: JAD (Wiki link because JAD is basically a dead project, though it continues to work when I need it to.) If you use Eclipse, you might have luck with JD-Eclipse. There is also the Procyon project, which I have had limited success with.

  • Sorry for the late response, but this is EXACTLY what I needed, I can't believe I never though of decompiling the single class I need, then using the compiled jar in the classpath, and then compiling the class then putting it back into the compiled jar, simply genious :) –  Mar 22 '15 at 21:36
0

Besides using (Hex) Editor or decompiler, use can use a byte code manipulation lib like asm. You actually might even be able to use an pre-load agent to transform the code on the fly.

eckes
  • 10,103
  • 1
  • 59
  • 71