Search in sources :

Example 31 with SharedClassHelperFactory

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

the class CustomURLClassLoaderNoAPIUse 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 32 with SharedClassHelperFactory

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

the class CustomPartitioningURLCL method getHelper.

public void getHelper(URL[] urls) throws HelperAlreadyDefinedException {
    SharedClassHelperFactory schFactory = Shared.getSharedClassHelperFactory();
    SharedClassURLClasspathHelper newHelper = null;
    newHelper = schFactory.getURLClasspathHelper(this, urls);
}
Also used : SharedClassHelperFactory(com.ibm.oti.shared.SharedClassHelperFactory) SharedClassURLClasspathHelper(com.ibm.oti.shared.SharedClassURLClasspathHelper)

Example 33 with SharedClassHelperFactory

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

the class FilterTester_2 method test2.

public boolean test2() {
    System.out.println("\nTest " + ++counter + ": Store Filter = Data");
    String testClassName = "sharedclasses.storefilter.resources.A_Main";
    URLClassPathCreator pathCreator = new URLClassPathCreator("./Resources/resources.jar");
    CustomURLClassLoader customURLCL = new CustomURLClassLoader(pathCreator.createURLClassPath());
    SharedClassHelperFactory schFactory = Shared.getSharedClassHelperFactory();
    SharedClassURLClasspathHelper newHelper;
    try {
        newHelper = schFactory.getURLClasspathHelper(customURLCL, pathCreator.createURLClassPath(), new StoreFilter("Data"));
        if (null == newHelper) {
            System.out.println("\t->newHelper is null.");
            return false;
        }
    } catch (HelperAlreadyDefinedException e) {
        System.out.println("\t->HelperAlreadyDefinedException is thrown.");
        return false;
    }
    try {
        Class c = Class.forName(testClassName, true, customURLCL);
        Method meth = c.getDeclaredMethod("run", new Class[0]);
        invokeMethod(c.newInstance(), "run", new Class[0]);
        /* Set the filter to null, 
			 * so there will be no filter to prevent some class names to be looked in shared cache.
			 * See SharedClassFilter#acceptFind 
			 */
        newHelper.setSharingFilter(null);
        if (customURLCL.isClassInSharedCache("sharedclasses.storefilter.resources.A_Main$Data")) {
            System.out.println("\nTEST FAILED - sharedclasses.storefilter.resources.A_Main$Data is in shared cache.");
            return false;
        }
        if (customURLCL.isClassInSharedCache("sharedclasses.storefilter.resources.B_Dummy$Data")) {
            System.out.println("\nTEST FAILED - sharedclasses.storefilter.resources.B_Dummy$Data is in shared cache.");
            return false;
        }
        if (customURLCL.isClassInSharedCache("sharedclasses.storefilter.resources.C_Dummy$Data")) {
            System.out.println("\nTEST FAILED - sharedclasses.storefilter.resources.C_Dummy$Data is in shared cache.");
            return false;
        }
        if (customURLCL.isClassInSharedCache("sharedclasses.storefilter.resources.D_Dummy$Data")) {
            System.out.println("\nTEST FAILED - sharedclasses.storefilter.resources.D_Dummy$Data is in shared cache.");
            return false;
        }
        if (!customURLCL.isClassInSharedCache("sharedclasses.storefilter.resources.A_Main")) {
            System.out.println("\nTEST FAILED - sharedclasses.storefilter.resources.A_Main is not in shared cache.");
            return false;
        }
        if (!customURLCL.isClassInSharedCache("sharedclasses.storefilter.resources.B_Dummy")) {
            System.out.println("\nTEST FAILED - sharedclasses.storefilter.resources.B_Dummy is not in shared cache.");
            return false;
        }
        if (!customURLCL.isClassInSharedCache("sharedclasses.storefilter.resources.C_Dummy")) {
            System.out.println("\nTEST FAILED - sharedclasses.storefilter.resources.C_Dummy is not in shared cache.");
            return false;
        }
        if (!customURLCL.isClassInSharedCache("sharedclasses.storefilter.resources.D_Dummy")) {
            System.out.println("\nTEST FAILED - sharedclasses.storefilter.resources.D_Dummy is not in shared cache.");
            return false;
        }
    } catch (Exception e2) {
        e2.printStackTrace();
        return false;
    }
    return true;
}
Also used : URLClassPathCreator(Utilities.URLClassPathCreator) HelperAlreadyDefinedException(com.ibm.oti.shared.HelperAlreadyDefinedException) SharedClassHelperFactory(com.ibm.oti.shared.SharedClassHelperFactory) SharedClassURLClasspathHelper(com.ibm.oti.shared.SharedClassURLClasspathHelper) Method(java.lang.reflect.Method) CustomURLClassLoader(CustomCLs.CustomURLClassLoader) HelperAlreadyDefinedException(com.ibm.oti.shared.HelperAlreadyDefinedException)

Example 34 with SharedClassHelperFactory

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

the class CustomTokenClassLoader method getHelper.

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

Example 35 with SharedClassHelperFactory

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

the class CustomTokenClassLoader method getURLClasspathHelper.

public void getURLClasspathHelper() throws HelperAlreadyDefinedException {
    SharedClassHelperFactory schFactory = Shared.getSharedClassHelperFactory();
    SharedClassURLClasspathHelper newHelper = null;
    newHelper = schFactory.getURLClasspathHelper(this, urls);
}
Also used : SharedClassHelperFactory(com.ibm.oti.shared.SharedClassHelperFactory) SharedClassURLClasspathHelper(com.ibm.oti.shared.SharedClassURLClasspathHelper)

Aggregations

SharedClassHelperFactory (com.ibm.oti.shared.SharedClassHelperFactory)53 SharedClassURLClasspathHelper (com.ibm.oti.shared.SharedClassURLClasspathHelper)25 HelperAlreadyDefinedException (com.ibm.oti.shared.HelperAlreadyDefinedException)17 SharedClassTokenHelper (com.ibm.oti.shared.SharedClassTokenHelper)14 SharedClassURLHelper (com.ibm.oti.shared.SharedClassURLHelper)14 IOException (java.io.IOException)6 MalformedURLException (java.net.MalformedURLException)6 CustomURLClassLoader (CustomCLs.CustomURLClassLoader)3 URLClassPathCreator (Utilities.URLClassPathCreator)3 Method (java.lang.reflect.Method)3 CannotSetClasspathException (com.ibm.oti.shared.CannotSetClasspathException)1