Skip to content

Commit

Permalink
Merge branch 'refs/heads/release/2.2.6'
Browse files Browse the repository at this point in the history
# Conflicts:
#	common.gradle
  • Loading branch information
jbachorik committed Nov 9, 2024
2 parents 0ab39e4 + 9467343 commit 1df64e8
Show file tree
Hide file tree
Showing 60 changed files with 651 additions and 255 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -55,4 +55,4 @@ jobs:
./gradlew -x test build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
43 changes: 23 additions & 20 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Java
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v4
- name: Build
run: ./gradlew build
- name: Upload build data
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build
retention-days: 1
path: |
btrace-dist/build
- name: Archive test reports
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-reports
path: |
Expand All @@ -52,20 +53,21 @@ jobs:
timeout-minutes: 10
strategy:
matrix:
java: [ 8, 11, 17, 20 ]
java: [ 8, 11, 17, 21 ]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v4
- name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: temurin
- name: Download build data
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build
path: btrace-dist/build
Expand All @@ -74,15 +76,15 @@ jobs:
./gradlew -Pintegration :integration-tests:test
- name: Integration test reports
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: integration-test-reports
name: integration-test-reports-${{ matrix.java }}
path: |
integration-tests/build/reports/**/*
- name: Archive binary artifacts
uses: actions/upload-artifact@v3
if: success() && matrix.java == '11'
uses: actions/upload-artifact@v4
with:
if: success()
name: btrace-dist
path: |
btrace-dist/build/distributions/**/btrace-*-bin*.tar.gz
Expand All @@ -93,21 +95,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v4
- name: Set up Java
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
- name: Download build data
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build
- name: Deploy Maven
run: JAVA_HOME="$JAVA_11_HOME" ./gradlew -x test :btrace-dist:publish
run: ./gradlew -x test :btrace-dist:publish
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_SIGNING_PWD: ${{ secrets.GPG_SIGNING_PWD }}
Expand All @@ -119,6 +122,6 @@ jobs:
needs: publish
steps:
- name: Cleanup temporary artifacts
uses: geekyeggo/delete-artifact@v2
uses: geekyeggo/delete-artifact@v5
with:
name: build
25 changes: 21 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Branch name
id: branch_name
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- name: Set up Java
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
- name: Build artifacts
run: ./gradlew :btrace-dist:build
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -39,4 +40,20 @@ jobs:
files: |
btrace-dist/build/distributions/btrace-${{ steps.branch_name.outputs.SOURCE_TAG }}-bin.tar.gz
btrace-dist/build/distributions/btrace-${{ steps.branch_name.outputs.SOURCE_TAG }}-bin.zip
btrace-dist/build/distributions/btrace-${{ steps.branch_name.outputs.SOURCE_TAG }}-sdkman-bin.zip
btrace-dist/build/distributions/btrace-${{ steps.branch_name.outputs.SOURCE_TAG }}-sdkman-bin.zip
- name: Deploy Maven
id: deploy_maven
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_SIGNING_PWD: ${{ secrets.GPG_SIGNING_PWD }}
BTRACE_SONATYPE_USER: ${{ secrets.BTRACE_SONATYPE_USER }}
BTRACE_SONATYPE_PWD: ${{ secrets.BTRACE_SONATYPE_PWD }}
run: |
./gradlew :btrace-dist:publishAllPublicationsToMavenRepository
- name: Update SDKMan!
id: update_sdkman
env:
SKDMAN_API_KEY: ${{ secrets.SDKMAN_KEY }}
SDKMAN_API_TOKEN: ${{ secrets.SDKMAN_TOKEN }}
run: |
./gradlew :btrace-dist:sdkMinorRelease
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/stale@v7
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*.war
*.ear

# Un-ignore specific files
!btrace-instr/src/test/resources/packed/test-pack.jar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
A safe, dynamic tracing tool for the Java platform

## Version
2.2.3
2.2.6

## Quick Summary
BTrace is a safe, dynamic tracing tool for the Java platform.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ private static synchronized void main(String args, Instrumentation inst) {
BTraceRuntime.leave();
}
});
// set the fall-back instrumentation object to BTraceRuntime
BTraceRuntime.instrumentation = inst;
// force back-registration of BTraceRuntimeImpl in BTraceRuntime
BTraceRuntimes.getDefault();
// init BTraceRuntime
Expand Down Expand Up @@ -398,8 +400,8 @@ private static void parseArgs() {

String libs = argMap.get(LIBS);
String config = argMap.get(CONFIG);
loadDefaultArguments(config);
processClasspaths(libs);
loadDefaultArguments(config);

p = argMap.get(DEBUG);
settings.setDebug(p != null && !"false".equals(p));
Expand Down
4 changes: 4 additions & 0 deletions btrace-client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
buildscript { scriptHandler ->
apply from: rootProject.file('buildSrc/shared.gradle'), to: scriptHandler
}

plugins {
alias(libs.plugins.versioning)
}
Expand Down
18 changes: 17 additions & 1 deletion btrace-client/src/main/java/org/openjdk/btrace/client/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Properties;

import org.openjdk.btrace.core.DebugSupport;
import org.openjdk.btrace.core.Messages;
import org.openjdk.btrace.core.comm.Command;
Expand Down Expand Up @@ -83,10 +87,22 @@ public final class Main {
if (log.isDebugEnabled()) log.debug("dumpDir is {}", DUMP_DIR);
}
PROBE_DESC_PATH = System.getProperty("com.sun.btrace.probeDescPath", ".");
con = System.console();
String javaVersion = getJavaVersion();
// In Java 22 the console will write standard output to stderr :shrug:
con = javaVersion == null || !javaVersion.startsWith("22") ? System.console() : null;
out = getOutWriter(con);
}

private static String getJavaVersion() {
Properties props = new Properties();
try {
props.load(Files.newInputStream(Paths.get(System.getenv("JAVA_HOME"), "release")));
return props.getProperty("JAVA_VERSION").replace("\"", "");
} catch (IOException ignored) {
return null;
}
}

@SuppressWarnings("DefaultCharset")
private static PrintWriter getOutWriter(Console con) {
return (con != null) ? con.writer() : new PrintWriter(System.out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void visitVarInsn(int opcode, int var) {
case Opcodes.DLOAD:
{
simulatedStack.push(Boolean.FALSE);
// long and double occoupy 2 stack slots; fall through
// long and double occupy 2 stack slots; fall through
}
case Opcodes.ILOAD:
case Opcodes.FLOAD:
Expand All @@ -283,7 +283,7 @@ public void visitVarInsn(int opcode, int var) {
case Opcodes.DSTORE:
{
simulatedStack.poll();
// long and double occoupy 2 stack slots; fall through
// long and double occupy 2 stack slots; fall through
}
case Opcodes.ASTORE:
case Opcodes.ISTORE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
* @author A. Sundararajan
*/
@SupportedAnnotationTypes("*")
@SupportedSourceVersion(SourceVersion.RELEASE_7)
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class Verifier extends AbstractProcessor implements TaskListener {
private final List<String> classNames = new ArrayList<>();
private final List<CompilationUnitTree> compUnits = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URL;
import java.util.Map;
import org.junit.jupiter.api.Test;
Expand All @@ -11,6 +12,8 @@
import org.openjdk.btrace.instr.BTraceProbe;
import org.openjdk.btrace.instr.BTraceProbeFactory;

import static org.junit.jupiter.api.Assertions.fail;

public class JfrEventsTest {
@Test
public void testCompile() throws Exception {
Expand All @@ -26,9 +29,18 @@ public void testCompile() throws Exception {
BTraceProbeFactory factory = new BTraceProbeFactory(SharedSettings.GLOBAL);
for (byte[] bytes : data.values()) {
BTraceProbe probe = factory.createProbe(bytes);
byte[] code = probe.getDataHolderBytecode();
CheckClassAdapter.verify(new ClassReader(code), true, new PrintWriter(System.err));
verifyCode(probe.getFullBytecode());
verifyCode(probe.getDataHolderBytecode());
}
}

private void verifyCode(byte[] code) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
CheckClassAdapter.verify(new ClassReader(code), true, pw);
if (sw.toString().contains("AnalyzerException")) {
System.err.println(sw);
fail();
}
System.out.println(data);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.openjdk.btrace.compiler;

import org.junit.jupiter.api.Test;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.util.CheckClassAdapter;
import org.openjdk.btrace.core.SharedSettings;
import org.openjdk.btrace.instr.BTraceProbe;
import org.openjdk.btrace.instr.BTraceProbeFactory;

import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URL;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.fail;

public class TypeErasureTest {
@Test
void testTypeErasure() throws Exception {
URL input = TypeErasureTest.class.getResource("/HistoProbe.java");
File inputFile = new File(input.toURI());
Map<String, byte[]> data =
new Compiler(true)
.compile(
inputFile,
new PrintWriter(System.err),
null,
System.getProperty("java.class.path"));
BTraceProbeFactory factory = new BTraceProbeFactory(SharedSettings.GLOBAL);
for (byte[] bytes : data.values()) {
BTraceProbe probe = factory.createProbe(bytes);
verifyCode(probe.getFullBytecode());
verifyCode(probe.getDataHolderBytecode());
}
}

private void verifyCode(byte[] code) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
CheckClassAdapter.verify(new ClassReader(code), true, pw);
if (sw.toString().contains("AnalyzerException")) {
System.err.println(sw);
fail();
}
}
}
Loading

0 comments on commit 1df64e8

Please sign in to comment.