R
Ross
Hi all.
I'm building a plugin loader. I want this loader to be able to load
from .jar files, which may contain multiple classes per plugin. So,
all of these classes need to be loaded in.
However, I don't want to load classes that already exist, e.g. I don't
want there to be the possibility of plugins loading classes which
would conflict with classes already part of the application.
I can easily check if classes are already present in the classpath by
using a method such as:
private boolean known( String className )
{
try
{
Class c = Class.forName( className );
return true;
}
catch( ClassNotFoundException cnfe )
{
return false;
}
}
This will cause a plugin to be rejected if it includes any class which
can be found. But, since plugins should really contain classes defined
in a unique package, I don't think this will cause a problem.
Is there a better way of identifying if plugins are redefining
existing classes, or otherwise creating a potential problem? Or, is
there no possibility of a potential conflict due to the way that
custom classloaders work?
I'm building a plugin loader. I want this loader to be able to load
from .jar files, which may contain multiple classes per plugin. So,
all of these classes need to be loaded in.
However, I don't want to load classes that already exist, e.g. I don't
want there to be the possibility of plugins loading classes which
would conflict with classes already part of the application.
I can easily check if classes are already present in the classpath by
using a method such as:
private boolean known( String className )
{
try
{
Class c = Class.forName( className );
return true;
}
catch( ClassNotFoundException cnfe )
{
return false;
}
}
This will cause a plugin to be rejected if it includes any class which
can be found. But, since plugins should really contain classes defined
in a unique package, I don't think this will cause a problem.
Is there a better way of identifying if plugins are redefining
existing classes, or otherwise creating a potential problem? Or, is
there no possibility of a potential conflict due to the way that
custom classloaders work?