Oct 22 1999.

Duplicate Metaclass Problem


MetaClasses? What are they?

Also see my story, MetaClasses bite back


from: ParcPlace Tech support.

John,

Here's an explanation for the duplicate metaclass problem in VisualWorks.

When a class is recompiled, the ClassBuilder basically performs the
following steps:

- creates a new class
- compiles all of the methods from the old class into the new class
- does a become: to swap the old and new classes
- resets all of the mclass references in the class to refer to the correct class,
since they after the become they point to the obsolete class.

If there are any unbound methods in the image that refer the obsolete class,
the ClassBuilder cannot see them and therefore they still point to the old
Metaclass. In all the cases that I have found this is usually the result of
a class variable that contains a reference to an unbounded method. When the
method is recompiled, the method in which the block is defined becomes unbound.

The SteamPolicy problem is traced back to the StreamPolicy class variable
DateFormats.

The class variable DateFormats contains two associations. The values of these
associations are BlockClosures. At some point, the class was recompiled, but the
dictionary entries remained. I've attached the recommended fix below.

In addition, there are a couple of other instances that are caused by the
class recompilations that result from filing in events.st. The following
cleared up the problem in my images:

UIPainterController initialize.
ControlManager initializeNoWindowBlock.
ObjectMemory globalGarbageCollect.

Unfortunately, there is not a general formula for eliminating these instances.
At best one can identify them, then track them down, and fix them. I have put
in a request that this process be integrated into our next release to prevent
this from happening in the future.

Regards,
Paul Daly
______________________________________________________________________
Technical Support ParcPlace-Digitalk, Sunnyvale, CA
Phone: (408)773-7474 or (800)727-2555 FAX: (408)481-9096
Email: support-vw@parcplace.com URL: http://www.parcplace.com
______________________________________________________________________

'Copyright (C) 1996 by ParcPlace Systems, Inc. All rights reserved.'!

ChangeSet current addPatch: 'VW2.5.1-13032u1'!

"Bug: Multiple StreamPolicy metaclasses in the image.

Problem: When the StreamPolicy class is recompiled the entries
in the DateFormats class dictionary contains references to
BlockClosures that were defined in methods that no longer exist.
This has the unwanted side effect of holding on to the old
StreamPolicy class.

Fix: Modify StreamPolicy class>>initialize to properly initialize
the DateFormats class variable."!

!StreamPolicy class methodsFor: 'class initialization'!

initialize
"StreamPolicy initialize"

DateFormats := Dictionary new.
DefaultPolicy := self new.
self initializeDates.! !

StreamPolicy initialize.!
ObjectMemory globalGarbageCollect.!