https://github.com/wkgcass/javaagent-base
A template project for writing a javaagent
https://github.com/wkgcass/javaagent-base
java java-agent javaagent
Last synced: 7 months ago
JSON representation
A template project for writing a javaagent
- Host: GitHub
- URL: https://github.com/wkgcass/javaagent-base
- Owner: wkgcass
- License: mit
- Created: 2023-10-13T12:12:12.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-10-14T06:31:03.000Z (over 2 years ago)
- Last Synced: 2025-01-15T12:17:14.882Z (about 1 year ago)
- Topics: java, java-agent, javaagent
- Language: Java
- Homepage:
- Size: 66.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# javaagent-base
## Dependency
```xml
io.vproxy
javaagent-base
1.0.0
```
```groovy
implementation 'io.vproxy:javaagent-base:1.0.0'
```
## How to use
Please refer to [the sample project](https://github.com/wkgcass/javaagent-base/tree/master/sample)
and [modify-gradle-compiler-args](https://github.com/vproxy-tools/modify-gradle-compiler-args) project.
> Notes:
> You must `--add-exports` for both **your module** and `io.vproxy.javaagent` when compiling.
> You should use `shadowJar` to bundle all classes into one fat jar and exclude `module-info.class` from the fat jar.
## Sample
```shell
./gradlew clean shadowJar
jshell -R-javaagent:./sample/build/libs/biginteger-agent.jar
```
in the jshell:
```
jsehll> var a = new BigInteger("1")
a ==> 1000
```
## Additional JVM Options
Add the following JVM options for the javaagent to work:
```shell
--add-opens java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
--add-opens java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
```