Skip to content

Instantly share code, notes, and snippets.

@rseitz
rseitz / PackagePrivateMethodCallAcrossClassLoaders.java
Created January 2, 2024 21:35
Demononstrate IllegalAccessError that occurs when a package-private method is invoked across two different classloaders
package org.example;
import java.lang.reflect.Method;
import org.apache.commons.io.IOUtils;
/**
* Large Java systems often include a plugin framework that allows a developer to
* contribute new functionality by packaging custom code as a JAR that is installed and run
* inside the primary system. The code for a plugin often exists in its own dedicated codebase,
* referencing the primary codebase as a dependency.