[squeak-dev] The Inbox: Environments-lrnp.85.mcz

commits at source.squeak.org commits at source.squeak.org
Wed May 25 03:24:36 UTC 2022


A new version of Environments was added to project The Inbox:
http://source.squeak.org/inbox/Environments-lrnp.85.mcz

==================== Summary ====================

Name: Environments-lrnp.85
Author: lrnp
Time: 24 May 2022, 9:24:35.577497 pm
UUID: 315c72c4-9d5f-480e-bbcf-1471cb91bae9
Ancestors: Environments-ul.84

add helper to clean stale class binding references

If, for example, you #unbind: a class manually without doing [aClass removeFromSystem] traces of it are left in the environment. This method finds all classes in the system that were improperly removed and properly removes them.

=============== Diff against Environments-ul.84 ===============

Item was added:
+ ----- Method: Environment>>sweepObsoleteClassReferences (in category 'classes and traits') -----
+ sweepObsoleteClassReferences
+ 	"Clean out references to expired class bindings in my receiver.
+ 
+ 	The swept classes are printed to Transcript.
+ 
+ 	Low-level manipulation of an Environment may result in state becoming inconsistent. This method cleans up any messes left behind due to error or oversight."
+ 
+ 	| obsolete |
+ 	obsolete := OrderedCollection new.
+ 	ProtoObject allSubclassesDo: [:cls |
+ 		(cls == cls theNonMetaClass
+ 				and: [cls environment == self]
+ 				and: [(self classNamed: cls name) isNil])
+ 			ifTrue: [
+ 				Transcript showln: 'Sweeping bindings for an obsolete class ',
+ 						cls name, '(', cls identityHash, ')'.
+ 				self bind: cls name to: cls.		"temporarily bind it to use #forgetClass:logged:"
+ 				cls removeFromSystem		"unbind it the proper way"]]!



More information about the Squeak-dev mailing list