// Load the bytecode
byte[] byteCode = ClassLoaderUtils.loadByteCode(name, is);
// Let the policy do things before we define the class
BaseClassLoaderPolicy basePolicy = policy;
ProtectionDomain protectionDomain = basePolicy.getProtectionDomain(name, resourcePath);
try
{
byte[] transformed = policy.transform(name, byteCode, protectionDomain);
if (transformed != null)
byteCode = transformed;
}
catch (Throwable t)
{
throw new RuntimeException("Unexpected error transforming class " + name, t);
}
// Create the package if necessary
URL codeSourceURL = null;
if (protectionDomain != null)
{
CodeSource codeSource = protectionDomain.getCodeSource();
if (codeSource != null)
codeSourceURL = codeSource.getLocation();
}
definePackage(name, codeSourceURL);