use of CustomClassloaders.CustomPartitioningURLClassLoader in project openj9 by eclipse.
the class PartitioningURLClassPathHelperURLHelperStaleEntryCompatabilityTest method executeTest.
private boolean executeTest(String classPath, String partition, String[] classesToLoad, String[] urls, String[] partitionStrings, String[][] classesToFind, String[][] results, String batchFile, String javacpath) {
URLClassPathCreator creator = new URLClassPathCreator(classPath);
URL[] urlPath;
urlPath = creator.createURLClassPath();
CustomPartitioningURLClassLoader cl = new CustomPartitioningURLClassLoader(urlPath, this.getClass().getClassLoader());
cl.setPartition(partition);
for (int classIndex = 0; classIndex < classesToLoad.length; classIndex++) {
String classToLoad = classesToLoad[classIndex];
if (classToLoad != null) {
try {
cl.loadClass(classToLoad);
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (0 != batchFile.length()) {
runBatchFile(batchFile, javacpath);
}
String urlsString = urls[0];
for (int index = 1; index < urls.length; index++) {
urlsString = new StringBuffer(urls[index].length() + 1).append(urlsString).append(urls[index]).toString();
}
URLClassPathCreator creator2 = new URLClassPathCreator(urlsString);
URL[] urlPath2;
urlPath2 = creator2.createURLClassPath();
CustomPartitioningURLLoader urlcl = new CustomPartitioningURLLoader(urlPath2, this.getClass().getClassLoader());
boolean result = true;
for (int urlIndex = 0; urlIndex < urls.length; urlIndex++) {
urlcl.setPartition(partitionStrings[urlIndex]);
for (int classIndex = 0; classIndex < classesToFind[urlIndex].length; classIndex++) {
String classToFind = classesToFind[urlIndex][classIndex];
String expectedResult = results[urlIndex][classIndex];
if (classToFind != null) {
String testResult = String.valueOf(urlcl.isClassInSharedCache(urlIndex, classToFind));
if (!(expectedResult.equals(testResult))) {
System.out.println("\nFailure finding class: " + classToFind + " on path: " + urls[urlIndex] + " which is index: " + urlIndex + " result: " + testResult + " expecting: " + expectedResult);
result = false;
}
}
}
}
return result;
}
use of CustomClassloaders.CustomPartitioningURLClassLoader in project openj9 by eclipse.
the class PartitioningURLHelperURLClassPathHelperStaleEntryCompatabilityTest method executeTest.
private boolean executeTest(String[] urls, String[] partitionStrings, String[][] classesToLoad, String classPath, String partition, String[] classesToFind, String[] results, String batchFile, String[] foundAt, String javacpath) {
String urlsString = urls[0];
for (int index = 1; index < urls.length; index++) {
urlsString = new StringBuffer(urls[index].length() + 1).append(urlsString).append(urls[index]).append(File.pathSeparatorChar).toString();
}
System.out.println("\n** urlsString: " + urlsString);
URLClassPathCreator creator = new URLClassPathCreator(urlsString);
URL[] urlPath;
urlPath = creator.createURLClassPath();
CustomPartitioningURLLoader[] loaderArray = new CustomPartitioningURLLoader[urls.length];
for (int urlIndex = 0; urlIndex < urls.length; urlIndex++) {
loaderArray[urlIndex] = new CustomPartitioningURLLoader(urlPath, this.getClass().getClassLoader());
loaderArray[urlIndex].setPartition(partitionStrings[urlIndex]);
for (int classIndex = 0; classIndex < classesToLoad[urlIndex].length; classIndex++) {
String classToLoad = classesToLoad[urlIndex][classIndex];
if (classToLoad != null) {
loaderArray[urlIndex].loadClassFrom(classToLoad, urlIndex);
}
}
}
if (0 != batchFile.length()) {
runBatchFile(batchFile, javacpath);
}
boolean result = true;
URLClassPathCreator creator2 = new URLClassPathCreator(classPath);
URL[] urlPath2;
urlPath2 = creator2.createURLClassPath();
CustomPartitioningURLClassLoader cl = new CustomPartitioningURLClassLoader(urlPath2, this.getClass().getClassLoader());
cl.setPartition(partition);
for (int classIndex = 0; classIndex < classesToLoad.length; classIndex++) {
String classToFind = classesToFind[classIndex];
String expectedResult = results[classIndex];
if (classToFind != null) {
String testResult = String.valueOf(cl.isClassInSharedCache(classToFind));
if (!(expectedResult.equals(testResult))) {
System.out.println("\nFailure finding class: " + classToFind + " result: " + testResult + " expecting: " + expectedResult);
result = false;
} else {
if (testResult.equals("true")) {
result = validateReturnedClass(classToFind, foundAt[classIndex], cl);
}
}
}
}
return result;
}
Aggregations