[Logo]
Forums Register Login
Decompiled Code different from Acutual Code
Hey People, I just joined the forum,
I'm learning Java from Head First Java. It told me to join the forum and I think that suggestion was very helpful.

I just wanted to know I made a small program in which i created 3 objects and defined their sizes. Then I made a method which they had to follow. But when i decompiled the class i got something different.

I made :



and when i decompiled i got :




I just wanted to ask why did and similar code to that change to ???

I just wanted to ask this for my knowledge.

Thanks.......

Unless you compile with the "g" flag (for debug info), the local variable names are not stored in the .class file. When Java decompiles, it doesn't know what the original names were and makes some up.
Thanks Jeanne, Now I understood it. Its like my reference variable has a different name but it refers to the correct objects.

Thanks
Note also that the Java compiler does some optimizations etc., and it's not always possible to get the exact same code back when you decompile a compiled class file. The decompiled source will ofcourse function the same way as the original source, but it's not always possible to get the exact statements that were in the original source code.

The transformation that the compiler does from source code to byte code is not completely reversible.
Thanks Jesper......now i understood whats the reason behind the jvm changing the source code......

And today was my first day at java ranch.....I just want to tell that

Java Ranch simply rocks
Do not set lab on fire. Or this tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature


This thread has been viewed 768 times.

All times above are in ranch (not your local) time.
The current ranch time is
Apr 27, 2018 02:58:04.