Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

JAgent framework helps you to implement java agents. It has some extra functionality instead of standard Java's API.

GitHub RepositoryComing soon...
Public Maven repohttps://bintray.com/devexperts/Maven/jagent
LicenseGPLv3
ContactImage Added

Class redefining

By default, java agents don't redefine already loaded classes. Standard API has method java.lang.instrument.Instrumentation#redefineClasses(ClassDefinition... definitions) to redefine them. But it's impossible to redefine some classes (for example, java.lang.String) using this method.

...

...
<plugins>
    <!-- maven-dependency-plugin is used to copy your agent into target directory -->
    <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <id>copy-sample-agent</id>
                <phase>process-test-classes</phase>
                <goals>
                    <goal>copy</goal>
                </goals>
                <configuration>
                    <artifactItems>
                        <artifactItem>
                            <groupId>com.agent.package</groupId>
                            <artifactId>your_agent</artifactId>
                            <version>${project.version}</version>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <destFileName>${agent.artifact.name}.jar</destFileName>
                        </artifactItem>
                    </artifactItems>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <!-- Configure maven-surefire-plugin to use your agent -->
    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <argLine>-javaagent:${agent.directory}/${agent.artifact.name}.jar</argLine>
        </configuration>
    </plugin>
</plugins>
...

Getting support

If you need help, you have a question, or you need further details on how to use JAgent, you can refer to the following resources:

  • DxLab department in Devexperts mailing-list: <dxlab at devexperts dot com> 
  • GitHub issues: TODO