From 01acc18c4e2d73d13a23c4f602219d5bfe2a04ba Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 11 Jan 2002 13:48:08 +0000 Subject: [PATCH] Search user specified classpath for Weblogic's rmic implementation. PR: 5763 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270666 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/taskdefs/rmic/WLRmic.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java index 14136be68..f4d0c9ff2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,14 +54,12 @@ package org.apache.tools.ant.taskdefs.rmic; +import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.Commandline; - - - import java.lang.reflect.Method; /** @@ -75,9 +73,18 @@ public class WLRmic extends DefaultRmicAdapter { getRmic().log("Using WebLogic rmic", Project.MSG_VERBOSE); Commandline cmd = setupRmicCommand(new String[] {"-noexit"}); + AntClassLoader loader = null; try { // Create an instance of the rmic - Class c = Class.forName("weblogic.rmic"); + Class c = null; + if (getRmic().getClasspath() == null) { + c = Class.forName("weblogic.rmic"); + } else { + loader = new AntClassLoader(getRmic().getProject(), + getRmic().getClasspath()); + c = loader.loadClass("weblogic.rmic"); + AntClassLoader.initializeClass(c); + } Method doRmic = c.getMethod("main", new Class [] { String[].class }); doRmic.invoke(null, new Object[] {cmd.getArguments() }); @@ -93,6 +100,10 @@ public class WLRmic extends DefaultRmicAdapter { } else { throw new BuildException("Error starting WebLogic rmic: ", ex, getRmic().getLocation()); } + } finally { + if (loader != null) { + loader.cleanup(); + } } }