From 761201eca25ffe38373a5b37d7747f6ff3d759f9 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Thu, 29 Jun 2006 21:57:15 +0000 Subject: [PATCH] If the class invoked by the 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 --- WHATSNEW | 3 ++ .../tools/ant/taskdefs/ExecuteJava.java | 34 ++++++++++--------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index f0940891b..f9964f83e 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -235,6 +235,9 @@ Fixed bugs: * can now handle uris with @s other than the final one denoting the domain. Bugzilla 38082. +* If the class invoked by the task threw a ClassNotFoundException, + this was misinterpreted as the specified class itself not being found. + Other changes: -------------- * took in bugzilla report 39320. diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java index 29565b7b1..bf431633c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java @@ -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) {