[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 
[node8-android] Instantiation of JavaObjects
Description of the algorithm used to instantiate wrappers to native objects in node8-android.
JavaObject class>>#@
Global resources: 
-  #ClassMap: Java class name -> s8 supporting class, mapping
 
Local resources: 
-  #cachedInstance: property of handle where supporting s8 class is cached
 -  delegationChain: a collection of all Java superclass names ordered from (handle #getClass #getName) to java.lang.Object), where aClassName is before than anotherClassName if aClassName is more concrete than anotherClassName
 
Algorithm
- if handle is nil then ^nil
 - if (isObject: handle) then ^handle
 - if (typeOf: handle#hashCode = 'undefined') then ^PoolDictionary @ handle
 - if handle has a hashCode
- then 
- if handle has #cachedInstance then ^aClass at handle#cachedInstance cache
 
 - else
- choices := delegationChain removeLast ("exclude java.lang.Object")
 - foundClass := nil
 - for each javaClassName in choices do:
- if ClassMap includesKey: javaClassName 
- then foundClass := ClassMap at: javaClassName
 - else
- for each subclass of self do:
- if (subclass javaFullName = javaClassName)
- then 
- foundClass := subclass
 - break
 
 
 
 - end loop
 
 
 - foundClass notNil 
- then
- ClassMap at: javaClassName put: foundClass. ("put found in ClassMap for next search")
 - wrapper := foundClass basicNew: handle.
 - put wrapper in handle#chachedInstance
 - ^wrapper
 
 
 
 - end loop
 - ^" Missing s8 support for handle "