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

17
LINES

< > BotCompany Repo | #1035085 // getDeclaredConstructors_cached - also calls setAccessible(true) on all constructors

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

Libraryless. Click here for Pure Java version (7652L/43K).

scope getDeclaredConstructors_cached

// TODO: convert to regularly cleared normal map
static Map<Class, Constructor[]> #cache = newDangerousWeakHashMap();

static Constructor[] getDeclaredConstructors_cached(Class c) {
  Constructor[] ctors;
  synchronized(cache) {
    ctors = cache.get(c);
    if (ctors == null) {
      cache.put(c, ctors = c.getDeclaredConstructors());
      for (ctor : ctors)
        makeAccessible(ctor);
    }
  }
  ret ctors;
}

Author comment

Began life as a copy of #1005587

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035085
Snippet name: getDeclaredConstructors_cached - also calls setAccessible(true) on all constructors
Eternal ID of this version: #1035085/3
Text MD5: 70872e836c20d8a7a31f2b33e5c4013a
Transpilation MD5: fe17949d12bb1f144343936e5a56fe68
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-02 18:06:40
Source code size: 470 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 161 / 235
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)