简体   繁体   中英

Java AOT + loading java classes dynamically

I'm building a plugin system for my application. I've read that anyone can decomple .class files and therefore I'm forced ot use a Ahead-Of-Time compiler (right?). The problem is that I need to load some plugin classes dynamically. Right now I'm loading all .class files in a folder and invoking a static method (I never create a object) as a plugin system.

Can I load those classes when all my source is AOT compled? Should I approach the problem another way? Is Java the right language for me?

Ahead of time compilation is not for blocking people from de-compiling. I think you should use an obfuscator for that purpose.

Dynamically loading classes for plugin system should work with both the obfuscators and AOT.

Tahit Akhtar is right. You need an obfuscator. You'll have to configure it not to obfuscate the name of the classes and methods that your program uses dynamically to load and call the plugins. That is, the public SPI of the plugins cannot be obfuscated, but their implementations can.

Unless your classes contain some really top secret functionality I would say drop the obfuscation...

I'm building myself a plug-in framework and I had the same thought to block access to the plug-ins code(since everything sensitive will be there) but I gave up, nowadays everything you can think of is already posted on the web, there are no more secrets in software development ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM