use of java.lang.ClassNotFoundException in project openj9 by eclipse.
the class Test_Class method test_forName.
/**
* @tests java.lang.Class#forName(java.lang.String)
* @tests java.lang.Class#forName(java.lang.Module, java.lang.String)
*/
@Test
public void test_forName() {
try {
// package java.rmi exported by module java.rmi
Class<?> jrAccessExceptionClz = Class.forName("java.rmi.AccessException");
AssertJUnit.assertNotNull(jrAccessExceptionClz);
if (!jrAccessExceptionClz.getProtectionDomain().implies(ALL_PERMISSION)) {
AssertJUnit.fail("java.rmi.AccessException should have all permission!");
}
Module jrModule = jrAccessExceptionClz.getModule();
Class<?> jrAlreadyBoundExceptionClz = Class.forName(jrModule, "java.rmi.AlreadyBoundException");
if ((jrAlreadyBoundExceptionClz == null) || !jrAlreadyBoundExceptionClz.getProtectionDomain().implies(ALL_PERMISSION)) {
AssertJUnit.fail("java.rmi.AlreadyBoundException should have all permission as well!");
}
} catch (ClassNotFoundException e) {
AssertJUnit.fail("Unexpected ClassNotFoundException: " + e.getMessage());
}
}
use of java.lang.ClassNotFoundException in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DimmableIZatIconPreference method load.
private static void load(Context context) {
if (mLoader == null) {
try {
if (mXtProxyClz == null || mNotifierClz == null) {
mLoader = new DexClassLoader("/system/framework/izat.xt.srv.jar", context.getFilesDir().getAbsolutePath(), null, ClassLoader.getSystemClassLoader());
mXtProxyClz = Class.forName("com.qti.izat.XTProxy", true, mLoader);
mNotifierClz = Class.forName("com.qti.izat.XTProxy$Notifier", true, mLoader);
mIzatPackage = (String) mXtProxyClz.getField("IZAT_XT_PACKAGE").get(null);
mGetXtProxyMethod = mXtProxyClz.getMethod("getXTProxy", Context.class, mNotifierClz);
mGetConsentMethod = mXtProxyClz.getMethod("getUserConsent");
mShowIzatMethod = mXtProxyClz.getMethod("showIzat", Context.class, String.class);
}
} catch (NoSuchMethodException | NullPointerException | SecurityException | NoSuchFieldException | LinkageError | IllegalAccessException | ClassNotFoundException e) {
mXtProxyClz = null;
mNotifierClz = null;
mIzatPackage = null;
mGetXtProxyMethod = null;
mGetConsentMethod = null;
mShowIzatMethod = null;
e.printStackTrace();
}
}
}
use of java.lang.ClassNotFoundException in project derby by apache.
the class RunList method shouldSkipTest.
/**
* Determine if a test should be skipped or not.
* These are ad-hoc rules, see comments within for details.
* Examples of what is checked: JVM version, framework,
* encryption, jdk12test,
* Sets some global variables so that skip reporting is clearer.
*
* @return true if test should not be run.
*/
private static boolean shouldSkipTest() {
boolean result = false;
// figure out if suite should be skipped ... adhoc rules
// really now 'isJdk12orHigher'
boolean isJdk12 = false;
boolean isJdk118 = false;
boolean isJdk117 = false;
boolean isEncryption = false;
boolean isJdk12Test = false;
boolean isJdk12ExtTest = false;
boolean isSyncTest = false;
boolean isSyncProduct = false;
boolean isExcludeJCC = false;
// runwithibmjvm is really tri-state. null = run-anywhere,
// true = only ibm jvms, false = only non-IBM jvms.
// reset skip reason parameters
driverNotFound = false;
needSync = false;
needJdk12 = false;
needJdk12ext = false;
excludedFromJCC = false;
needIBMjvm = null;
// Determine if this is jdk12 or higher (with or without extensions)
if (iminor >= 2)
isJdk12 = true;
if (System.getProperty("java.version").startsWith("1.1.8"))
isJdk118 = true;
if (System.getProperty("java.version").startsWith("1.1.7"))
isJdk117 = true;
// if null, continue in all cases.
if (runwithibmjvm != null) {
if (runwithibmjvm.equals("")) {
needIBMjvm = null;
} else {
needIBMjvm = Boolean.valueOf(runwithibmjvm);
}
}
if (runwithibmjvm == null) {
needIBMjvm = null;
}
if (needIBMjvm != null) {
boolean needsibm = needIBMjvm.booleanValue();
boolean ibmjvm = false;
String vendor = System.getProperty("java.vendor");
if (vendor.startsWith("IBM")) {
ibmjvm = true;
}
if (!needsibm && ibmjvm) {
return true;
}
if (needsibm && !ibmjvm) {
return true;
}
}
if (runwithjvm != null && runwithjvm.equals("false")) {
return true;
}
if ((framework != null) && (framework.length() > 0)) {
if (framework.equals("DerbyNet")) {
// skip if the derbynet.jar is not in the Classpath
try {
Class.forName("org.apache.derby.drda.NetworkServerControl");
} catch (ClassNotFoundException cnfe) {
driverNotFound = true;
result = true;
}
// be present at runtime, and thus we need to catch a possible error too
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
} catch (ClassNotFoundException cnfe) {
driverNotFound = true;
result = true;
} catch (NoClassDefFoundError err) {
driverNotFound = true;
result = true;
}
}
}
// stop looking once know should skip
if (result)
return true;
if ((encryption != null) && (encryption.length() > 0))
if ("true".equalsIgnoreCase(encryption))
isEncryption = true;
if ((jdk12test != null) && (jdk12test.length() > 0))
if ("true".equalsIgnoreCase(jdk12test))
isJdk12Test = true;
if ((jdk12exttest != null) && (jdk12exttest.length() > 0))
if ("true".equalsIgnoreCase(jdk12exttest))
isJdk12ExtTest = true;
// Skip any suite if jvm is not jdk12 or higher for encryption, jdk12test or jdk12exttest
if (!isJdk12) {
if ((isEncryption) || (isJdk12Test) || (isJdk12ExtTest)) {
needJdk12 = true;
// Can't run in this combination
result = true;
}
// stop looking once know should skip
if (result)
return true;
}
// Also require jdk12 extensions for encryption and jdk12exttest
if ((isEncryption) || (isJdk12ExtTest)) {
needJdk12ext = true;
// Check for extensions
try {
Class jtaClass = Class.forName("javax.transaction.xa.Xid");
Class jdbcClass = Class.forName("javax.sql.RowSet");
} catch (ClassNotFoundException cnfe) {
// at least one of the extension classes was not found
// skip this test
result = true;
}
// stop looking once know should skip
if (result)
return true;
}
if (// make sure encryption classes are available
isEncryption) {
needEncryption = true;
try {
Class jceClass = Class.forName("javax.crypto.Cipher");
} catch (ClassNotFoundException cnfe) {
result = true;
}
if (result)
return true;
}
if (excludeJCC != null) {
Class<?> c = null;
Method m = null;
Object o = null;
Integer i = null;
int jccMajor = 0;
int jccMinor = 0;
try {
c = Class.forName("com.ibm.db2.jcc.DB2Driver");
o = c.getConstructor().newInstance();
m = c.getMethod("getMajorVersion", null);
i = (Integer) m.invoke(o, null);
jccMajor = i.intValue();
m = c.getMethod("getMinorVersion", null);
i = (Integer) m.invoke(o, null);
jccMinor = i.intValue();
} catch (Exception e) {
if (verbose)
System.out.println("Exception in shouldSkipTest: " + e);
}
try {
checkClientExclusion(excludeJCC, "JCC", jccMajor, jccMinor, javaVersion);
} catch (Exception e) {
excludedFromJCC = true;
clientExclusionMessage = e.getMessage();
return true;
}
}
// last test result is returned
return result;
}
Aggregations