Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

44
LINES

< > BotCompany Repo | #1035084 // ResolvableLASClass (is an implementation of Type)

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (31176L) is out of date.

persistable sclass ResolvableLASClass is IResolvableClass {
  transient ILASClassLoader lasClassLoader;
  LASClassDef classDef;

  *(ILASClassLoader *lasClassLoader, LASClassDef *classDef) {}
  
  public S resolveToClassName() {
    ret classDef.finalClassName();
  }
  
  Class resolvedClass() {
    ret classDef.resolvedClass;
  }
  
  public Class get aka resolveToClass() {
    if (resolvedClass() == null) {
      if (lasClassLoader == null)
        fail("Need LASClassLoader to define " + classDef.userGivenName);
      Class resolvedClass = lasClassLoader.defineLASClass(classDef.finalClassName(),
        -> classDef.toBytes());
        
      // set resolvedClass & init static fields
      classDef.init(resolvedClass);
    }
    
    ret resolvedClass();
  }
  
  // This function is very defensive (doesn't resolve anything)
  toString {
    if (resolvedClass() != null)
      ret className(resolvedClass());
    
    try object userGivenName();
    
    if (classDef.classHash_cache != null)
      ret classDef.finalClassNameWithoutPrefix();
      
    ret or2(userGivenName(), "script-defined class")
      + " [unresolved]";
  }
  
  S userGivenName() { ret classDef.userGivenName; }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035084
Snippet name: ResolvableLASClass (is an implementation of Type)
Eternal ID of this version: #1035084/18
Text MD5: 1c9ef75a9316f28ae5d4190fe7a48c92
Author: stefan
Category: javax / left arrow script
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-04-29 23:53:25
Source code size: 1243 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 215 / 362
Version history: 17 change(s)
Referenced in: [show references]