Search code examples
javajarclassloaderurlclassloader

Do I need to create custom ClassLoaders to support new archives format?


I need to support loading classes from other types of archives(tar.gz,tar.bz2...) and custom types defined by third parties. Do I need to override the 'loadClass' method to achieve that? (Perhaps theres another extension point for doing this? I still want to benefit from all the security checks made by the default class loaders).


Solution

  • Unfortunately there's no standard class loader that delegates to a simple class name to byte[]/ByteBuffer interface. You'll need to either do your own class loader, save to an icky temporary file or, I believe, give URLClassLoader.newInstance a URL with a custom URLHandler.