Browse Source

Don't assume class.getClassLoader is not null, PR 31450

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276903 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
ccfc216622
2 changed files with 14 additions and 3 deletions
  1. +5
    -2
      src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
  2. +9
    -1
      src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java

+ 5
- 2
src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java View File

@@ -140,8 +140,11 @@ public class CompilerAdapterFactory {
return true;
} catch (ClassNotFoundException cnfe) {
try {
CompilerAdapterFactory.class.getClassLoader().loadClass(MODERN_COMPILER);
return true;
ClassLoader cl = CompilerAdapterFactory.class.getClassLoader();
if (cl != null) {
cl.loadClass(MODERN_COMPILER);
return true;
}
} catch (ClassNotFoundException cnfe2) {
}
}


+ 9
- 1
src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java View File

@@ -487,7 +487,15 @@ public class ModifiedSelector extends BaseExtendSelector implements BuildListene
protected Object loadClass(String classname, String msg, Class type) {
try {
// load the specified class
Object rv = getClassLoader().loadClass(classname).newInstance();
ClassLoader cl = getClassLoader();
Class clazz = null;
if (cl != null) {
clazz = cl.loadClass(classname);
} else {
clazz = Class.forName(classname);
}
Object rv = clazz.newInstance();

if (!type.isInstance(rv)) {
throw new BuildException("Specified class (" + classname + ") " + msg);


Loading…
Cancel
Save