Java AOT + dynamically loading Java classes

I am creating a plugin for my application. I read that anyone can unpack .class files and so I am forced to use the Ahead-Of-Time compiler (right?). The problem is I need to load some plugin classes dynamically. Right now I am loading all .class files into a folder and calling a static method (I never create an object) as a plugin system.

Can I load these classes when all the AOT source code is compiled? Should I approach the problem differently? Is Java the right language for me?

+1


a source to share


3 answers


Compilation time ahead is not to block people from compiling. I think you should use an obfuscator for this purpose.



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

+4


a source


Tait Akhtar is right. You need an obfuscator. You will have to customize it to avoid obfuscating the name of the classes and methods that your program dynamically uses to load and call plugins. That is, public SPI plugins cannot be obfuscated, but their implementations can.



+2


a source


Unless your classes contain some really top secret functionality, I would say discard obfuscation ...

I am building a plugin platform and I thought I was blocking access to the plugin code (since all the sensitive ones will be there), but I gave up, now everything you can think of is already published on the internet there are no more secrets in software development; )

+1


a source







All Articles