Search in sources :

Example 16 with IAvmResourceFactory

use of org.aion.avm.stub.IAvmResourceFactory in project aion by aionnetwork.

the class AvmResourcesVersion2 method loadAvmResourceFactory.

/**
 * Uses the provided classloader to load a new instance of {@link IAvmResourceFactory} defined
 * in the avm version 2 module.
 */
private static IAvmResourceFactory loadAvmResourceFactory(URLClassLoader classLoader) throws IllegalAccessException, InstantiationException, ClassNotFoundException, IOException {
    Class<?> factory = classLoader.loadClass(AvmDependencyInfo.avmResourceFactoryClassNameVersion2);
    IAvmResourceFactory resourceFactory = (IAvmResourceFactory) factory.newInstance();
    // Verify that the resources were loaded by the correct classloader.
    ClassLoader resourceClassloader = resourceFactory.verifyAndReturnClassloader();
    if (resourceClassloader != classLoader) {
        classLoader.close();
        throw new IllegalStateException("The avm resources were loaded using the wrong classloader: " + resourceClassloader);
    }
    return resourceFactory;
}
Also used : IAvmResourceFactory(org.aion.avm.stub.IAvmResourceFactory) URLClassLoader(java.net.URLClassLoader)

Aggregations

IAvmResourceFactory (org.aion.avm.stub.IAvmResourceFactory)16 AionTransaction (org.aion.base.AionTransaction)9 URLClassLoader (java.net.URLClassLoader)6 AionTxReceipt (org.aion.base.AionTxReceipt)5 AionBlockSummary (org.aion.zero.impl.types.AionBlockSummary)5 MiningBlock (org.aion.zero.impl.types.MiningBlock)5 Test (org.junit.Test)5 AionAddress (org.aion.types.AionAddress)4 ImportResult (org.aion.zero.impl.core.ImportResult)4 BigInteger (java.math.BigInteger)3 TestResourceProvider (org.aion.zero.impl.vm.TestResourceProvider)3 AvmVersion (org.aion.avm.stub.AvmVersion)2 ArrayList (java.util.ArrayList)1 RepositoryCache (org.aion.base.db.RepositoryCache)1 ECKey (org.aion.crypto.ECKey)1 AionRepositoryCache (org.aion.zero.impl.db.AionRepositoryCache)1 ContractInformation (org.aion.zero.impl.db.ContractInformation)1 MiningBlockHeader (org.aion.zero.impl.types.MiningBlockHeader)1 VmFatalException (org.aion.zero.impl.vm.common.VmFatalException)1