public static Class<?> tryDefineClassesInClassLoader(
      String className, Class<?> neighbor, ClassLoader classLoader, byte[] bytecode) {
    ProtectionDomain domain =
        neighbor != null
            ? neighbor.getProtectionDomain()
            : classLoader.getClass().getProtectionDomain();
    return tryDefineClassesInClassLoader(className, neighbor, classLoader, domain, bytecode);
  }
@Test(dataProvider = "packages")
  public void testTryDefineClassesInClassLoader(String pkg) {
    String classname = String.format("A%d", System.currentTimeMillis());
    String classCode =
        String.format(
            ""
                + "package %s;\n"
                + "public final class %s implements java.io.Serializable {\n"
                + "  public int f1;\n"
                + "  public long f2;\n"
                + "}",
            pkg, classname);
    byte[] bytes =
        JaninoUtils.toBytecode(
                getClass().getClassLoader(), new CompileUnit(pkg, classname, classCode))
            .values()
            .iterator()
            .next();
    if (ClassLoaderUtils.class.getPackage().getName().equals(pkg)) {
      Class<?> cls =
          ClassLoaderUtils.tryDefineClassesInClassLoader(
              pkg + "." + classname,
              ClassLoaderUtils.class,
              ClassLoaderUtils.class.getClassLoader(),
              bytes);
      Assert.assertNotNull(cls);
      Assert.assertEquals(cls.getSimpleName(), classname);
    } else {
      Class<?> cls =
          ClassLoaderUtils.tryDefineClassesInClassLoader(
              pkg + "." + classname, null, getClass().getClassLoader(), bytes);
      Assert.assertNotNull(cls);
    }
  }