private void definePackageIfNeeded(String name) {
    int lastDotIndex = name.lastIndexOf('.');
    if (lastDotIndex == -1) {
      return;
    }

    String packageName = name.substring(0, lastDotIndex);
    // check if the package is already loaded
    if (isPackageDefined(packageName)) {
      return;
    }

    try {
      definePackage(packageName, null, null, null, null, null, null, null);
    }
    catch (IllegalArgumentException ignore) {
      // do nothing, the package is already defined by another thread
    }
  }
private void definePackageIfNeeded(String name)