0

I've been given the task to make a small modification in a compiled .jar file. We don't have the source code for this anymore.

I downloaded JD-GUI and I managed to open the .jar file and see it's class files, but I'm afraid that some of the functions have only commented out lines with the //Byte Code header. It looks something like this:

private static List<BatchInfo> createBatchesFromCSVFile(BulkConnection connection, JobInfo jobInfo, String csvFileName)
throws IOException, AsyncApiException
{
    // Byte code:
    //   0: new 109 java/util/ArrayList
    //   3: dup
    //   4: invokespecial 111   java/util/ArrayList:<init>  ()V
    //   7: astore_3
    //   8: new 356 java/io/BufferedReader
    ......

If there are functions like this, will I be able to re-compile the file? I want to note, that I don't necessarily have to make my changes in the file that has these commented out lines. But this class is definitely used in the main class which I would have to rewrite.

PS: this is a data loader tool, and we actually need to change a field mapping that was hard coded previously...

Laureant
  • 979
  • 3
  • 18
  • 47
  • if you don't need to alter that code, don't even start with decompiling it. why don't you have the original code any more? – Stultuske Feb 27 '19 at 14:22
  • It looks to me like your decompiler is out of date. Try a more recent one. https://stackoverflow.com/questions/272535/how-do-i-decompile-java-class-files – markspace Feb 27 '19 at 14:29
  • _Small_ modification means most classes and methods can remain the same. Maybe ASM, a byte code manipulating library, may be better. – Joop Eggen Feb 27 '19 at 14:29
  • @markspace thanks, that helped. I actually decompiled it online with a lot better result. Still, the question remains: how can I recompile so it will act the same? BTW, I edited my question in order to reflect what this tool actually is, and why we can't edit the source. – Laureant Feb 27 '19 at 14:41
  • If you don't have to recompile a class file, it shouldn't matter that the class has funny byte codes in it. Concentrate on only the classes you need to change, the others should be fine. – markspace Feb 27 '19 at 14:53

0 Answers0