groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alain Stalder <>
Subject Share MetaClass state between classes based on same bytecode?
Date Sun, 23 Aug 2015 07:50:45 GMT
I load the same set of compiled Groovy scripts with several separate
class loaders. Say, I have a script "MyScript.groovy" that results
in a class called MyScript. Now, for each class loader, a separate
MyScript class instance will be created and by default, a new
instance of an associated MetaClass with be created, initialized
and stored in the MetaClassRegistry, even though these classes have
the same methods and so on. This costs quite a bit of time and memory.

What I would like to do instead, is determine meta information just
once per same bytecode and reuse it in several lightweight MetaClass

What kind of options do I have? What do I have to consider?

Make a copy of MetaClassImpl, modify it, and set an instance of it
in the registry when loading a class?

Or is there a better way that involves copying less code (which is
not so robust against Groovy upgrades)?


View raw message