Skip to content

Commit

Permalink
Merge pull request #1686 from embulk/load-class-in-PluginClassLoader
Browse files Browse the repository at this point in the history
Add PluginClassLoader#loadClassInThisClassLoader, for internal use
  • Loading branch information
dmikurube authored Sep 12, 2024
2 parents ea1e0bc + 10eeb94 commit f2f41db
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions embulk-core/src/main/java/org/embulk/plugin/PluginClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,29 @@ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundE
}
}

/**
* Loads the class with the specified binary name, forcibly in this {@code PluginClassLoader}, never in the parent class loader.
*
* @param name The binary name of the class
* @param resolve If true then resolve the class
* @return The resulting Class object
* @throws ClassNotFoundException If the class could not be found
*
* @deprecated Do not use this method. This method is only for internal use by Embulk's own testing framework.
*/
@Deprecated
public Class<?> loadClassInThisClassLoader(final String name, final boolean resolve) throws ClassNotFoundException {
synchronized (this.getClassLoadingLock(name)) {
final Class<?> loadedClass = this.findLoadedClass(name);

if (loadedClass != null) {
return this.resolveClass(loadedClass, resolve);
}

return this.resolveClass(this.findClass(name), resolve);
}
}

private Class<?> resolveClass(Class<?> clazz, boolean resolve) {
if (resolve) {
resolveClass(clazz);
Expand Down

0 comments on commit f2f41db

Please sign in to comment.