如何使用Java注释最后汇编之前修改源$ C ​​$ C? [英] How to use java annotations to modify source code before final compilation?

查看:221
本文介绍了如何使用Java注释最后汇编之前修改源$ C ​​$ C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从apt工具页面,你可以创建AnnotationProcessors来阅读生成新的派生文件(源文件,类文件,部署描述符等)。我找的例子来这样做。

I've read from the apt tool page that one can create AnnotationProcessors to generate new derived files (source files, class files, deployment descriptors, etc.). I am looking for example to do so.

我需要的是EN code在编译时都注明字符串,因此,阅读类文件不允许读取静态字符串:

My need is to encode all annotated strings at compile time, so that reading the class file does not allow reading the static strings:

基地code:

String message = (@Obfuscated "a string that should not be readable in class file");

应返工为:

String message = new ObfuscatedString(new long[] {0x86DD4DBB5166C13DL, 0x4C79B1CDC313AE09L, 0x1A353051DAF6463BL}).toString();

基于静态 ObfuscatedString.obfuscate(string)的TrueLicense框架法<

/一>中,处理器可以生成code键替换注解字符串。事实上,这种方法生成的字符串新ObfuscatedString([numeric_ code])。的toString()。
在运行时ObfuscatedString的toString()方法能够在数字code返回字符串连接codeD。

Based on the static ObfuscatedString.obfuscate(String) method of the TrueLicense framework, the processor can generate the code to replace the annotated string. Indeed, this method generates the string "new ObfuscatedString([numeric_code]).toString()". At runtime the toString() method of ObfuscatedString is able to return the string encoded in the numeric code.

这是怎么写的AnnotationProcessor的过程中()方法来编辑注释$ C $(c)任何想法?

Any idea on how to write the process() method of the AnnotationProcessor to edit the annotated code?

由于提前,

推荐答案

我敢打赌,勺子可能你在找什么。但是,为什么要混淆静态字符串?

I bet spoon may be what you are looking for. But why do you want to obfuscate static strings?

这篇关于如何使用Java注释最后汇编之前修改源$ C ​​$ C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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