From 93672649d29d5243b089b6f45fbf966b1b542c4c Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 25 Nov 2009 20:47:18 +0000 Subject: [PATCH] made project class loader public + throw exception is mote class could not be loaded --- tools/cooja/java/se/sics/cooja/GUI.java | 13 +++++-------- tools/cooja/java/se/sics/cooja/Simulation.java | 6 ++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/GUI.java b/tools/cooja/java/se/sics/cooja/GUI.java index 667437fe0..3438c1fca 100644 --- a/tools/cooja/java/se/sics/cooja/GUI.java +++ b/tools/cooja/java/se/sics/cooja/GUI.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: GUI.java,v 1.154 2009/11/25 10:29:21 fros4943 Exp $ + * $Id: GUI.java,v 1.155 2009/11/25 20:47:18 fros4943 Exp $ */ package se.sics.cooja; @@ -302,7 +302,7 @@ public class GUI extends Observable { private Vector currentProjectDirs = new Vector(); - private ClassLoader projectDirClassLoader; + public ClassLoader projectDirClassLoader; private Vector> moteTypeClasses = new Vector>(); @@ -2846,12 +2846,9 @@ public class GUI extends Observable { /** * Help method that tries to load and initialize a class with given name. * - * @param - * Class extending given class type - * @param classType - * Class type - * @param className - * Class name + * @param Class extending given class type + * @param classType Class type + * @param className Class name * @return Class extending given class type or null if not found */ public Class tryLoadClass( diff --git a/tools/cooja/java/se/sics/cooja/Simulation.java b/tools/cooja/java/se/sics/cooja/Simulation.java index 66bfba5e8..38bc18ebe 100644 --- a/tools/cooja/java/se/sics/cooja/Simulation.java +++ b/tools/cooja/java/se/sics/cooja/Simulation.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: Simulation.java,v 1.54 2009/11/13 08:37:36 fros4943 Exp $ + * $Id: Simulation.java,v 1.55 2009/11/25 20:47:19 fros4943 Exp $ */ package se.sics.cooja; @@ -610,7 +610,9 @@ public class Simulation extends Observable implements Runnable { if (element.getName().equals("mote")) { Class moteClass = myGUI.tryLoadClass(this, Mote.class, element.getText().trim()); - + if (moteClass == null) { + throw new Exception("Could not load mote class: " + element.getText().trim()); + } Mote mote = moteClass.getConstructor((Class[]) null).newInstance((Object[]) null); if (mote.setConfigXML(this, element.getChildren(), visAvailable)) { addMote(mote);