net.imagej.patcher
Class JavaAgent

java.lang.Object
  extended by net.imagej.patcher.JavaAgent
All Implemented Interfaces:
ClassFileTransformer

public class JavaAgent
extends Object
implements ClassFileTransformer

A Java agent to help with legacy issues.

Author:
Johannes Schindelin

Constructor Summary
JavaAgent()
           
 
Method Summary
static void dontCall(int i)
           
static void main(String... args)
          Writes out a minimal java agent .jar file.
static void premain(String agentArgs, Instrumentation instrumentation)
          The premain method started at JVM startup.
static void stop()
           
 byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaAgent

public JavaAgent()
Method Detail

stop

public static void stop()

premain

public static void premain(String agentArgs,
                           Instrumentation instrumentation)
The premain method started at JVM startup. When this class is specified as Premain-Class in the manifest and the JVM is started with the option -javaagent:/path/to/ij1-patcher.jar then this method is called some time before the main method of the main class is called.

Parameters:
agentArgs - the optional argument passed via -javaagent:ij1-patcher.jar=ARGUMENT
instrumentation - the Instrumentation instance passed by the JVM

transform

public byte[] transform(ClassLoader loader,
                        String className,
                        Class<?> classBeingRedefined,
                        ProtectionDomain protectionDomain,
                        byte[] classfileBuffer)
                 throws IllegalClassFormatException
Specified by:
transform in interface ClassFileTransformer
Throws:
IllegalClassFormatException

dontCall

public static void dontCall(int i)

main

public static void main(String... args)
                 throws IOException
Writes out a minimal java agent .jar file.

When trying to debug class loading issues in ij1-patcher itself, of course we cannot load the complete ij1-patcher.jar as a Java Agent (otherwise it would hide the classes that we want to test with possibly out-dated ones).

This main method can be used to generate a minimal .jar file for use with -javaagent that contains only the LegacyJavaAgent class.

Parameters:
args - the command-line arguments (the first one, if specified, refers to the output file name)
Throws:
IOException


Copyright © 2009–2014 ImageJ. All rights reserved.