public static boolean defineAccessorClass(Class<?> beanClass) {
    ClassLoader classLoader = beanClass.getClassLoader();
    if (classLoader == null) {
      // Maybe return null if this class was loaded by the bootstrap class loader.
      return false;
    }
    String qualifiedClassName = qualifiedAccessorClassName(beanClass);
    try {
      classLoader.loadClass(qualifiedClassName);
      return true;
    } catch (ClassNotFoundException ignored) {
      Object lock;
      synchronized (defineLock) {
        if (defineAccessorStatus.containsKey(beanClass)) {
          return defineAccessorStatus.get(beanClass);
        } else {
          lock = getDefineLock(beanClass);
        }
      }
      synchronized (lock) {
        if (defineAccessorStatus.containsKey(beanClass)) {
          return defineAccessorStatus.get(beanClass);
        }
        long startTime = System.nanoTime();
        String code = genCode(beanClass);
        long durationMs = (System.nanoTime() - startTime) / 1000_000;
        LOG.info("Generate code {} take {} ms", qualifiedClassName, durationMs);
        String pkg = CodeGenerator.getPackage(beanClass);
        CompileUnit compileUnit = new CompileUnit(pkg, accessorClassName(beanClass), code);
        Map<String, byte[]> classByteCodes = JaninoUtils.toBytecode(classLoader, compileUnit);
        boolean succeed =
            ClassLoaderUtils.tryDefineClassesInClassLoader(
                    qualifiedClassName,
                    beanClass,
                    classLoader,
                    classByteCodes.values().iterator().next())
                != null;
        defineAccessorStatus.put(beanClass, succeed);
        if (!succeed) {
          LOG.info("Define accessor {} in classloader {} failed.", qualifiedClassName, classLoader);
        }
        return succeed;
      }
    }
  }
@Test
  public void testJavaxPackage() {
    assertTrue(AccessorHelper.defineAccessorClass(Accessor.class));
  }