Re: empty interfaces via reflection
Sorry if this a double-post. Damn google.
On Oct 19, 10:09 am, "Aryeh M. Friedman" <Aryeh.Fried...@gmail.com>
wrote:
On Oct 19, 4:14 pm, Steven Simpson <s...@domain.invalid> wrote:
Aryeh M. Friedman wrote:
the
following test code (using findClass not loadClass as the override
method) still doesn't work:
public static void main(String[] args)
throws Throwable
{
while(true) {
ClassLoader loader=new MyClassLoader();
I did get the following to work. It uses a URLClassLoader, as Daniel
Pitts suggested. Your MyClassLoader didn't seem to be doing anything
extra, so you may as well use the existing class - though I don't see
why yours wouldn't work.
You give the directory containing the class to be tested as the first
argument, and it is turned into a URL for the class loader. Make sure
this directory is not in your classpath.
There is the rub... since it is meant for a standalone commercial app
I don't feel comfortable making any assumptions about the struct of
the user's class path (matter of fact on the surface I think all
loaded classes will have to be in the class path one way or an other
[cmd line arg passing maybe but not very portable])
So, use it as an example, and work from there.
You can't do what you're trying to do without some assumptions about
the class path. Commercial products make assumptions all the time
(like, for instance, the validity of the environment their running
on). It is the only feasible way to do this. Just document the fact
that your program's execution environment should be *different* than
that of the tests. Or, figure out some other way of supporting that.