-3

I was wondering what is meant with decompiling Java code. Does it mean that the native code is translated back to byte code and then to source code? I was also wondering which role the RAM plays when a java program is compiled. Do decompiling tools get the native code in RAM?

  • The java compiler ("`javac`") does not compile Java source code to binary code, but to bytecode. Bytecode is an intermediary representation (`.class`-files). The process of compilation does need some memory, but not too much. Decompilation is the reverse-transformation from bytecode to java source code. Depending on how the java code was compiled, the decompilation is more or less precise (e.g. variable names can be obfuscated). Some information, however, are lost permanently. For examle, the bytecode has no types for `boolean`, `char`, `byte` and `short`. They are all represented as `int`. – Turing85 Jan 04 '18 at 19:09
  • If you want to reverse-engineering some code, you should read a lot of books. Good luck with that. – zlakad Jan 04 '18 at 19:20
  • @Turing85 primitive types for all fields, parameters and return types are recorded, it's only local variables the decompile has to infer if it can (unless it's long. float or double) – Peter Lawrey Jan 04 '18 at 19:59

1 Answers1

1

Does it mean that the native code is translated back to byte code and then to source code?

Usually, decompiling means turning the byte code back into Java code.

The JVM does de-optimise native code back into byte code to avoid keeping two copies of the code in memory. However the JVM never turns it back into source code.

I was also wondering which role the RAM plays when a java program is compiled.

The Java compiler uses RAM like any other Java program. Nothing special happens when it is compiled in terms of RAM used.

Do decompiling tools get the native code in RAM?

No. Decompiling from byte code is simpler, faster and easier.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130