Search in sources :

Example 11 with SharedClassURLHelper

use of com.ibm.oti.shared.SharedClassURLHelper in project openj9 by eclipse.

the class CustomPartitioningURLLoader method getHelper.

public boolean getHelper() {
    SharedClassHelperFactory schFactory = Shared.getSharedClassHelperFactory();
    SharedClassURLHelper newHelper = null;
    try {
        newHelper = schFactory.getURLHelper(this);
    } catch (Exception e) {
        return false;
    }
    if (newHelper.equals(scHelper)) {
        return true;
    } else {
        return false;
    }
}
Also used : SharedClassURLHelper(com.ibm.oti.shared.SharedClassURLHelper) SharedClassHelperFactory(com.ibm.oti.shared.SharedClassHelperFactory) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) HelperAlreadyDefinedException(com.ibm.oti.shared.HelperAlreadyDefinedException)

Example 12 with SharedClassURLHelper

use of com.ibm.oti.shared.SharedClassURLHelper in project openj9 by eclipse.

the class CustomTokenClassLoader method getURLHelper.

public void getURLHelper() throws Exception {
    SharedClassHelperFactory schFactory = Shared.getSharedClassHelperFactory();
    SharedClassURLHelper newHelper = null;
    newHelper = schFactory.getURLHelper(this);
}
Also used : SharedClassURLHelper(com.ibm.oti.shared.SharedClassURLHelper) SharedClassHelperFactory(com.ibm.oti.shared.SharedClassHelperFactory)

Example 13 with SharedClassURLHelper

use of com.ibm.oti.shared.SharedClassURLHelper in project openj9 by eclipse.

the class CDSHookImpls method addClassPathEntry.

public boolean addClassPathEntry(ArrayList cpEntries, String cp, ClasspathManager hostmanager, Generation sourceGeneration) {
    CDSBundleFile hostFile = getCDSBundleFile(hostmanager.getGeneration().getBundleFile());
    CDSBundleFile sourceFile = getCDSBundleFile(sourceGeneration.getBundleFile());
    if ((hostFile != sourceFile) && (null != hostFile) && (null != sourceFile)) {
        // set the helper that got set on the host base bundle file in initializedClassLoader
        SharedClassURLHelper urlHelper = hostFile.getURLHelper();
        sourceFile.setURLHelper(urlHelper);
    }
    return false;
}
Also used : SharedClassURLHelper(com.ibm.oti.shared.SharedClassURLHelper)

Example 14 with SharedClassURLHelper

use of com.ibm.oti.shared.SharedClassURLHelper in project openj9 by eclipse.

the class CDSHookImpls method recordClassDefine.

public void recordClassDefine(String name, Class clazz, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager) {
    // 4) class bytes is same as passed to weaving hook i.e. weaving hook did not modify the class bytes
    if ((null == clazz) || (false == hasMagicClassNumber(classbytes)) || (null == getCDSBundleFile(classpathEntry.getBundleFile()))) {
        return;
    }
    try {
        // check if weaving hook modified the class bytes
        byte[] originalClassBytes = entry.getBytes();
        if (originalClassBytes != classbytes) {
            // weaving hook has potentially modified the class bytes
            boolean modified = false;
            if (originalClassBytes.length == classbytes.length) {
                // do a byte-by-byte comparison
                modified = !Arrays.equals(classbytes, originalClassBytes);
            } else {
                modified = true;
            }
            if (modified) {
                // Such classes need to be stored as Orphans, so skip the call to storeSharedClass()
                return;
            }
        }
    } catch (IOException e) {
        // this should never happen, but in case it does, its safe to return
        return;
    }
    CDSBundleFile cdsFile = getCDSBundleFile(classpathEntry.getBundleFile());
    if (null == cdsFile.getURL()) {
        // something went wrong trying to determine the url to the real bundle file
        return;
    }
    // look for the urlHelper; if it does not exist then we are not sharing for this class loader
    SharedClassURLHelper urlHelper = cdsFile.getURLHelper();
    if (urlHelper == null) {
        // this should never happen but just in case get the helper from the base host bundle file.
        CDSBundleFile hostBundleFile = getCDSBundleFile(manager.getGeneration().getBundleFile());
        if (null != hostBundleFile) {
            // try getting the helper from the host base cdsFile
            urlHelper = hostBundleFile.getURLHelper();
        }
        if (null != urlHelper) {
            cdsFile.setURLHelper(urlHelper);
        }
    }
    if (null != urlHelper) {
        // store the class in the cache
        urlHelper.storeSharedClass(cdsFile.getURL(), clazz);
        cdsFile.setPrimed(true);
    }
}
Also used : SharedClassURLHelper(com.ibm.oti.shared.SharedClassURLHelper) IOException(java.io.IOException)

Example 15 with SharedClassURLHelper

use of com.ibm.oti.shared.SharedClassURLHelper in project openj9 by eclipse.

the class CustomURLLoader method getHelper.

public boolean getHelper() {
    SharedClassHelperFactory schFactory = Shared.getSharedClassHelperFactory();
    SharedClassURLHelper newHelper = null;
    try {
        newHelper = schFactory.getURLHelper(this);
    } catch (Exception e) {
        return false;
    }
    if (newHelper.equals(scHelper)) {
        return true;
    } else {
        return false;
    }
}
Also used : SharedClassURLHelper(com.ibm.oti.shared.SharedClassURLHelper) SharedClassHelperFactory(com.ibm.oti.shared.SharedClassHelperFactory) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) HelperAlreadyDefinedException(com.ibm.oti.shared.HelperAlreadyDefinedException)

Aggregations

SharedClassURLHelper (com.ibm.oti.shared.SharedClassURLHelper)18 SharedClassHelperFactory (com.ibm.oti.shared.SharedClassHelperFactory)14 HelperAlreadyDefinedException (com.ibm.oti.shared.HelperAlreadyDefinedException)5 IOException (java.io.IOException)5 MalformedURLException (java.net.MalformedURLException)4 BundleFile (org.eclipse.osgi.storage.bundlefile.BundleFile)1