Skip to content

Commit

Permalink
build: fixes bytecode level and updates build versions (openzipkin#236)…
Browse files Browse the repository at this point in the history
… (openzipkin#1393)

This fixes a problem where we weren't releasing jars with the right
bytecode level, due to a constant release=8. As we no longer can rely on
RetroLambda to rewrite code, I've had to port things to the appropriate
bytecode level manually. I also updated build deps that could be.

Special note: Projects that optionally use types above their bytecode
level *unset* maven.compiler.release in the release profile. This allows
the project to compile classes not at the source level. This is used in
brave core and okhttp, for example.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
codefromthecrypt committed Jan 6, 2024
1 parent 70600a5 commit 41fe2ee
Show file tree
Hide file tree
Showing 52 changed files with 219 additions and 261 deletions.
4 changes: 2 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ project has a bom.
$ mvn=$PWD/mvnw
$ for p in ./brave-bom .; do
(cd $p
$mvn versions:set -DnewVersion=2.17.1-SNAPSHOT -DgenerateBackupPoms=false
$mvn versions:set -DnewVersion=5.17.2-SNAPSHOT -DgenerateBackupPoms=false
$mvn -o clean install -DskipTests
$mvn com.mycila:license-maven-plugin:format
$mvn versions:set -DnewVersion=5.17.0-SNAPSHOT -DgenerateBackupPoms=false)
$mvn versions:set -DnewVersion=5.17.1-SNAPSHOT -DgenerateBackupPoms=false)
done
$ git commit -asm"Adjusts copyright headers for this year"
```
Expand Down
4 changes: 2 additions & 2 deletions brave-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<main.basedir>${project.basedir}/..</main.basedir>

<!-- use the same values in ../pom.xml -->
<zipkin.version>2.25.2</zipkin.version>
<zipkin-reporter.version>2.17.1</zipkin-reporter.version>
<zipkin.version>2.27.0</zipkin.version>
<zipkin-reporter.version>2.17.2</zipkin-reporter.version>
</properties>

<organization>
Expand Down
2 changes: 1 addition & 1 deletion brave-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down
18 changes: 6 additions & 12 deletions brave/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -34,9 +34,6 @@

<!-- disable errorprone cast warning as PendingSpans internally hacks equals -->
<errorprone.args>-Xep:EqualsUnsafeCast:OFF</errorprone.args>

<!-- The brave jar needs to be Java 1.6 bytecode -->
<main.signature.artifact>java16</main.signature.artifact>
</properties>

<dependencies>
Expand All @@ -47,13 +44,6 @@
<artifactId>zipkin-reporter-brave</artifactId>
<version>${zipkin-reporter.version}</version>
</dependency>
<dependency>
<groupId>org.jvnet</groupId>
<artifactId>animal-sniffer-annotation</artifactId>
<version>1.0</version>
<!-- annotations are not runtime retention, so don't need a runtime dep -->
<scope>provided</scope>
</dependency>

<!-- To show off SpanHandler -->
<dependency>
Expand Down Expand Up @@ -136,7 +126,11 @@
<id>release</id>
<properties>
<!-- The brave jar needs to be Java 1.6 bytecode -->
<main.java.version>1.6</main.java.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<!-- Clear the release tag, so that we can compile Platform without
errors and without changing the end bytecode to 1.8 -->
<maven.compiler.release />
</properties>
<build>
<plugins>
Expand Down
15 changes: 7 additions & 8 deletions brave/src/main/java/brave/internal/Platform.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2023 The OpenZipkin Authors
* Copyright 2013-2024 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand All @@ -25,7 +25,6 @@
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.jvnet.animal_sniffer.IgnoreJRERequirement;

/**
* Access to platform-specific features.
Expand Down Expand Up @@ -167,12 +166,12 @@ public Clock clock() {
}

static class Jre9 extends Jre7 {
@IgnoreJRERequirement @Override public long currentTimeMicroseconds() {
@Override public long currentTimeMicroseconds() {
java.time.Instant instant = java.time.Clock.systemUTC().instant();
return (instant.getEpochSecond() * 1000000) + (instant.getNano() / 1000);
}

@IgnoreJRERequirement @Override public Clock clock() {
@Override public Clock clock() {
return new Clock() {
// we could use jdk.internal.misc.VM to do this more efficiently, but it is internal
@Override public long currentTimeMicroseconds() {
Expand All @@ -199,19 +198,19 @@ static class Jre7 extends Platform {
return System.nanoTime();
}

@IgnoreJRERequirement @Override public String getHostString(InetSocketAddress socket) {
@Override public String getHostString(InetSocketAddress socket) {
return socket.getHostString();
}

@IgnoreJRERequirement @Override public long randomLong() {
@Override public long randomLong() {
return java.util.concurrent.ThreadLocalRandom.current().nextLong();
}

@IgnoreJRERequirement @Override public long nextTraceIdHigh() {
@Override public long nextTraceIdHigh() {
return nextTraceIdHigh(currentTimeMicroseconds(), java.util.concurrent.ThreadLocalRandom.current().nextInt());
}

@IgnoreJRERequirement @Override
@Override
public AssertionError assertionError(String message, Throwable cause) {
return new AssertionError(message, cause);
}
Expand Down
21 changes: 6 additions & 15 deletions context/jfr/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -29,23 +29,14 @@
<!-- Matches Export-Package in bnd.bnd -->
<module.name>brave.context.jfr</module.name>

<!-- JFR is JDK11+ -->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>

<main.basedir>${project.basedir}/../..</main.basedir>
<!-- for add-modules -->
<main.java.version>11</main.java.version>
<!-- 12 not 11 as there is no java11 published -->
<main.signature.artifact>java12</main.signature.artifact>
</properties>

<dependencies>
<dependency>
<groupId>org.jvnet</groupId>
<artifactId>animal-sniffer-annotation</artifactId>
<version>1.0</version>
<!-- annotations are not runtime retention, so don't need a runtime dep -->
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2023 The OpenZipkin Authors
* Copyright 2013-2024 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand All @@ -22,7 +22,6 @@
import jdk.jfr.Description;
import jdk.jfr.Event;
import jdk.jfr.Label;
import org.jvnet.animal_sniffer.IgnoreJRERequirement;

/**
* Adds {@linkplain Event} properties "traceId", "parentId" and "spanId" when a {@link
Expand Down Expand Up @@ -56,7 +55,6 @@ public static ScopeDecorator get() {
@Category("Zipkin")
@Label("Scope")
@Description("Zipkin event representing a span being placed in scope")
@IgnoreJRERequirement
static final class ScopeEvent extends Event {
@Label("Trace Id") String traceId;
@Label("Parent Id") String parentId;
Expand Down
11 changes: 5 additions & 6 deletions context/log4j12/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -30,9 +30,6 @@
<module.name>brave.context.log4j12</module.name>

<main.basedir>${project.basedir}/../..</main.basedir>

<!-- log4j is Java 1.6 bytecode -->
<main.signature.artifact>java16</main.signature.artifact>
</properties>

<dependencies>
Expand All @@ -48,8 +45,10 @@
<profile>
<id>release</id>
<properties>
<!-- log4j is Java 1.6 bytecode -->
<main.java.version>1.6</main.java.version>
<!-- log4j is 1.6 bytecode -->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.release>6</maven.compiler.release>
</properties>
<build>
<plugins>
Expand Down
8 changes: 4 additions & 4 deletions context/log4j2/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -31,8 +31,6 @@

<main.basedir>${project.basedir}/../..</main.basedir>

<!-- log4j2 <= 2.3.2 is 1.6 bytecode -->
<main.signature.artifact>java16</main.signature.artifact>
</properties>

<dependencies>
Expand All @@ -49,7 +47,9 @@
<id>release</id>
<properties>
<!-- log4j2 <= 2.3.2 is 1.6 bytecode -->
<main.java.version>1.6</main.java.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.release>6</maven.compiler.release>
</properties>
<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion context/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down
9 changes: 4 additions & 5 deletions context/rxjava2/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -30,9 +30,6 @@
<module.name>brave.context.rxjava2</module.name>

<main.basedir>${project.basedir}/../..</main.basedir>

<!-- RxJava 2.x continues support for Java 1.6 and Android 2.3+ -->
<main.signature.artifact>java16</main.signature.artifact>
</properties>

<dependencies>
Expand Down Expand Up @@ -68,7 +65,9 @@
<id>release</id>
<properties>
<!-- RxJava 2.x continues support for Java 1.6 and Android 2.3+ -->
<main.java.version>1.6</main.java.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.release>6</maven.compiler.release>
</properties>
<build>
<plugins>
Expand Down
9 changes: 4 additions & 5 deletions context/slf4j/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -30,9 +30,6 @@
<module.name>brave.context.slf4j</module.name>

<main.basedir>${project.basedir}/../..</main.basedir>

<!-- SLF4J is 1.6 bytecode -->
<main.signature.artifact>java16</main.signature.artifact>
</properties>

<dependencies>
Expand All @@ -49,7 +46,9 @@
<id>release</id>
<properties>
<!-- SLF4J is 1.6 bytecode -->
<main.java.version>1.6</main.java.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.release>6</maven.compiler.release>
</properties>
<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/benchmarks/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down
9 changes: 4 additions & 5 deletions instrumentation/dubbo-rpc/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -45,9 +45,6 @@
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.base/java.math=ALL-UNNAMED
</maven-failsafe-plugin.argLine>

<!-- Dubbo is 1.6 bytecode -->
<main.signature.artifact>java16</main.signature.artifact>
</properties>

<dependencies>
Expand Down Expand Up @@ -83,7 +80,9 @@
<id>release</id>
<properties>
<!-- Dubbo is 1.6 bytecode -->
<main.java.version>1.6</main.java.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.release>6</maven.compiler.release>
</properties>
<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/dubbo/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Copyright 2013-2023 The OpenZipkin Authors
Copyright 2013-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down
Loading

0 comments on commit 41fe2ee

Please sign in to comment.