Search code examples
javaandroidjvmbufferedreaderreverse-engineering

Difference between decompiling and executing Java code


As the question states is there any main difference between the process of decompiling code and executing. I know that decompiling uses reflection, and at some point used buffered reader or some type of reader, as Oracle has documented the structure of class binary files. When executing code normally, does it also use reflection in both android and java too.

If this is the case then it should be the case that if a decompiler was unsuccessful then the code doesn't run either (as they follow the same procedure) ?

Unless when executing code it only get's the information about the method called and not the whole class ?

I also noticed that something that can't be compiled can still run normally and decompiled to if manually edited.

class A extends A {...} //will run without any problem if manually edited

EDIT1: Recently whilst trying something i got this result from the decompiled code but code failed to run as the code was like this

private static String voidFunction() {
    final int a = -1;
    final int b = a * -1;
    int c = (int)Math.pow(a, b);
    c *= new Random().nextInt(200);
    (new short[4])[0] = 48;
    true; // code on it's own
    -1; //missing return statement
}

Solution

  • Well I tried a simple test and was able to easily create an application which could not be decompiled with any decompiler because of the nature of how Java application works, but the application run's perfectly fine on all OS's. On the other hand If a hacker or analyzer knows the method I used can easily create a decompiler to crack even this application.

    So to answer my own question decompilers and running application takes different paths otherwise the application would never have run. I'm surprised their is nothing about this on the Internet.