JavaClassReloader.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 16 Jan 2013 21:31:50 +0000
branchrefactoring-vmdata
changeset 1973 617e6a088dd1
parent 1895 2d30e588124c
child 2069 75d40b7b986f
permissions -rw-r--r--
- JavaListInspectorView class: JavaListInspectorView - JavaFormalParameterNode class: JavaFormalParameterNode - JavaTypeNode class: JavaTypeNode - JavaScanner class: JavaScanner - JavaArrayTypeNode class: JavaArrayTypeNode - JavaParser class: JavaParser - JavaCommentNode class: JavaCommentNode - JavaIntTypeNode class: JavaIntTypeNode - JavaParseNodeBuilder class: JavaParseNodeBuilder - JavaMethodDeclaratorNode class: JavaMethodDeclaratorNode - JavaScannerBase class: JavaScannerBase - JavaFloatTypeNode class: JavaFloatTypeNode - JavaDocNode class: JavaDocNode - JavaClassOrInterfaceTypeNode class: JavaClassOrInterfaceTypeNode - stx_libjava_tools class: stx_libjava_tools - JavaSettingsApplication class: JavaSettingsApplication - JavaLongTypeNode class: JavaLongTypeNode - JavaParserII class: JavaParserII - JavaSourceReference class: JavaSourceReference - JavaCharTypeNode class: JavaCharTypeNode - JavaParser_Eclipse class: JavaParser_Eclipse - JavaSyntaxHighlighter class: JavaSyntaxHighlighter - JavaMethodNode class: JavaMethodNode - JavaBooleanTypeNode class: JavaBooleanTypeNode - JavaDoubleTypeNode class: JavaDoubleTypeNode - JavaSetInspectorView class: JavaSetInspectorView - JavaParseNode class: JavaParseNode - JavaVoidTypeNode class: JavaVoidTypeNode - JavaMapInspectorView class: JavaMapInspectorView - JavaParserI class: JavaParserI - extensions ...
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
1895
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   143
     be installed in registry once reloader finishes his job.
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   144
     
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   145
     At this point, all references are already invalidated (see #reload)
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   146
     "
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   147
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   148
    mustMigrateInstances ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   149
        self migrateInstances.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   150
        mustMigrateClass ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   151
            self migrateClass
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
        ^newClass.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   154
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   155
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   156
    mustMigrateClass ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   157
        self migrateClass.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   158
        ^newClass.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   159
    ].
1895
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   160
    self updateOldClass.
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   161
    ^oldClass.
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
    "Created: / 20-02-2012 / 23:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1895
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   164
    "Modified (comment): / 16-12-2012 / 17:39:26 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   165
!
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
migrateClass
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   168
1376
c4b2cf1467c3 Fixes for Groovy and class reloading
vranyj1
parents: 1372
diff changeset
   169
    "/self error:'Not yet supported'
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   170
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   171
    "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
   172
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   173
1441
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   174
migrateInstance: object
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   175
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   176
    self assert: object class == oldClass.
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   177
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   178
    "Created: / 30-03-2012 / 19:42:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   179
!
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   180
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   181
migrateInstances
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   182
1441
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   183
    oldClass allInstancesDo:[:i|
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   184
        self migrateInstance:i.
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1376
diff changeset
   185
    ].
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   186
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   187
    "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
   188
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   189
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   190
prepare
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   191
    "Analyze and prepare data for reloading" 
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   192
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   193
    self prepareInstFieldMapping.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   194
    self prepareStaticFieldMapping.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   195
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   196
    "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
   197
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   198
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   199
prepareFieldMap: fields
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
    map := Dictionary new.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   203
    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
   204
    ^map
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   205
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   206
    "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
   207
!
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
prepareInstFieldMapping
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   210
    "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
   211
     Sets mustMigrateInstances"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   212
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   213
    | newFields |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   214
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   215
    mustMigrateInstances := false.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   216
    instFieldMapping := Set new.
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   217
    newFields := self prepareFieldMap: newClass allFields.
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   218
    oldClass fields do:[:old|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   219
        | new mapping |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   220
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   221
        new := newFields at: old name ifAbsent:[nil].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   222
        new notNil ifTrue:[ newFields removeKey: old name ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   223
        mapping := FieldMapping old: old new: new.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   224
        mustMigrateInstances := mustMigrateInstances or:[mapping mustMigrate].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   225
        instFieldMapping add: mapping.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   226
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   227
    "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
   228
     old class. Add them to the mapping"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   229
    newFields do:[:new|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   230
        instFieldMapping add: (FieldMapping old: nil new: new).
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   231
        mustMigrateInstances := true
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
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   234
    "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
   235
!
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
prepareStaticFieldMapping
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   238
    "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
   239
     Sets mustMigrateInstances"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   240
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   241
    | newFields |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   242
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   243
    mustMigrateClass := false.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   244
    staticFieldMapping := Set new.
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   245
    newFields := self prepareFieldMap: newClass allStaticFields.
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   246
    oldClass staticFields do:[:old|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   247
        | new mapping |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   248
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   249
        new := newFields at: old name ifAbsent:[nil].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   250
        new notNil ifTrue:[ newFields removeKey: old name ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   251
        mapping := FieldMapping old: old new: new.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   252
        mustMigrateClass:= mustMigrateClass or:[mapping mustMigrate].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   253
        staticFieldMapping add: mapping.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   254
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   255
    "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
   256
     old class. Add them to the mapping"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   257
    newFields do:[:new|
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   258
        staticFieldMapping add: (FieldMapping old: nil new: new).
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   259
        mustMigrateClass:= true
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
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   262
    "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
   263
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   264
1895
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   265
updateOldClass
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   266
    "at this point we know that both classes have same layout. So we can
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   267
     simply copy methods and other info from new class to old one. 
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   268
     References must be flushed anyway!!"
1372
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
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   271
1895
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   272
    oldClass setMethodDictionary: newClass methodDictionary.
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   273
    oldClass setConstantPool: newClass constantPool.
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   274
2d30e588124c added reloading tests and naive implementation
Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
parents: 1864
diff changeset
   275
    "Created: / 16-12-2012 / 17:36:52 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
1372
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
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   278
!JavaClassReloader::SingleClassReloader methodsFor:'reloading'!
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   279
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   280
reload
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   281
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   282
    self prepare.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   283
    self invalidate.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   284
    ^self migrate.
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
    "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
   287
!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   288
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   289
reload: oldClassA with: newClassA
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   290
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   291
    oldClass := oldClassA.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   292
    newClass := newClassA.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   293
    ^ self reload.
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
    "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
   296
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   297
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   298
!JavaClassReloader::SingleClassReloader::FieldMapping class methodsFor:'instance creation'!
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   299
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   300
old: old new:new
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   301
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   302
    ^self new old: old new: new.
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
    "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
   305
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   306
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   307
!JavaClassReloader::SingleClassReloader::FieldMapping methodsFor:'accessing'!
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   308
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   309
new
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   310
    ^ new
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
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   313
new:something
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   314
    new := something.
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
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   317
old
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   318
    ^ old
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
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   321
old:something
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   322
    old := something.
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
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   325
old:oldArg new:newArg 
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   326
    old := oldArg.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   327
    new := newArg.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   328
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   329
1453
f7a8861cdbe1 - added JavaMetaclass, GroovyMetaclass
vranyj1
parents: 1441
diff changeset
   330
!JavaClassReloader::SingleClassReloader::FieldMapping methodsFor:'queries'!
1372
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
mustMigrate
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   333
    "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
   334
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   335
    | oldD newD |
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   336
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   337
    (old isNil or:[new isNil]) ifTrue:[ 
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   338
        ^ true "Either one is missing, must migrate"
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
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   341
    old index ~~ new index ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   342
        ^true "Offsets changed, must migrate"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   343
    ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   344
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   345
    oldD := old descriptor.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   346
    newD := new descriptor.
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   347
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   348
    oldD = newD ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   349
        ^false"Same descriptor, the easy case"
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
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   352
    (oldD first == $L and: [newD first == $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
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   356
    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
   357
        ((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
   358
            ^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
   359
        ].
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   360
        ((oldD at: i) ~~ $[ or: [ (newD at: i) ~~ $[ ]) ifTrue:[
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   361
            ^true"Different primitive/array types, must migrate"
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   362
        ].
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
    ^false
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
    "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
   368
! !
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   369
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   370
!JavaClassReloader class methodsFor:'documentation'!
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   371
1864
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   372
version_HG
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   373
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   374
    ^ '$Changeset: <not expanded> $'
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   375
!
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   376
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   377
version_SVN
1864
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   378
    ^ '§Id§'
1372
dea574a1b6b3 Some initial class reloading support. Not yet finished, just sketched out.
vranyj1
parents:
diff changeset
   379
! !