-1

I am taking over a very old project with no documentation and I am trying to determine the right library to try and decompile and eventually recompile code with.

Looking around the internet I have seen two methods: Checking the manifest file and doing javap -v sample.class

When looking at the manifest inside the jar file I am seeing the following:

Manifest-Version: 1.0
Created-By: 1.4.2_09 (Sun Microsystems Inc.)

But when I do javap -v on the classes inside the jar file, it is showing major version 46 (java version 1.2)

As this is a old project with no documentation and no handover, any code changes done would have to be decompiled from the original jar and after modification recompiled using the same libraries and then updated into the jar. Therefore the right library is extremely important.

So the question is which version should I be looking at or is there a better way to achieve what I need?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

1

There is no relation at all.

One (Created-By in the manifest) is the Java version which was used to compile the classes, or it could be a complete fabrication, as it is not actually set by Java itself, but set by whatever build tool or manual process that created the JAR.

The other is the Java class version, meaning the target Java version which was used when compiling the classes, i.e. -target 1.2, or in modern versions of Java -release nn with nn the desired Java version for the classes.

That said, I don't see what this would have to do with "determin[ing] the right library". Also, trying to decompile code to make changes is fraught with problems, and something which you should really avoid if possible (e.g. by using the actual source code, if available).

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 1
    And if source code is not available ... you should consider throwing the project in the bin and starting again. If this code was developed for the Java 1.2 platform, its likely to be primitive ... and have all sorts of problems. And the fact that you have no source code will make it harder to fix them. – Stephen C Jul 31 '23 at 09:31
  • Finally ... you need to be aware that the source code you get by decompiling will be missing comments, names of local variables and stuff like that. And it may be inaccurate and / or uncompilable. I see difficulties, left, right and centrefield. – Stephen C Jul 31 '23 at 09:33
  • I would throw it away and start from scratch but its still in production and being used. rewriting it from scratch without even the business requirements is not a small job. Unfortunately im stuck between a rock and a hard place. – Zalthoria Jul 31 '23 at 11:23
  • @Zalthoria If that application is so important, why aren't there any sources? – Mark Rotteveel Jul 31 '23 at 11:25
  • I tried make a change recently and compiled the new class in 1.8 (which was verbally told to me what the project was compiled in before I checked) and I wasn't able to get the program to recognize the changes. A colleague of mine told me he had managed to done it the same way by compiling the change using the same library then replacing the affected class in the jar via the help of winrar – Zalthoria Jul 31 '23 at 11:27
  • @MarkRotteveel it was a combination of bad handover practices and a mass quitting – Zalthoria Jul 31 '23 at 11:28