It is possible to recover the src from a deployed .WAR file?

1.1k Views Asked by At

I am working with a lot of legacy applications here. One of them (deployed in production) need to be edited because doesn't have any log.

I decompiled the it, but I have no idea about how to reassemble in this situation. I could not even recompile de single classes edited because of the compiler optimization.

(I am using Java 6)

Sorry if my english is bad, I am just a junior

2

There are 2 best solutions below

0
harperska On

No. A WAR file is just a specialized JAR file that contains, in addition to the compiled bytecode, JSP files, static HTML files, and a descriptor file that tells the webserver how to deploy the app. What it does not contain is the original source code. This means your only options are working with the decompiled code, or asking the original developers for the source code.

0
Antimony On

As you have discovered, compilation and decompilation are lossy processes, so you cannot in general recompile decompiled code, and even if it does compile, it may not be identical to the original binary.

One alternative is to use Krakatau disassembler and assembler. Krakatau can roundtrip Java bytecode to a human readable text format, which makes it easy to edit bytecode losslessly. The main downside is that you have to have a good understanding of Java bytecode to understand the disassembly and it is a lot harder to read or edit than Java source code.