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

20
LINES

< > BotCompany Repo | #1030720 // unstructureClassFinderAllowingCertainClasses_preferUtils

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

Libraryless. Click here for Pure Java version (2735L/16K).

sO unstructureClassFinderAllowingCertainClasses_preferUtils(bool failOnUnknownClass default true, S... allowedClasses) {
  new Set<S> allowedClassesSet;
  fOr (S name : allowedClasses) {
    allowedClassesSet.add("main$" + name);
    allowedClassesSet.add("loadableUtils.utils$" + name);
  }
  ret func(S name) {
    if (!allowedClassesSet.contains(name))
      if (failOnUnknownClass)
        fail("Class not allowed to unstructure: " + name);
      else
        null;
    if (name.startsWith("main$")) {
      S name2 = "loadableUtils.utils$" + substring(name, 5);
      Class c = classForNameOpt(name2);
      if (c != null) ret c;
    }
    ret classForNameOpt(name);
  };
}

Author comment

Began life as a copy of #1024784

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030720
Snippet name: unstructureClassFinderAllowingCertainClasses_preferUtils
Eternal ID of this version: #1030720/4
Text MD5: 6b4b5b6e121190e8d4cba96e4d13c82e
Transpilation MD5: cf4ba035bb1684aa8d291524fd862e47
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-03-16 17:25:55
Source code size: 697 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 106 / 156
Version history: 3 change(s)
Referenced in: [show references]