我如何混淆外部GWT开发的Java源代码? [英] How can I obfuscate Java source code for external GWT development?

查看:97
本文介绍了我如何混淆外部GWT开发的Java源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大部分模糊处理都集中在字节码上。我必须提供源代码,因为外部开发人员需要运行GWT编译器。在发布源代码之前,我需要清理它:




  • 混淆方法变量名称

  • 混淆私有方法参数名称

  • 删除除每个文件顶部的许可证之外的所有非Javadoc注释。

  • 删除所有Javadoc注释私人方法或最终类的保护方法。
  • 删除某些Javadoc标签,如@author

  • 删除某些其他评论标签,如TODO,FIXME,

  • 删除所有对私人类的引用@
  • 删除所有空白



除了上述所有注释和所有Javadoc都可以被删除(每个文件顶部仍然需要许可证),我会分别生成Javadoc。



我还没有找到一种方法,我可以确定它可以在多平台上执行的gradle构建脚本中很好地工作。一些非常古老且不再维护的解决方案可能会在诸如钻石运营商和lambda等Java增强方面遇到麻烦。



对于我如何做到这一点,有任何建议吗? p>

请注意,这里有很多这样的问题没有答案。其中之一: GWT Java混淆

解决方案

今天没有任何东西可用:


  1. 源代码混淆开始。

  2. 其中一些不是免费的或不是基于Java的。

  3. 源代码(格式化)工具没有足够的可定制性来移除所有的注释,但将GWTJSNI代码放入(GWT将JavaScript代码嵌入到Java中的特殊/ * - {...} - * / /native方法的样式注释中。 li>

最后,我自己写了一段简单的代码,只取出所有的空白,但保留了JSNI代码并保持原样。不会混淆方法变量或其他任何东西,但它现在必须做。


Most obfuscation focuses on bytecode. I have to supply the source code too as that is what a GWT compiler an external developer would use needs to run. Before releasing the source code I need to clean it up a bit:

  • Obfuscate method variable names
  • Obfuscate private method argument names
  • Remove all non-Javadoc comments except for the licence at the top of each file.
  • Remove all Javadoc comments on private methods or protected methods of final classes.
  • Remove certain Javadoc tags such as @author
  • Remove certain other comment tags such as TODO, FIXME, etc.
  • Remove all @see references to private classes
  • Remove all whitespace

Alternatively to the above all comments and all Javadoc could be removed (licence still needed at the top of each file) and I'd generate Javadoc separately.

I have not found a way that I could be sure would work nicely from within a gradle build script executed on multiple platforms. Some very old and no longer maintained solutions may have trouble with Java enhancements such as diamond operators and lambdas.

Are there any recommendations as to how I could do this?

Note that there are many questions like this unanswered here. One of them: GWT Java Obfuscation

解决方案

Nothing appears to be available for this TODAY:

  1. There are very few tools that work on Java source code obfuscation to begin with.
  2. Some of these are either not free or are not Java based.
  3. Source code (formatting) tools that remain are not customizable enough to remove all the comments but leave the GWT "JSNI" code in (GWT's way of embedding JavaScript code into Java within special /*-{ ... }-*/ style comments of "native" methods.

In the end, I wrote a simple bit of code myself that only takes out all the whitespace but leaves the JSNI code in and untouched. It does not obfuscate method variables or anything else but it will have to do for now.

这篇关于我如何混淆外部GWT开发的Java源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆