Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 8 additions & 24 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [7, 8, 9, 10, 11 ]
java: [7, 8, 11, 17 ]
steps:
- uses: actions/checkout@v2
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Build with Maven
run: |
mvn clean package -DskipTests
mvn test

build_jdk_ge_12:
runs-on: ubuntu-latest
strategy:
matrix:
java: [12, 13, 14, 15]
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 8
- name: save java8 home
java-version: 11
- name: save java11 home
run: |
export JAVA8_HOME=$JAVA_HOME && echo $JAVA8_HOME
echo "export JAVA8_HOME=$JAVA_HOME" > ~/.testenv
export JAVA11_HOME=$JAVA_HOME && echo $JAVA11_HOME
echo "export JAVA11_HOME=$JAVA_HOME" > ~/.testenv

- name: Setup java
uses: actions/setup-java@v1
Expand All @@ -42,5 +26,5 @@ jobs:
- name: Build with Maven
run: |
source ~/.testenv
mvn -Dmaven.compiler.fork=true -Dmaven.compiler.executable=$JAVA8_HOME/bin/javac clean package -DskipTests
mvn -Dmaven.compiler.fork=true -Dmaven.compiler.executable=$JAVA8_HOME/bin/javac test
mvn -Dmaven.compiler.fork=true -Dmaven.compiler.executable=$JAVA11_HOME/bin/javac clean package -DskipTests --batch-mode
mvn -Dmaven.compiler.fork=true -Dmaven.compiler.executable=$JAVA11_HOME/bin/javac test --batch-mode
2 changes: 1 addition & 1 deletion fastjson-demo-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.76</version>
<version>1.2.83</version>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ public void run() {
}
}
}, "oneagent plugin " + plugin.name() + " init");
thread.setDaemon(true);
thread.start();
}

Expand Down Expand Up @@ -340,6 +341,7 @@ public void run() {
}
}
}, "oneagent plugin " + plugin.name() + " start");
thread.setDaemon(true);
thread.start();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.alibaba.oneagent;

import com.alibaba.oneagent.inst.InstrumentationWrapper;

import java.lang.instrument.Instrumentation;

/**
Expand Down Expand Up @@ -28,6 +30,7 @@ public static void destroy() {
}

private static synchronized void main(String args, Instrumentation inst, boolean premain) {
inst = InstrumentationWrapper.newInstrumentationWrapper(inst);
if (NopAgent.INSTANCE == AGENT) {
Agent agent = new AgentImpl();
agent.init(args, inst, premain);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.alibaba.oneagent.inst;

import java.lang.instrument.Instrumentation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class InstrumentationInvocationHandler implements InvocationHandler {
private final Instrumentation instrumentation;

private final Object lockForAppend = new Object();

public InstrumentationInvocationHandler(Instrumentation instrumentation) {
this.instrumentation = instrumentation;
}

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("appendToBootstrapClassLoaderSearch") ||
method.getName().equals("appendToSystemClassLoaderSearch")
) {
synchronized (lockForAppend) {
return method.invoke(instrumentation, args);
}
} else {
return method.invoke(instrumentation, args);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.alibaba.oneagent.inst;

import java.lang.instrument.Instrumentation;
import java.lang.reflect.Proxy;

public class InstrumentationWrapper {
public static Instrumentation newInstrumentationWrapper(Instrumentation instrumentation) {
return (Instrumentation) Proxy.newProxyInstance(
instrumentation.getClass().getClassLoader(),
new Class[]{Instrumentation.class},
new InstrumentationInvocationHandler(instrumentation));
}
}