The only downside i see here is that finalization of every object will now lookup for a corresponding monitor, if it's class doesn't define embedded one.

Ok, i think i've found a simple yet effective solution.
Adding a flag to ClassFlags: hasAllocatedMonitors.
Mark m_flags with this flag in runtime, when monitor is allocated.
When finalizing, check this flag to know if we need to lookup the monitors.

This way the only types that suffer would be those who don't define embedded __monitor, but still use synchronized() over them.

Would that be an ultimate win-win solution?

Reply via email to