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).

static new HashMap<S, Class> findClass_fullName_cache;

// returns null on not found
// this is the simple version that is not case-tolerant
static Class findClass_fullName(String name) {
  synchronized(findClass_fullName_cache) {
    if (findClass_fullName_cache.containsKey(name))
      ret findClass_fullName_cache.get(name);
      
    Class c;
    try {
      c = Class.forName(name);
    } catch (ClassNotFoundException e) {
      c = null;
    }
    findClass_fullName_cache.put(name, c);
    ret c;
  }
}

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: 357 / 446
Version history: 2 change(s)
Referenced in: [show references]