<p>I wonder if anyone uses commercial/free java obfuscators on his own commercial product. I know only about one project that actually had an obfuscating step in the ant build step for releases.</p>

<p>Do you obfuscate? And if so, why do you obfuscate?</p>

<p>Is it really a way to protect the code or is it just a better feeling for the developers/managers?</p>

<p><strong>edit:</strong> Ok, I to be exact about my point: Do you obfuscate to protect your IP (your algorithms, the work you've put into your product)? I won't obfuscate for security reasons, that doesn't feel right. So I'm only talking about protecting your applications code against competitors.</p>

<p><a href="https://stackoverflow.com/users/988/staffan">@staffan</a> has a good point:</p>

<blockquote>
  <p>The reason to stay away from chaining code flow is that some of those changes makes it impossible for the JVM to efficiently optimize the code. In effect it will actually degrade the performance of your application.</p>
</blockquote>

[{'answer_id': 12096, 'author': 'ninesided', 'author_id': 1030, 'author_profile': 'https://Stackoverflow.com/users/1030', 'pm_score': 3, 'selected': False, 'text': "<p>I guess it really comes down to <em>what</em> your Java code is for, how it's distributed and who your clients are. We don't obfuscate anything, as we've never found one that was particularly good and it tends to be more trouble than it's worth. If someone has access to our JAR files and has the knowledge to be able to sniff around inside them, then there's far more worrying things that they can do than rip off our source code.</p>\n"}, {'answer_id': 12100, 'author': 'izb', 'author_id': 974, 'author_profile': 'https://Stackoverflow.com/users/974', 'pm_score': 4, 'selected': False, 'text': '<p>I use proguard for JavaME development. It\'s not only very very good at making jar files smaller (Essential for mobile) but it is useful as a nicer way of doing device-specific code without resorting to IDE-unfriendly preprocessing tools such as antenna.</p>\n\n<p>E.g.</p>\n\n<pre><code>public void doSomething()\n{\n    /* Generated config class containing static finals: */\n    if (Configuration.ISMOTOROLA)\n    {\n        System.out.println("This is a motorola phone");\n    }\n    else\n    {\n        System.out.println("This is not a motorola phone");\n    }\n}\n</code></pre>\n\n<p>This gets compiled, obfuscated, and the class file ends up as though you had written:</p>\n\n<pre><code>public void doSomething()\n{\n    System.out.println("This is a motorola phone");\n}\n</code></pre>\n\n<p>So you can have variants of code to work around manufacturer bugs in JVM/library implementations without bulking out the final executable class files.</p>\n\n<p>I believe that some commercial obfuscators can also merge class files together in certain cases. This is useful because the more classes you have, the larger the size overhead you have in the zip (jar) file.</p>\n'}, {'answer_id': 12133, 'author': 'staffan', 'author_id': 988, 'author_profile': 'https://Stackoverflow.com/users/988', 'pm_score': 7, 'selected': True, 'text': '<p>If you do obfuscate, stay away from obfuscators that modify the code by changing code flow and/or adding exception blocks and such to make it hard to disassemble it. To make the code unreadable it is usually enough to just change all names of methods, fields and classes.</p>\n\n<p>The reason to stay away from changing code flow is that some of those changes makes it impossible for the JVM to efficiently optimize the code. In effect it will actually degrade the performance of your application. </p>\n'}, {'answer_id': 110472, 'author': 'adum', 'author_id': 9871, 'author_profile': 'https://Stackoverflow.com/users/9871', 'pm_score': 4, 'selected': False, 'text': '<p>I spent some time this year trying out various Java obfuscators, and I found one to be miles ahead of the rest: <a href="http://www.sable.mcgill.ca/JBCO/" rel="noreferrer">JBCO</a>. It\'s unfortunately a bit cumbersome to set up, and has no GUI, but in terms of the level of obfuscation it produces, it is unparalleled. You try feeding it a simple loop, and if your decompiler doesn\'t crash trying to load it, you will see something like this:</p>\n\n<pre><code>    if(i &lt; ll1) goto _L6; else goto _L5\n_L5:\n    char ac[] = run(stop(lI1l));\n    l7 = (long)ac.length &lt;&lt; 32 &amp; 0xffffffff00000000L ^ l7 &amp; 0xffffffffL;\n    if((int)((l7 &amp; 0xffffffff00000000L) &gt;&gt; 32) != $5$)\n    {\n        l = (long)III &lt;&lt; 50 &amp; 0x4000000000000L ^ l &amp; 0xfffbffffffffffffL;\n    } else\n    {\n        for(l3 = (long)III &amp; 0xffffffffL ^ l3 &amp; 0xffffffff00000000L; (int)(l3 &amp; 0xffffffffL) &lt; ll1; l3 = (long)(S$$ + (int)(l3 &amp; 0xffffffffL)) ^ l3 &amp; 0xffffffff00000000L)\n        {\n            for(int j = III; j &lt; ll1; j++)\n            {\n                l2 = (long)actionevent[j][(int)(l3 &amp; 0xffffffffL)] &amp; 65535L ^ l2 &amp; 0xffffffffffff0000L;\n                l6 = (long)(j &lt;&lt; -351) &amp; 0xffffffffL ^ l6 &amp; 0xffffffff00000000L;\n                l1 = (long)((int)(l6 &amp; 0xffffffffL) + j) &amp; 0xffffffffL ^ l1 &amp; 0xffffffff00000000L;\n                l = (long)((int)(l1 &amp; 0xffffffffL) + (int)(l3 &amp; 0xffffffffL)) &lt;&lt; 16 &amp; 0xffffffff0000L ^ l &amp; 0xffff00000000ffffL;\n                l = (long)ac[(int)((l &amp; 0xffffffff0000L) &gt;&gt; 16)] &amp; 65535L ^ l &amp; 0xffffffffffff0000L;\n                if((char)(int)(l2 &amp; 65535L) != (char)(int)(l &amp; 65535L))\n                {\n                    l = (long)III &lt;&lt; 50 &amp; 0x4000000000000L ^ l &amp; 0xfffbffffffffffffL;\n                }\n            }\n\n        }\n\n    }\n</code></pre>\n\n<p>You didn\'t know Java had goto\'s? Well, the JVM supports them =)</p>\n'}, {'answer_id': 814349, 'author': 'Lawrence Dol', 'author_id': 8946, 'author_profile': 'https://Stackoverflow.com/users/8946', 'pm_score': 4, 'selected': False, 'text': '<p>I use <a href="http://proguard.sourceforge.net" rel="noreferrer">ProGuard</a> and highly recommend it.  While obfuscation does protect your code from casual attackers, it\'s main benefit is the minimizing effect of removing unused classes and methods and shortening all identifiers to 1 or 2 characters.</p>\n'}, {'answer_id': 871848, 'author': 'StaxMan', 'author_id': 59501, 'author_profile': 'https://Stackoverflow.com/users/59501', 'pm_score': 4, 'selected': False, 'text': "<p>I think that for the most part obfuscation is pointless: even with full source code it's generally hard enough to figure out what the heck intention was (assuming there are no comments, and no meaningful names for local variables -- which is the case when re-generating sources from byte code). Obfuscation just decorates the cake.</p>\n\n<p>I think developers and especially their managers tend to greatly over-exaggerate risk of someone seeing the source code. While good decompilers can produce nice looking source code, it's not trivial to work with it, and costs associated (not to mention legal risks) are high enough to make this approach seldom useful. I have only decompiled to debug problems with closed-source vendors' products (deadlocks in DB abstraction layer, ugh).\nBytecode was actually obfuscated, I think, but we nonetheless found the underlying problem -- it was an actual design problem.</p>\n"}, {'answer_id': 10137205, 'author': 'Ivan Kinash', 'author_id': 1254184, 'author_profile': 'https://Stackoverflow.com/users/1254184', 'pm_score': 5, 'selected': False, 'text': '<p>I think that the old (classical) way of the obfuscation is gradually losing its relevance. Because in most cases a classical obfuscators breaking a stack trace (it is not good for support your clients)</p>\n\n<p>Nowadays the main point to not protect some algorithms, but to protect a sensitive data: API logins/passwords/keys, code which responsible for licensing (piracy still here, especially Western Europe, Russia, Asia, IMHO), advertisement account IDs, etc. </p>\n\n<p>Interesting fact: we have all this sensitive data in Strings. Actually Strings is about 50-80% of logic of our applications.\nIt seems to me that future of obfuscation is "String encryption tools".</p>\n\n<p>But now "String encryption" feature is available only in commercial obfuscators, such as: <a href="http://www.allatori.com/" rel="noreferrer">Allatori</a>, <a href="http://www.zelix.com/klassmaster/index.html" rel="noreferrer">Zelix KlassMaster</a>, <a href="http://www.leesw.com/smokescreen/" rel="noreferrer">Smokescreen</a>, <a href="https://jfxstore.com/stringer" rel="noreferrer">Stringer Java Obfuscation Toolkit</a>, <a href="http://www.preemptive.com/" rel="noreferrer">DashO</a>.</p>\n\n<p>N.B.\nI\'m CEO at Licel LLC. Developer of Stringer Java Obfuscator.</p>\n'}]
['https://Stackoverflow.com/questions/12088', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/834/']