自动大写从 Java 到 .NET 的端口的所有方法名称
我正在使用 IKVM 将大型 Java 库项目编译为 .NET DLL。然而,这样做时,方法名称将遵循 Java 方法名称不大写的约定 - 但我希望 .NET dll 在 .NET 项目中使用,因此希望方法名称大写。
唯一的例外是 JDK 方法的重载方法,例如 toString() 等 - 这些方法必须保持小写。
我应该如何自动重命名所有方法(不是 JDK 方法的重载!),使它们变成大写名称?
请注意,我已经尝试使用像 Proguard 这样的混淆器,但不断遇到设置问题并且希望有一个不同的解决方案 - 但如果您知道任何使用 Proguard 的easy方法,请告诉我!
I am using IKVM to compile a large Java library project to a .NET DLL. In so doing, however, the method names are staying according to the Java convention of method names NOT being capitalized - but I want the .NET dll to be used in .NET projects and so would like the method names to be capitalized.
The only exception would be methods which are overloads of JDK methods such as toString() or such - these will have to remain in lower-case.
How should I go about automatically renaming all methods (which are not overloads of JDK methods!), making them into capitalized names?
Note that I've tried using an obfuscator like Proguard but keep running into settings issues and would love a different solution - but if you know of any easy way to do it with Proguard, please let me know!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将使用 sed、awk 和一个简单的正则表达式来为您检查和替换方法。方法有一个相当可预测的签名..
public|private|protected (一些词包括 void)(可能是静态的)(可能是同步的)(实际的方法名称)。
该脚本会将所有内容都颠倒.. 然后,如果正确地具有 @Override 注释,则像 toString 这样的东西将破坏编译.. 并且您可以返回并修复(手动或使用专门用于 toString 等的另一个 sed )。
I would use sed, awk, and a simple regex to go through and replace methods for you. Methods have a pretty predictable signature..
public|private|protected (some word including void) (maybe static) (maybe synchronized) (the actual method name).
The script would bump everything up.. then the stuff like toString will break compilation if it properly has the @Override annotation.. and you can go back and fix (by hand or with another sed specifically for toString and such).