use of com.ibm.oti.shared.HelperAlreadyDefinedException 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;
}
use of com.ibm.oti.shared.HelperAlreadyDefinedException in project openj9 by eclipse.
the class CustomPartitioningURLClassLoader method getHelper.
public boolean getHelper() {
SharedClassHelperFactory schFactory = Shared.getSharedClassHelperFactory();
SharedClassURLClasspathHelper newHelper = null;
try {
newHelper = schFactory.getURLClasspathHelper(this, orgUrls);
} catch (HelperAlreadyDefinedException e) {
return false;
}
if (newHelper.equals(scHelper)) {
return true;
} else {
return false;
}
}
use of com.ibm.oti.shared.HelperAlreadyDefinedException in project openj9 by eclipse.
the class CDSHookImpls method classLoaderCreated.
public void classLoaderCreated(ModuleClassLoader classLoader) {
// try to get the url helper for this class loader
if (factory == null) {
return;
}
CDSBundleFile hostFile = null;
try {
SharedClassURLHelper urlHelper = factory.getURLHelper(classLoader);
boolean minimizeSucceeded = runMinimizeMethod(urlHelper);
// set the url helper for the host base CDSBundleFile
hostFile = getCDSBundleFile(classLoader.getClasspathManager().getGeneration().getBundleFile());
if (hostFile != null) {
hostFile.setURLHelper(urlHelper);
if (minimizeSucceeded) {
/* In Java6, there is no longer a requirement to "prime" plugins */
hostFile.setPrimed(true);
}
}
} catch (HelperAlreadyDefinedException e) {
// We should never get here.
// If we do, we simply won't share for this ClassLoader
}
}
use of com.ibm.oti.shared.HelperAlreadyDefinedException in project openj9 by eclipse.
the class FilterTester_1 method test1.
public boolean test1() {
System.out.println("\nTest " + ++counter + ": Store Filter = A_Main");
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("A_Main"));
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 someclass names to be looked in shared cache.
* See SharedClassFilter#acceptFind */
newHelper.setSharingFilter(null);
if (customURLCL.isClassInSharedCache("sharedclasses.storefilter.resources.A_Main")) {
System.out.println("\nTEST FAILED - sharedclasses.storefilter.resources.A_Main is 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;
}
use of com.ibm.oti.shared.HelperAlreadyDefinedException in project openj9 by eclipse.
the class FilterTester_3 method test3.
public boolean test3() {
System.out.println("\nTest " + ++counter + ": Store Filter = C_Dummy$Data. Verify shared classpath helper methods.");
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("C_Dummy$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 not 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 not 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 not 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;
}
newHelper.setSharingFilter(new StoreFilter("C_Dummy"));
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 (null != newHelper.getSharingFilter()) {
System.out.println("\nTEST FAILED - Shared Filter is not null");
return false;
}
if (newHelper.getClassLoader() != customURLCL) {
System.out.println("\nTEST FAILED - Wrong classloader in shared classpath helper");
return false;
}
newHelper.confirmAllEntries();
try {
newHelper.setClasspath(new URL[0]);
System.out.println("\nTEST FAILED - Shared classpath helper can set new classpath after confirming all entries. ");
return false;
} catch (CannotSetClasspathException e) {
/* Expected */
}
} catch (Exception e2) {
e2.printStackTrace();
return false;
}
return true;
}
Aggregations