login about faq

To prove you're not a spammer, email newuser.lgqa@gmail.com with the subject "Account Request" to request an account.

Basically I'm starting to play around with java and I learned about how source code is compiled into object code when it's compiled. So I began to wonder if source code can be compiled into object code can object code be translated into source code? If not, why not?

asked Sep 07 '10 at 19:24

FilipinoPower's gravatar image


Yup, this is called decompiling - it can be performed on MSIL (Microsoft Intermediate Language, the language C#, VB.Net etc compile into). In theory it should be quite easy to "decompile" java "bytecode" (the object code) back into source code, however it's a practice that is often frowned upon. Also, the source code will not necessarily be 100% the code you entered - it may have been optimised and things may have been renamed - e.g.:


int myCounter = 0;
PersonClass person = new PersonClass("Steve");

could end up as something like:

int __a = 0;
__classA __b = new __classA("Steve");

Hope this sort of helps!

  • Javawag

answered Sep 08 '10 at 12:37

javawag's gravatar image


Thanks but what stops people from coping your algorithms then?

(Sep 08 '10 at 19:55) FilipinoPower FilipinoPower's gravatar image

This is one issue that faces developers. Not using languages that are stored in bytecode format (i.e. Java, C#, VB.NET) can mean it's harder to reverse engineer, but still not impossible. The best way is to look into "Obfuscation" - have a look on Wikipedia. It basically takes your code, juggles some bits around, and then compiles it - this way the code is hard to read even if it is reverse engineered. However, as trueb said below - this can make the code inefficient.

  • Javawag
(Sep 09 '10 at 14:47) javawag javawag's gravatar image

yes it can: but because when you write code in a high level language there are many ways the compiler can translate it to assembly. when you go though a disassembler or de-compiler (IDA is popular) it can also take that code and translate it to many ways in your high level language.

what im getting at is that when you go from high level to low level and back to high level, the code does not like anything like the code you started with, and because comments are not compiled to the object, it is very hard to reverse engineer.

point being yes it can be done, but not everyone can do it, and understand it.

there are supposedly tricks to do to make it harder to do this, but they often times make the code inefficient.

answered Sep 08 '10 at 20:17

trueb's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Sep 07 '10 at 19:24

Seen: 2,131 times

Last updated: Sep 09 '10 at 14:47