diff --git a/WHATSNEW b/WHATSNEW index bd6725b5d..317f0285b 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -37,6 +37,13 @@ Fixed bugs: * Resource collection implementation of mapped PropertySet returned unusable resources. + * The hasmethod condition failed with a NullPointerException when + ignoresystemclasses is true and Ant tried to load a "restricted + class" - i.e. a class that the Java VM will only accept when loaded + via the bootclassloader (a java.* class). + It will now fail with a more useful error message. + Bugzilla Report 51035. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java b/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java index 4f5ce5224..889a9f876 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java @@ -113,10 +113,12 @@ public class HasMethod extends ProjectComponent implements Condition { try { return loader.findClass(classname); } catch (SecurityException se) { - // class found but restricted name; this is - // actually the case we're looking for in JDK 1.3+, - // so catch the exception and return - return null; + // class found but restricted name + throw new BuildException("class \"" + classname + + "\" was found but a" + + " SecurityException has been" + + " raised while loading it", + se); } } else if (loader != null) { // How do we ever get here? diff --git a/src/tests/antunit/taskdefs/condition/hasmethod-text.xml b/src/tests/antunit/taskdefs/condition/hasmethod-text.xml new file mode 100644 index 000000000..9ae9b323b --- /dev/null +++ b/src/tests/antunit/taskdefs/condition/hasmethod-text.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +