public class SelfModifier extends Object
| Constant | System property | description |
|---|---|---|
| BASE_KEY | self.mod.jar | base path to log file and sandbox dir |
| JAR_KEY | self.mod.class | path to original jar file |
| CLASS_KEY | self.mod.method | class of target method |
| METHOD_KEY | self.mod.phase | name of method to be invoked in sandbox |
| PHASE_KEY | self.mod.base | phase of operation to run |
| Constructor and Description |
|---|
SelfModifier(Method method)
Creates a SelfModifier which will invoke the target method in a separate process from which
it may modify it's own jar file.
|
| Modifier and Type | Method and Description |
|---|---|
static File |
findJarFile(Class<?> clazz)
Retrieve the jar file the specified class was loaded from.
|
void |
invoke(String[] args)
Invoke the target method in a separate process from which it may modify it's own jar file.
|
static void |
main(String[] args) |
static void |
test(String[] args) |
public SelfModifier(Method method) throws IOException
method - a public, static method that accepts a String array as it's only parameter. Any
return value is ignored.NullPointerException - if method is nullIllegalArgumentException - if method is not public, static, and take a
String array as it's only argument, or of it's declaring class is not public.IllegalStateException - if process was not invoked from a jar file,
or an IOException occurred while accessing itIOException - if java is unable to be executed as a separate processSecurityException - if access to the method, or creation of a child process is deniedpublic static void test(String[] args)
public static void main(String[] args)
public void invoke(String[] args) throws IOException
System.exit(int).
The contents of the current jar file are extracted copied to a 'sandbox' directory from which
the method is invoked. The path to the original jar file is placed in the system property
JAR_KEY.
args - arguments to pass to the target method. May be empty or null to indicate no
arguments.IOException - for lots of thingsIllegalStateException - if method's class was not loaded from a jarpublic static File findJarFile(Class<?> clazz)
SecurityException - if access to is denied by SecurityManagerCopyright © 2001–2025. All rights reserved.