JavaClassReloader.st
author hlopkmar
Fri, 30 Nov 2012 20:52:11 +0000
branchdevelopment
changeset 1844 7f4dd9a13c2c
parent 1818 2e5ed72e7dfd
child 1864 60a8dc26c8c6
permissions -rw-r--r--
disabling multibyte char disassempler test as stderr cannot write multibyte chars and hudson reports error
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
     1
"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
     3
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
     5
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
     8
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    14
 hereby transferred.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    15
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    18
     see the differences between this version and version stx:libjava
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    19
     as of 1.9.2010
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    20
"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    22
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    23
Object subclass:#JavaClassReloader
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    24
	instanceVariableNames:''
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    25
	classVariableNames:''
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    26
	poolDictionaries:''
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    27
	category:'Languages-Java-Support'
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    28
!
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    29
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    30
Object subclass:#SingleClassReloader
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    31
	instanceVariableNames:'oldClass newClass mustMigrateInstances mustMigrateClass
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    32
		instFieldMapping staticFieldMapping'
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    33
	classVariableNames:''
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    34
	poolDictionaries:''
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    35
	privateIn:JavaClassReloader
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    36
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    37
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    38
Object subclass:#FieldMapping
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    39
	instanceVariableNames:'old new'
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    40
	classVariableNames:''
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    41
	poolDictionaries:''
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    42
	privateIn:JavaClassReloader::SingleClassReloader
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    43
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    44
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    45
!JavaClassReloader class methodsFor:'documentation'!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    46
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    47
copyright
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    48
"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    49
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    50
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    51
 New code and modifications done at SWING Research Group [1]:
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    52
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    53
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    54
                            SWING Research Group, Czech Technical University in Prague
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    55
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    56
 This software is furnished under a license and may be used
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    57
 only in accordance with the terms of that license and with the
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    58
 inclusion of the above copyright notice.   This software may not
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    59
 be provided or otherwise made available to, or used by, any
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    60
 other person.  No title to or ownership of the software is
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    61
 hereby transferred.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    62
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    63
 [1] Code written at SWING Research Group contains a signature
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    64
     of one of the above copright owners. For exact set of such code,
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    65
     see the differences between this version and version stx:libjava
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    66
     as of 1.9.2010
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    67
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    68
"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    69
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    70
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    71
documentation
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    72
"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    73
    A main workhorse for reloading (updating) java classes
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    74
    in running system.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    75
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    76
    [author:]
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    77
        Jan Vrany <jan.vrany@fit.cvut.cz>
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    78
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    79
    [instance variables:]
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    80
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    81
    [class variables:]
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    82
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    83
    [see also:]
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    84
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    85
"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    86
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    87
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    88
!JavaClassReloader class methodsFor:'reloading'!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    89
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    90
reload: oldClass with: newClass
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    91
    ^ self new reload: oldClass with: newClass
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    92
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    93
    "Created: / 20-02-2012 / 23:29:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    94
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
    95
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    96
!JavaClassReloader methodsFor:'reloading'!
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    97
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    98
reload: oldClass with: newClass
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
    99
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   100
    | newClassToInstall |
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   101
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   102
    newClassToInstall := SingleClassReloader new reload: oldClass with: newClass.
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   103
    "Also, reload all subclasses - fields may have changed!!"
1454
518b5e5332c6 - JavaClassReloader: do not reload subclasses if new class remains the same (MD update only)
vranyj1
parents: 1453
diff changeset
   104
    newClassToInstall ~~ oldClass ifTrue:[
518b5e5332c6 - JavaClassReloader: do not reload subclasses if new class remains the same (MD update only)
vranyj1
parents: 1453
diff changeset
   105
        oldClass subclassesDo:[:oldSubclass|
518b5e5332c6 - JavaClassReloader: do not reload subclasses if new class remains the same (MD update only)
vranyj1
parents: 1453
diff changeset
   106
            | newSubclass |
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   107
1454
518b5e5332c6 - JavaClassReloader: do not reload subclasses if new class remains the same (MD update only)
vranyj1
parents: 1453
diff changeset
   108
            newSubclass := oldSubclass copy.
518b5e5332c6 - JavaClassReloader: do not reload subclasses if new class remains the same (MD update only)
vranyj1
parents: 1453
diff changeset
   109
            newSubclass setSuperclass: newClassToInstall.
518b5e5332c6 - JavaClassReloader: do not reload subclasses if new class remains the same (MD update only)
vranyj1
parents: 1453
diff changeset
   110
            newSubclass instSize: (newClassToInstall instSize + oldSubclass fields size).
518b5e5332c6 - JavaClassReloader: do not reload subclasses if new class remains the same (MD update only)
vranyj1
parents: 1453
diff changeset
   111
            JavaVM registry registerClass: newSubclass.
518b5e5332c6 - JavaClassReloader: do not reload subclasses if new class remains the same (MD update only)
vranyj1
parents: 1453
diff changeset
   112
        ].
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   113
    ].
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   114
    ^newClassToInstall.
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   115
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   116
    "Created: / 04-04-2012 / 01:32:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   117
! !
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   118
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   119
!JavaClassReloader::SingleClassReloader methodsFor:'private'!
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   120
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   121
invalidate
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   122
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   123
    | anyInvalidated |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   124
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   125
    anyInvalidated := false.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   126
    JavaVM registry classesDo:[:class|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   127
        anyInvalidated := anyInvalidated | (self invalidateClass: class).
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   128
    ].
1376
c4b2cf1467c3 Fixes for Groovy and class reloading
vranyj1
parents: 1372
diff changeset
   129
    anyInvalidated ifTrue:[ObjectMemory flushCaches].
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   130
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   131
    "Created: / 21-02-2012 / 09:47:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   132
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   133
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   134
invalidateClass: javaClass
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   135
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   136
    ^javaClass constantPool invalidateForClass: oldClass name
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   137
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   138
    "Created: / 21-02-2012 / 09:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   139
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   140
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   141
migrate
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   142
    "Possibly migrate instances and class. Return the class that should
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   143
     be installed in registry afterwards"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   144
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   145
    mustMigrateInstances ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   146
        self migrateInstances.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   147
        mustMigrateClass ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   148
            self migrateClass
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   149
        ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   150
        ^newClass.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   151
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   152
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   153
    mustMigrateClass ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   154
        self migrateClass.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   155
        ^newClass.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   156
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   157
    self update.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   158
    ^oldClass.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   159
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   160
    "Created: / 20-02-2012 / 23:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   161
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   162
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   163
migrateClass
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   164
1376
c4b2cf1467c3 Fixes for Groovy and class reloading
vranyj1
parents: 1372
diff changeset
   165
    "/self error:'Not yet supported'
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   166
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   167
    "Created: / 21-02-2012 / 11:04:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   168
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   169
1441
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   170
migrateInstance: object
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   171
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   172
    self assert: object class == oldClass.
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   173
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   174
    "Created: / 30-03-2012 / 19:42:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   175
!
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   176
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   177
migrateInstances
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   178
1441
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   179
    oldClass allInstancesDo:[:i|
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   180
        self migrateInstance:i.
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   181
    ].
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   182
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   183
    "Created: / 21-02-2012 / 11:04:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   184
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   185
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   186
prepare
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   187
    "Analyze and prepare data for reloading" 
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   188
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   189
    self prepareInstFieldMapping.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   190
    self prepareStaticFieldMapping.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   191
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   192
    "Created: / 20-02-2012 / 23:40:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   193
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   194
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   195
prepareFieldMap: fields
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   196
    | map |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   197
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   198
    map := Dictionary new.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   199
    fields do:[ :field | map at: field name put: field ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   200
    ^map
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   201
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   202
    "Created: / 21-02-2012 / 09:42:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   203
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   204
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   205
prepareInstFieldMapping
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   206
    "Scans both old and new class inst fields and create a mapping.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   207
     Sets mustMigrateInstances"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   208
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   209
    | newFields |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   210
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   211
    mustMigrateInstances := false.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   212
    instFieldMapping := Set new.
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   213
    newFields := self prepareFieldMap: newClass allFields.
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   214
    oldClass fields do:[:old|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   215
        | new mapping |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   216
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   217
        new := newFields at: old name ifAbsent:[nil].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   218
        new notNil ifTrue:[ newFields removeKey: old name ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   219
        mapping := FieldMapping old: old new: new.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   220
        mustMigrateInstances := mustMigrateInstances or:[mapping mustMigrate].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   221
        instFieldMapping add: mapping.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   222
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   223
    "Remaining fields are new, i.e., does not exist in
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   224
     old class. Add them to the mapping"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   225
    newFields do:[:new|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   226
        instFieldMapping add: (FieldMapping old: nil new: new).
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   227
        mustMigrateInstances := true
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   228
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   229
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   230
    "Created: / 21-02-2012 / 09:32:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   231
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   232
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   233
prepareStaticFieldMapping
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   234
    "Scans both old and new class inst fields and create a mapping.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   235
     Sets mustMigrateInstances"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   236
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   237
    | newFields |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   238
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   239
    mustMigrateClass := false.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   240
    staticFieldMapping := Set new.
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   241
    newFields := self prepareFieldMap: newClass allStaticFields.
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   242
    oldClass staticFields do:[:old|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   243
        | new mapping |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   244
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   245
        new := newFields at: old name ifAbsent:[nil].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   246
        new notNil ifTrue:[ newFields removeKey: old name ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   247
        mapping := FieldMapping old: old new: new.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   248
        mustMigrateClass:= mustMigrateClass or:[mapping mustMigrate].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   249
        staticFieldMapping add: mapping.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   250
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   251
    "Remaining fields are new, i.e., does not exist in
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   252
     old class. Add them to the mapping"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   253
    newFields do:[:new|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   254
        staticFieldMapping add: (FieldMapping old: nil new: new).
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   255
        mustMigrateClass:= true
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   256
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   257
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   258
    "Created: / 21-02-2012 / 09:45:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   259
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   260
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   261
update
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   262
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   263
    "Brute force, copy instvars directly"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   264
    self assert: oldClass class instSize == newClass class instSize.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   265
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   266
    1 to: newClass class instSize do:[:i|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   267
        newClass instVarAt: i put: (oldClass instVarAt: i).
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   268
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   269
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   270
    "Created: / 21-02-2012 / 11:04:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   271
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   272
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   273
!JavaClassReloader::SingleClassReloader methodsFor:'reloading'!
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   274
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   275
reload
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   276
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   277
    self prepare.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   278
    self invalidate.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   279
    ^self migrate.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   280
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   281
    "Created: / 20-02-2012 / 23:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   282
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   283
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   284
reload: oldClassA with: newClassA
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   285
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   286
    oldClass := oldClassA.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   287
    newClass := newClassA.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   288
    ^ self reload.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   289
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   290
    "Created: / 20-02-2012 / 23:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   291
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   292
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   293
!JavaClassReloader::SingleClassReloader::FieldMapping class methodsFor:'instance creation'!
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   294
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   295
old: old new:new
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   296
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   297
    ^self new old: old new: new.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   298
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   299
    "Created: / 21-02-2012 / 09:20:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   300
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   301
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   302
!JavaClassReloader::SingleClassReloader::FieldMapping methodsFor:'accessing'!
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   303
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   304
new
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   305
    ^ new
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   306
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   307
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   308
new:something
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   309
    new := something.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   310
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   311
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   312
old
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   313
    ^ old
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   314
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   315
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   316
old:something
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   317
    old := something.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   318
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   319
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   320
old:oldArg new:newArg 
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   321
    old := oldArg.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   322
    new := newArg.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   323
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   324
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   325
!JavaClassReloader::SingleClassReloader::FieldMapping methodsFor:'queries'!
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   326
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   327
mustMigrate
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   328
    "Returns true if the field must be migrated, false otherwise"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   329
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   330
    | oldD newD |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   331
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   332
    (old isNil or:[new isNil]) ifTrue:[ 
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   333
        ^ true "Either one is missing, must migrate"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   334
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   335
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   336
    old index ~~ new index ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   337
        ^true "Offsets changed, must migrate"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   338
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   339
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   340
    oldD := old descriptor.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   341
    newD := new descriptor.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   342
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   343
    oldD = newD ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   344
        ^false"Same descriptor, the easy case"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   345
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   346
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   347
    (oldD first == $L and: [newD first == $L]) ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   348
        ^false"Both object types, who cares about type safety in Smalltalk?"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   349
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   350
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   351
    1 to: (oldD size min: newD size) do:[:i|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   352
        ((oldD at: i) == $L and: [ (newD at: i) == $L ]) ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   353
            ^false"Both object types, who cares about type safety in Smalltalk?"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   354
        ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   355
        ((oldD at: i) ~~ $[ or: [ (newD at: i) ~~ $[ ]) ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   356
            ^true"Different primitive/array types, must migrate"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   357
        ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   358
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   359
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   360
    ^false
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   361
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   362
    "Created: / 21-02-2012 / 10:57:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   363
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   364
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   365
!JavaClassReloader class methodsFor:'documentation'!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   366
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   367
version_SVN
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   368
    ^ '$Id$'
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   369
! !