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

19
LINES

< > BotCompany Repo | #1020753 // findClass_fullName

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

Libraryless. Click here for Pure Java version (44L/1K).

1  
static new HashMap<S, Class> findClass_fullName_cache;
2  
3  
// returns null on not found
4  
// this is the simple version that is not case-tolerant
5  
static Class findClass_fullName(String name) {
6  
  synchronized(findClass_fullName_cache) {
7  
    if (findClass_fullName_cache.containsKey(name))
8  
      ret findClass_fullName_cache.get(name);
9  
      
10  
    Class c;
11  
    try {
12  
      c = Class.forName(name);
13  
    } catch (ClassNotFoundException e) {
14  
      c = null;
15  
    }
16  
    findClass_fullName_cache.put(name, c);
17  
    ret c;
18  
  }
19  
}

Author comment

Began life as a copy of #1001137

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020753
Snippet name: findClass_fullName
Eternal ID of this version: #1020753/3
Text MD5: 9d29dc8725b7aebf38a812916ecdf7a4
Transpilation MD5: 5ee737f4baa43a1131aab24021546b62
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-01 19:38:05
Source code size: 530 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 308 / 379
Version history: 2 change(s)
Referenced in: [show references]