Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decompiled java classes have some special characters

I decompiled some java classes and I get a source with special characters:

this.val$b.dispose();
this.val$domainLabel.setText((String)domains_config.get("description"));

what does this mean: this.val$b?

like image 414
developer Avatar asked Jan 17 '23 17:01

developer


1 Answers

According to the Java spec (see http://docs.oracle.com/javase/specs/jls/se5.0/html/lexical.html#3.8) $ is a valid value in an identifier. However, note that "The $ character should be used only in mechanically generated source code or, rarely, to access preexisting names on legacy systems."

There are two common reasons for seeing dollar signs in a variable name in decompiled code:

1. Your source code contains an inner class (perhaps, but not necessarily an anonymous one), in which case things for the inner class will have variable and constructor names like outerclass$innerclass. (See, for example http://docstore.mik.ua/orelly/java/exp/ch05_09.htm in the section on how inner classes really work). If the class is anonymous, the names will have a naming scheme/form like outerclass$ followed by outerclass$1 and so forth

2. The code has been run through an obfuscator. An obfuscator meets the criterion of "mechanically generating" the source code, so it can use dollar signs in the ame. An example would be RetroGuard, which explains in an FAQ on their website, the criterion for using $ in variable and class names. Essentially, the obfuscator uses the $ as a disambiguator and will rename classes or variables with generated names (typically single character letters used when possible to minimize code size), and what is renamed and what isn't depends on the variable's scope, etc.

In your particular example, val$b looks to me like it might be a variable name that has been obfuscated.

like image 173
Jessica Brown Avatar answered Jan 25 '23 22:01

Jessica Brown