PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/external/proguard/docs/FAQ.html

https://gitlab.com/brian0218/rk3188_r-box_android4.2.2_sdk
HTML | 254 lines | 213 code | 41 blank | 0 comment | 0 complexity | b0369c00eeb78e8635022e0968b7562b MD5 | raw file
  1. <!doctype html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
  5. <meta http-equiv="content-style-type" content="text/css">
  6. <link rel="stylesheet" type="text/css" href="style.css">
  7. <title>ProGuard FAQ</title>
  8. </head>
  9. <body>
  10. <h2>Frequently Asked Questions</h2>
  11. <h3>Contents</h3>
  12. <ol>
  13. <li><a href="#shrinking">What is shrinking?</a>
  14. <li><a href="#obfuscation">What is obfuscation?</a>
  15. <li><a href="#preverification">What is preverification?</a>
  16. <li><a href="#optimization">What kind of optimizations does <b>ProGuard</b>
  17. support?</a>
  18. <li><a href="#commercial">Can I use <b>ProGuard</b> to process my commercial
  19. application?</a>
  20. <li><a href="#jdk1.4">Does <b>ProGuard</b> work with Java 2? Java 5? Java
  21. 6?</a>
  22. <li><a href="#jme">Does <b>ProGuard</b> work with Java Micro Edition?</a>
  23. <li><a href="#android">Does <b>ProGuard</b> work for Google Android code?</a>
  24. <li><a href="#blackberry">Does <b>ProGuard</b> work for Blackberry code?</a>
  25. <li><a href="#ant">Does <b>ProGuard</b> have support for Ant?</a>
  26. <li><a href="#gui">Does <b>ProGuard</b> come with a GUI?</a>
  27. <li><a href="#forname">Does <b>ProGuard</b> handle <code>Class.forName</code>
  28. calls?</a>
  29. <li><a href="#resource">Does <b>ProGuard</b> handle resource files?</a>
  30. <li><a href="#encrypt">Does <b>ProGuard</b> encrypt strings constants?</a>
  31. <li><a href="#flow">Does <b>ProGuard</b> perform control flow obfuscation?</a>
  32. <li><a href="#incremental">Does <b>ProGuard</b> support incremental
  33. obfuscation?</a>
  34. <li><a href="#keywords">Can <b>ProGuard</b> obfuscate using reserved
  35. keywords?</a>
  36. <li><a href="#stacktrace">Can <b>ProGuard</b> reconstruct obfuscated stack
  37. traces?</a>
  38. </ol>
  39. <a name="shrinking">&nbsp;</a>
  40. <h3>What is shrinking?</h3>
  41. Java source code (.java files) is typically compiled to bytecode (.class
  42. files). Bytecode is more compact than Java source code, but it may still
  43. contain a lot of unused code, especially if it includes program libraries.
  44. Shrinking programs such as <b>ProGuard</b> can analyze bytecode and remove
  45. unused classes, fields, and methods. The program remains functionally
  46. equivalent, including the information given in exception stack traces.
  47. <a name="obfuscation">&nbsp;</a>
  48. <h3>What is obfuscation?</h3>
  49. By default, compiled bytecode still contains a lot of debugging information:
  50. source file names, line numbers, field names, method names, argument names,
  51. variable names, etc. This information makes it straightforward to decompile
  52. the bytecode and reverse-engineer entire programs. Sometimes, this is not
  53. desirable. Obfuscators such as <b>ProGuard</b> can remove the debugging
  54. information and replace all names by meaningless character sequences, making
  55. it much harder to reverse-engineer the code. It further compacts the code as a
  56. bonus. The program remains functionally equivalent, except for the class
  57. names, method names, and line numbers given in exception stack traces.
  58. <a name="preverification">&nbsp;</a>
  59. <h3>What is preverification?</h3>
  60. When loading class files, the class loader performs some sophisticated
  61. verification of the byte code. This analysis makes sure the code can't
  62. accidentally or intentionally break out of the sandbox of the virtual machine.
  63. Java Micro Edition and Java 6 introduced split verification. This means that
  64. the JME preverifier and the Java 6 compiler add preverification information to
  65. the class files (StackMap and StackMapTable attributes, respectively), in order
  66. to simplify the actual verification step for the class loader. Class files can
  67. then be loaded faster and in a more memory-efficient way. <b>ProGuard</b> can
  68. perform the preverification step too, for instance allowing to retarget older
  69. class files at Java 6.
  70. <a name="optimization">&nbsp;</a>
  71. <h3>What kind of optimizations does <b>ProGuard</b> support?</h3>
  72. Apart from removing unused classes, fields, and methods in the shrinking step,
  73. <b>ProGuard</b> can also perform optimizations at the bytecode level, inside
  74. and across methods. Thanks to techniques like control flow analysis, data flow
  75. analysis, partial evaluation, static single assignment, global value numbering,
  76. and liveness analysis, <b>ProGuard</b> can:
  77. <ul>
  78. <li>Evaluate constant expressions.
  79. <li>Remove unnecessary field accesses and method calls.
  80. <li>Remove unnecessary branches.
  81. <li>Remove unnecessary comparisons and instanceof tests.
  82. <li>Remove unused code blocks.
  83. <li>Merge identical code blocks.
  84. <li>Reduce variable allocation.
  85. <li>Remove write-only fields and unused method parameters.
  86. <li>Inline constant fields, method parameters, and return values.
  87. <li>Inline methods that are short or only called once.
  88. <li>Simplify tail recursion calls.
  89. <li>Merge classes and interfaces.
  90. <li>Make methods private, static, and final when possible.
  91. <li>Make classes static and final when possible.
  92. <li>Replace interfaces that have single implementations.
  93. <li>Perform over 200 peephole optimizations, like replacing ...*2 by
  94. ...&lt;&lt;1.
  95. <li>Optionally remove logging code.
  96. </ul>
  97. The positive effects of these optimizations will depend on your code and on
  98. the virtual machine on which the code is executed. Simple virtual machines may
  99. benefit more than advanced virtual machines with sophisticated JIT compilers.
  100. At the very least, your bytecode may become a bit smaller.
  101. <p>
  102. Some notable optimizations that aren't supported yet:
  103. <ul>
  104. <li>Moving constant expressions out of loops.
  105. <li>Optimizations that require escape analysis.
  106. </ul>
  107. <a name="commercial">&nbsp;</a>
  108. <h3>Can I use <b>ProGuard</b> to process my commercial application?</h3>
  109. Yes, you can. <b>ProGuard</b> itself is distributed under the GPL, but this
  110. doesn't affect the programs that you process. Your code remains yours, and
  111. its license can remain the same.
  112. <a name="jdk1.4">&nbsp;</a>
  113. <h3>Does <b>ProGuard</b> work with Java 2? Java 5? Java 6?</h3>
  114. Yes, <b>ProGuard</b> supports all JDKs from 1.1 up to and including 6.0. Java 2
  115. introduced some small differences in the class file format. Java 5 added
  116. attributes for generics and for annotations. Java 6 introduced preverification
  117. attributes. <b>ProGuard</b> handles all versions correctly.
  118. <a name="jme">&nbsp;</a>
  119. <h3>Does <b>ProGuard</b> work with Java Micro Edition?</h3>
  120. Yes. <b>ProGuard</b> itself runs in Java Standard Edition, but you can freely
  121. specify the run-time environment at which your programs are targeted,
  122. including Java Micro Edition. <b>ProGuard</b> then also performs the required
  123. preverification, producing more compact results than the traditional external
  124. preverifier.
  125. <p>
  126. <b>ProGuard</b> also comes with an obfuscator plug-in for the JME Wireless
  127. Toolkit.
  128. <a name="android">&nbsp;</a>
  129. <h3>Does <b>ProGuard</b> work for Google Android code?</h3>
  130. Yes. Google's <code>dx</code> compiler converts ordinary jar files into files
  131. that run on Android devices. By preprocessing the original jar files,
  132. <b>ProGuard</b> can significantly reduce the file sizes and boost the run-time
  133. performance of the code.
  134. <a name="blackberry">&nbsp;</a>
  135. <h3>Does <b>ProGuard</b> work for Blackberry code?</h3>
  136. It should. RIM's proprietary <code>rapc</code> compiler converts ordinary JME
  137. jar files into cod files that run on Blackberry devices. The compiler performs
  138. quite a few optimizations, but preprocessing the jar files with
  139. <b>ProGuard</b> can generally still reduce the final code size by a few
  140. percent. However, the <code>rapc</code> compiler also seems to contain some
  141. bugs. It sometimes fails on obfuscated code that is valid and accepted by other
  142. JME tools and VMs. Your mileage may therefore vary.
  143. <a name="ant">&nbsp;</a>
  144. <h3>Does <b>ProGuard</b> have support for Ant?</h3>
  145. Yes. <b>ProGuard</b> provides an Ant task, so that it integrates seamlessly
  146. into your Ant build processes. You can still use configurations in
  147. <b>ProGuard</b>'s own readable format. Alternatively, if you prefer XML, you
  148. can specify the equivalent XML configuration.
  149. <a name="gui">&nbsp;</a>
  150. <h3>Does <b>ProGuard</b> come with a GUI?</h3>
  151. Yes. First of all, <b>ProGuard</b> is perfectly usable as a command-line tool
  152. that can easily be integrated into any automatic build process. For casual
  153. users, there's also a graphical user interface that simplifies creating,
  154. loading, editing, executing, and saving ProGuard configurations.
  155. <a name="forname">&nbsp;</a>
  156. <h3>Does <b>ProGuard</b> handle <code>Class.forName</code> calls?</h3>
  157. Yes. <b>ProGuard</b> automatically handles constructs like
  158. <code>Class.forName("SomeClass")</code> and <code>SomeClass.class</code>. The
  159. referenced classes are preserved in the shrinking phase, and the string
  160. arguments are properly replaced in the obfuscation phase.
  161. <p>
  162. With variable string arguments, it's generally not possible to determine their
  163. possible values. They might be read from a configuration file, for instance.
  164. However, <b>ProGuard</b> will note a number of constructs like
  165. "<code>(SomeClass)Class.forName(variable).newInstance()</code>". These might
  166. be an indication that the class or interface <code>SomeClass</code> and/or its
  167. implementations may need to be preserved. The user can adapt his configuration
  168. accordingly.
  169. <a name="resource">&nbsp;</a>
  170. <h3>Does <b>ProGuard</b> handle resource files?</h3>
  171. Yes. <b>ProGuard</b> copies all non-class resource files, optionally adapting
  172. their names and their contents to the obfuscation that has been applied.
  173. <a name="encrypt">&nbsp;</a>
  174. <h3>Does <b>ProGuard</b> encrypt strings constants?</h3>
  175. No. Storing encrypted string constants in program code is fairly futile, since
  176. the encryption has to be perfectly reversible by definition. Moreover, the
  177. decryption costs additional memory and computation at run-time. If this feature
  178. is ever incorporated, I'll provide a tool to decrypt the strings as well.
  179. <a name="flow">&nbsp;</a>
  180. <h3>Does <b>ProGuard</b> perform flow obfuscation?</h3>
  181. Not explicitly. Control flow obfuscation injects additional branches into the
  182. bytecode, in an attempt to fool decompilers. <b>ProGuard</b> does not do this,
  183. in order to avoid any negative effects on performance and size. However, the
  184. optimization step often already restructures the code to the point where most
  185. decompilers get confused.
  186. <a name="incremental">&nbsp;</a>
  187. <h3>Does <b>ProGuard</b> support incremental obfuscation?</h3>
  188. Yes. This feature allows you to specify a previous obfuscation mapping file in
  189. a new obfuscation step, in order to produce add-ons or patches for obfuscated
  190. code.
  191. <a name="keywords">&nbsp;</a>
  192. <h3>Can <b>ProGuard</b> obfuscate using reserved keywords?</h3>
  193. Yes. You can specify your own obfuscation dictionary, such as a list of
  194. reserved key words, identifiers with foreign characters, random source files,
  195. or a text by Shakespeare. Note that this hardly improves the obfuscation.
  196. Decent decompilers can automatically replace reserved keywords, and the effect
  197. can be undone fairly easily, by obfuscating again with simpler names.
  198. <a name="stacktrace">&nbsp;</a>
  199. <h3>Can <b>ProGuard</b> reconstruct obfuscated stack traces?</h3>
  200. Yes. <b>ProGuard</b> comes with a companion tool, <b>ReTrace</b>, that can
  201. 'de-obfuscate' stack traces produced by obfuscated applications. The
  202. reconstruction is based on the mapping file that <b>ProGuard</b> can write
  203. out. If line numbers have been obfuscated away, a list of alternative method
  204. names is presented for each obfuscated method name that has an ambiguous
  205. reverse mapping. Please refer to the <a href="manual/index.html">ProGuard User
  206. Manual</a> for more details.
  207. <hr>
  208. <address>
  209. Copyright &copy; 2002-2009
  210. <a href="http://www.graphics.cornell.edu/~eric/">Eric Lafortune</a>.
  211. </address>
  212. </body>
  213. </html>