When Java (or any language capable of reflection) outputs a program, does it keep the names of the methods as strings within the bytecode?
I’m wondering how, for example, the following is possible without this being the case:
Class c = Class.forName("foo");
Method m[] = c.getDeclaredMethods();
Will the bytecode then contain Strings of each method field and name within the class? I’m wondering because I want to make sure all parts of my code are not easily read, without having to obfuscate everything. If there is something fundamentally wrong with my understanding of reflection, please let me know.
First, Method, fields and class names are stored as clear text in .class file.
Second, additionally to reflection there are java decompilers that can restore the almost-readable code from byte code.
Third if you want to protect your code use obfuscation. There are several popular java obfuscatotors available.