简体   繁体   中英

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

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM