Search code examples
javastaticclassloaderfinal

static final's and multiple classloaders


I have a definition like this

public static final Object foo = Xyz.generateFoo(); 

And my application is using multiple custom class loaders. How can I ensure that all classes see the same instance of foo?

Preferrably without resorting to external storage (ie System.Properties or file). Thanks.


Solution

  • Place a reference to the value in a class loaded by a common parent class loader.