Skip to content

Commit

Permalink
Mr java8 (#1719)
Browse files Browse the repository at this point in the history
* Make jars multi-release for Java 8.

* Remove printout.

* Add multi-release to release profile.

* Add readme section about Java file size.
  • Loading branch information
raphw authored Oct 17, 2024
1 parent 8a38f33 commit a6a286d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
architecture: x64
cache: maven
- name: Build project
run: ./mvnw jacoco:prepare-agent verify jacoco:report coveralls:report -DrepoToken=${{ secrets.coveralls }} -Pextras -Pchecks -Panalysis -Pintegration -Pchecksum-enforce
run: ./mvnw jacoco:prepare-agent verify jacoco:report coveralls:report -DrepoToken=${{ secrets.coveralls }} -Pextras -Pchecks -Panalysis -Pintegration -Pmulti-release -Pchecksum-enforce
release:
name: Release new version
runs-on: ubuntu-24.04
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,17 @@ version conflicts.

Please note the [security policy](https://github.com/raphw/byte-buddy/blob/master/SECURITY.md) of this project.

Byte Buddy supports execution on all JVM versions from version five and onwards in a single jar. This is done to ease
the development of Java agents which often require to support older, or unknown, applications which are not actively
updated. To allow for this while also supporting modern Java and features like CDS or class validation with stack
map frames, the main jars for Byte Buddy ship as multi-release jars that contain class files in version five and eight.
As a result, the jar size of Byte Buddy is higher as one would expect. Jar file size is not normally a problem, as
the majority of Byte Buddy's classes will never be loaded. Yet, file size might be an issue when distributing Java
agents. As agents already need to be bundled as a single jar, it is therefore recommended to remove either the basic
Java five version, or the multi-release Java eight version of the contained class files, to reduce this issue. This
is supported by most build plugins for this purpose, such as the
[Maven Shade plugin](https://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html#filters).

License and development
-----------------------

Expand Down
27 changes: 27 additions & 0 deletions byte-buddy-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,32 @@
</plugins>
</build>
</profile>
<profile>
<id>multi-release</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.plugin.compiler}</version>
<executions>
<execution>
<id>java8-multi-release</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/META-INF/versions/8</outputDirectory>
<target>1.8</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
27 changes: 27 additions & 0 deletions byte-buddy-dep/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,33 @@
</plugins>
</build>
</profile>
<profile>
<id>multi-release</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.plugin.compiler}</version>
<executions>
<execution>
<id>java8-multi-release</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/META-INF/versions/8</outputDirectory>
<target>1.8</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- Precompilation configuration for Java 1.4 class files. -->
<profile>
<id>java-4-precompile</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public void testIdentityField() throws Exception {
.defineField(FOO, Object.class, Visibility.PUBLIC)
.method(isEquals())
.intercept(EqualsMethod.isolated().withIdentityFields(named(FOO)))
.visit(DebuggingWrapper.makeDefault(true))
.make()
.load(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassLoadingStrategy.Default.WRAPPER);
assertThat(loaded.getLoadedAuxiliaryTypes().size(), is(0));
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<version.junit>4.13.2</version.junit>
<version.mockito>2.28.2</version.mockito>
<version.plugin.clean>3.2.0</version.plugin.clean>
<version.plugin.bundle>5.1.7</version.plugin.bundle>
<version.plugin.bundle>5.1.9</version.plugin.bundle>
<version.plugin.compiler>3.10.1</version.plugin.compiler>
<version.plugin.install>3.0.1</version.plugin.install>
<version.plugin.deploy>3.0.0</version.plugin.deploy>
Expand Down Expand Up @@ -183,7 +183,7 @@
<version>${version.plugin.release}</version>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>extras,gpg,gradle-release</releaseProfiles>
<releaseProfiles>extras,gpg,gradle-release,multi-release</releaseProfiles>
<autoVersionSubmodules>true</autoVersionSubmodules>
<tagNameFormat>byte-buddy-@{project.version}</tagNameFormat>
</configuration>
Expand Down

0 comments on commit a6a286d

Please sign in to comment.