Browse Source

If the class invoked by the <java> task threw a ClassNotFoundException,

this was misinterpreted as the specified class itself not being found.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@418146 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 19 years ago
parent
commit
761201eca2
2 changed files with 21 additions and 16 deletions
  1. +3
    -0
      WHATSNEW
  2. +18
    -16
      src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java

+ 3
- 0
WHATSNEW View File

@@ -235,6 +235,9 @@ Fixed bugs:
* <scp> can now handle uris with @s other than the final one denoting the
domain. Bugzilla 38082.

* If the class invoked by the <java> task threw a ClassNotFoundException,
this was misinterpreted as the specified class itself not being found.

Other changes:
--------------
* took in bugzilla report 39320.


+ 18
- 16
src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2006 The Apache Software Foundation
* Copyright 2000-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -120,17 +120,23 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
sysProperties.setSystem();
}
Class target = null;
if (classpath == null) {
target = Class.forName(classname);
} else {
loader = project.createClassLoader(classpath);
loader.setParent(project.getCoreLoader());
loader.setParentFirst(false);
loader.addJavaLibraries();
loader.setIsolated(true);
loader.setThreadContextLoader();
loader.forceLoadClass(classname);
target = Class.forName(classname, true, loader);
try {
if (classpath == null) {
target = Class.forName(classname);
} else {
loader = project.createClassLoader(classpath);
loader.setParent(project.getCoreLoader());
loader.setParentFirst(false);
loader.addJavaLibraries();
loader.setIsolated(true);
loader.setThreadContextLoader();
loader.forceLoadClass(classname);
target = Class.forName(classname, true, loader);
}
} catch (ClassNotFoundException e) {
throw new BuildException("Could not find " + classname + "."
+ " Make sure you have it in your"
+ " classpath");
}
main = target.getMethod("main", new Class[] {String[].class});
if (main == null) {
@@ -176,10 +182,6 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
if (caught != null) {
throw caught;
}
} catch (ClassNotFoundException e) {
throw new BuildException("Could not find " + classname + "."
+ " Make sure you have it in your"
+ " classpath");
} catch (BuildException e) {
throw e;
} catch (SecurityException e) {


Loading…
Cancel
Save