Libraryless. Click here for Pure Java version (10349L/58K).
1 | // takes ~70 ms to set up, do it only once if possible |
2 | sclass ClassNameResolver { |
3 | settable File byteCodePath = byteCodePathForClass(getClass()); |
4 | LS importedPackages = itemPlusList("java.lang", |
5 | endingWith_dropSuffix(standardImports(), ".*")); |
6 | |
7 | simplyCached Set<S> allFullyQualifiedClassNames() { |
8 | new Set<S> set; |
9 | assertNotNull(byteCodePath); |
10 | set.addAll(classNamesInJarOrDir(byteCodePath)); |
11 | printVars ClassNameResolver(+byteCodePath, classesFound := l(set)); |
12 | set.addAll(classNamesInLoadedJigsawModules()); |
13 | ret set; |
14 | } |
15 | |
16 | selfType init() { allFullyQualifiedClassNames(); this; } |
17 | |
18 | S findClass(S name) { |
19 | for (S pkg : importedPackages) { |
20 | S fullName = pkg + "." + name; |
21 | if (allFullyQualifiedClassNames().contains(fullName)) |
22 | ret fullName; |
23 | } |
24 | null; |
25 | } |
26 | |
27 | void printMe { |
28 | printVars("ClassNameResolver", +byteCodePath); |
29 | print(+importedPackages); |
30 | } |
31 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034226 |
Snippet name: | ClassNameResolver |
Eternal ID of this version: | #1034226/11 |
Text MD5: | c161cf6053a9819e3162ae8d6bc88bdd |
Transpilation MD5: | d4cd33f85540feb3745d4697459139cc |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-29 07:44:16 |
Source code size: | 951 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 223 / 388 |
Version history: | 10 change(s) |
Referenced in: | [show references] |