Hi, question about decompiler : what are the conditions for a decompiler to decompile the original variable names, method names ? are those informations only available when the class is compiled with all debuging info (javac -g) ? and finally is there a difference between decompiling a class that was created using only the jdk, and a claas that was created with and EDI like JBuilder ?
From what I know (from my own experience with decompilers - i.e. losing the source code to an assignment and only having the jar file left the night before it's due) you'll probably won't find decompiler capable of this since the translation of human friendly source code to machine friendly byte-code generally strips this information. At a machine level, the os doesn't think of variables as acii names but rather as memory locations, etc. Sean
after some tests, here are my results if no code obfuscators is used, the name of instance variables, static variables, method can be obtained by decompilation of the byte-code. The only thing taht's lost is the local variable name(and so method parameters names as well) does everybody agree with this ?
Yes, that's correct, the compiler will not change your class, field, or method names. This is why obfuscators are important in Java. First, it shrinks the size. Effectively it's compression. If I can replace myReallyLongMethodName() with a(), I get a space savings. I have seen footprints decrease 50%, and the companies that make them claim up to 70%. Second, it makes it harder to reverse engineer. The method calclateTax(int amount, int rate) is pretty clear. The method a(int b, int c) is obscure. Imagine a file full of sinle letter variables and methods. It's pretty hard to figure out what's going on.
On a somewhat related note, the bytecode often contais other information, not necessary for the actual running of the program, such as debugger information. You can remove this to decrease your size. ALternatively, you can add to this. I know academic projetcs in which they tag the bytecode with additional information to get higher performence JITs and memory optimizations. (I have no idea of the legal implications of this, wrt to the JVM license. These are just academic projects.) --Mark firstname.lastname@example.org