From 77732becaabdcda675adf0f840c6285064c1a00a Mon Sep 17 00:00:00 2001 From: Mat Booth Date: Tue, 4 Dec 2018 11:02:03 +0000 Subject: [PATCH] Update to latest upstream release --- .gitignore | 2 + avoid-bundling-asm.patch | 95 +++++++++++++ byte-buddy.spec | 159 +++++++++++---------- no-unixsocket.patch | 289 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 471 insertions(+), 74 deletions(-) create mode 100644 .gitignore create mode 100644 avoid-bundling-asm.patch create mode 100644 no-unixsocket.patch diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4106cf2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/*.src.rpm +/*.tar.gz diff --git a/avoid-bundling-asm.patch b/avoid-bundling-asm.patch new file mode 100644 index 0000000..f04755c --- /dev/null +++ b/avoid-bundling-asm.patch @@ -0,0 +1,95 @@ +--- byte-buddy/pom.xml.orig 2018-11-22 17:18:25.000000000 +0000 ++++ byte-buddy/pom.xml 2018-11-30 17:48:48.655978937 +0000 +@@ -26,8 +26,6 @@ + --> + + +- org.objectweb.asm +- net.bytebuddy.jar.asm + + net.bytebuddy, + net.bytebuddy.agent.builder, +@@ -61,10 +59,7 @@ + net.bytebuddy.pool, + net.bytebuddy.utility, + net.bytebuddy.utility.privilege, +- net.bytebuddy.utility.visitor, +- ${shade.target}, +- ${shade.target}.signature, +- ${shade.target}.commons ++ net.bytebuddy.utility.visitor + + + +@@ -77,7 +72,17 @@ + + ${project.groupId} + byte-buddy-dep +- ${project.version} ++ ${project.version} ++ ++ ++ org.ow2.asm ++ asm ++ ${version.asm} ++ ++ ++ org.ow2.asm ++ asm-commons ++ ${version.asm} + + + +@@ -99,47 +104,19 @@ + true + true + true +- +- +- ${shade.source} +- ${shade.target} +- +- +- +- +- org.ow2.asm:asm-commons +- +- org/objectweb/asm/commons/Remapper.class +- org/objectweb/asm/commons/SimpleRemapper.class +- org/objectweb/asm/commons/ClassRemapper.class +- org/objectweb/asm/commons/AnnotationRemapper.class +- org/objectweb/asm/commons/FieldRemapper.class +- org/objectweb/asm/commons/MethodRemapper.class +- org/objectweb/asm/commons/ModuleRemapper.class +- org/objectweb/asm/commons/SignatureRemapper.class +- +- +- + + + net.bytebuddy.build.Plugin$Engine$Default + + ++ ++ ++ org.ow2.asm:* ++ ++ + + + +- +- +- org.ow2.asm +- asm +- ${version.asm} +- +- +- org.ow2.asm +- asm-commons +- ${version.asm} +- +- + + + diff --git a/byte-buddy.spec b/byte-buddy.spec index e93df9c..4577332 100644 --- a/byte-buddy.spec +++ b/byte-buddy.spec @@ -1,26 +1,37 @@ +# Byte Buddy requires itself to build, so set this flag +# to break the bootstrap cycle +%bcond_with bootstrap + Name: byte-buddy -Version: 1.3.19 +Version: 1.9.5 Release: 1%{?dist} Summary: Runtime code generation for the Java virtual machine License: ASL 2.0 URL: http://bytebuddy.net/ Source0: https://github.com/raphw/byte-buddy/archive/%{name}-%{version}.tar.gz -BuildRequires: maven-local -BuildRequires: mvn(cglib:cglib) -BuildRequires: mvn(com.google.code.findbugs:annotations) -BuildRequires: mvn(junit:junit) -BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) -BuildRequires: mvn(org.apache.maven.plugins:maven-enforcer-plugin) -BuildRequires: mvn(org.apache.maven.plugins:maven-release-plugin) -BuildRequires: mvn(org.javassist:javassist) -BuildRequires: mvn(org.mockito:mockito-core) -BuildRequires: mvn(org.openjdk.jmh:jmh-core) -BuildRequires: mvn(org.openjdk.jmh:jmh-generator-annprocess) -BuildRequires: mvn(org.ow2.asm:asm) -BuildRequires: mvn(org.ow2.asm:asm-analysis) -BuildRequires: mvn(org.ow2.asm:asm-commons) -BuildRequires: mvn(org.ow2.asm:asm-util) +# Patch out use of a unixsocket lib that is not in Fedora +Patch0: no-unixsocket.patch + +# Patch the build to avoid bundling inside shaded jars +Patch1: avoid-bundling-asm.patch + +BuildRequires: maven-local +%if %{without bootstrap} +BuildRequires: mvn(net.bytebuddy:byte-buddy) +BuildRequires: mvn(net.bytebuddy:byte-buddy-maven-plugin) +%endif +BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) +BuildRequires: mvn(org.apache.maven:maven-core) +BuildRequires: mvn(org.apache.maven:maven-plugin-api) +BuildRequires: mvn(org.apache.maven.plugins:maven-plugin-plugin) +BuildRequires: mvn(org.apache.maven.plugins:maven-shade-plugin) +BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-annotations) +BuildRequires: mvn(org.codehaus.mojo:build-helper-maven-plugin) +BuildRequires: mvn(org.eclipse.aether:aether-api) +BuildRequires: mvn(org.eclipse.aether:aether-util) +BuildRequires: mvn(org.ow2.asm:asm) +BuildRequires: mvn(org.ow2.asm:asm-commons) BuildArch: noarch @@ -32,103 +43,103 @@ allows the creation of arbitrary classes and is not limited to implementing interfaces for the creation of runtime proxies. %package agent -Summary: Byte Buddy Java agent +Summary: Byte Buddy Java agent %description agent -The Byte Buddy Java agent allows to access the -JVM's HotSwap feature. +The Byte Buddy Java agent allows to access the JVM's HotSwap feature. -%package benchmark -Summary: Byte Buddy benchmarks +%package maven-plugin +Summary: Byte Buddy Maven plugin -%description benchmark -A benchmark of Byte Buddy using the JMH. +%description maven-plugin +A plugin for post-processing class files via Byte Buddy in a Maven build. %package parent -Summary: Byte Buddy Parent POM +Summary: Byte Buddy parent POM %description parent The parent artifact contains configuration information that concern all modules. %package javadoc -Summary: Javadoc for %{name} +Summary: Javadoc for %{name} %description javadoc -This package contains javadoc for %{name}. +This package contains API documentation for %{name}. %prep %setup -q -n %{name}-%{name}-%{version} +%patch0 +%patch1 -# No source code, repackage asm libraries only -%pom_disable_module %{name} -%pom_disable_module %{name}-android -# Unavailable plugin -%pom_remove_plugin -r com.github.ferstl:jitwatch-jarscan-maven-plugin -%pom_remove_plugin -r org.codehaus.mojo:animal-sniffer-maven-plugin -%pom_remove_plugin -r org.codehaus.mojo:cobertura-maven-plugin -%pom_remove_plugin -r org.codehaus.mojo:findbugs-maven-plugin -%pom_remove_plugin -r org.eluder.coveralls:coveralls-maven-plugin -%pom_remove_plugin -r org.pitest:pitest-maven -%pom_remove_plugin -r org.codehaus.mojo:clirr-maven-plugin -# Unwanted tasks -%pom_remove_plugin -r org.apache.maven.plugins:maven-checkstyle-plugin -%pom_remove_plugin -r org.apache.maven.plugins:maven-gpg-plugin -%pom_remove_plugin -r org.apache.maven.plugins:maven-source-plugin -%pom_xpath_remove -r "pom:plugin[pom:artifactId = 'maven-javadoc-plugin']/pom:executions" -%pom_xpath_inject "pom:plugin[pom:artifactId='maven-javadoc-plugin']/pom:configuration" "-Xdoclint:none" +# Remove pre-built jars +find -name *.jar -delete +find -name *.class -delete -%pom_remove_plugin -r org.apache.maven.plugins:maven-shade-plugin %{name}-benchmark +# Cause pre-compiled stuff to be re-compiled +mv byte-buddy-dep/src/precompiled/java/net/bytebuddy/build/*.java \ + byte-buddy-dep/src/main/java/net/bytebuddy/build -%pom_change_dep cglib: :cglib %{name}-benchmark +# Don't ship android or benchmark modules +%pom_disable_module byte-buddy-android +%pom_disable_module byte-buddy-benchmark -find %{name}-dep/src/test/java -name "*.java" -exec sed -i "s|org\.mockito\.asm|org\.objectweb\.asm|g" {} + +# Don't ship gradle plugin +%pom_disable_module byte-buddy-gradle-plugin -%pom_xpath_set "pom:project/pom:packaging" bundle %{name}-dep -%pom_add_plugin org.apache.felix:maven-bundle-plugin:'${version.plugin.bundle}' %{name}-dep " -true - - - Byte Buddy (without dependencies) - \${project.groupId}.byte-buddy - \${project.version} - net.bytebuddy* - - - - - bundle-manifest - process-classes - - manifest - - -" +# Remove check plugins unneeded by RPM builds +%pom_remove_plugin :jacoco-maven-plugin +%pom_remove_plugin :license-maven-plugin +%pom_remove_plugin :pitest-maven +%pom_remove_plugin :coveralls-maven-plugin +%pom_remove_plugin :spotbugs-maven-plugin +%pom_remove_plugin :jitwatch-jarscan-maven-plugin +%pom_remove_plugin :clirr-maven-plugin +%pom_remove_plugin :maven-release-plugin -%mvn_alias :%{name}-dep :%{name} +# Drop build dep on findbugs annotations, used only by the above check plugins +%pom_remove_dep :findbugs-annotations +sed -i -e '/SuppressFBWarnings/d' $(grep -lr SuppressFBWarnings) + +# Plugin for generating Java 9 module-info file is not in Fedora +%pom_remove_plugin -r :modulemaker-maven-plugin + +%if %{with bootstrap} +# Remove circular self-dependency to allow bootstrapping +%pom_remove_plugin :byte-buddy-maven-plugin byte-buddy-dep +%endif %build - -%mvn_build -s -- -Pextras +# Cannot run the test suite until mockito is updated in Fedora +# Cannot update mockito until this package is in Fedora +%mvn_build -s -f -- -P'java8,!checks' %install %mvn_install -%files -f .mfiles-%{name}-dep +%files -f .mfiles-%{name} -f .mfiles-%{name}-dep %doc README.md release-notes.md +%license LICENSE NOTICE %files agent -f .mfiles-%{name}-agent -%license LICENSE +%license LICENSE NOTICE -%files benchmark -f .mfiles-%{name}-benchmark +%files maven-plugin -f .mfiles-%{name}-maven-plugin %files parent -f .mfiles-%{name}-parent -%license LICENSE +%license LICENSE NOTICE %files javadoc -f .mfiles-javadoc -%license LICENSE +%license LICENSE NOTICE %changelog +* Fri Nov 30 2018 Mat Booth - 1.9.5-1 +- Update to latest upstream release +- Add a bootstrap mode to break circular self-dependency +- Patch out use of optional external unixsocket library that is not present + in Fedora +- Patch to avoid bundling ASM inside the shaded jar + * Wed May 25 2016 gil cattaneo 1.3.19-1 - update to 1.3.19 diff --git a/no-unixsocket.patch b/no-unixsocket.patch new file mode 100644 index 0000000..9b06132 --- /dev/null +++ b/no-unixsocket.patch @@ -0,0 +1,289 @@ +--- byte-buddy-agent/pom.xml.orig 2018-11-30 11:43:29.016481386 +0000 ++++ byte-buddy-agent/pom.xml 2018-11-30 11:43:42.676439662 +0000 +@@ -15,7 +15,6 @@ + net.bytebuddy.agent.Installer + com.sun.tools.attach + com.ibm.tools.attach +- 2.0.4 + net.bytebuddy.agent + + +@@ -30,12 +29,6 @@ + + + +- com.kohlschutter.junixsocket +- junixsocket-native-common +- ${version.unixsocket} +- provided +- +- + junit + junit + ${version.junit} +--- byte-buddy-agent/src/main/java/net/bytebuddy/agent/ByteBuddyAgent.java.orig 2018-11-30 11:22:23.274443432 +0000 ++++ byte-buddy-agent/src/main/java/net/bytebuddy/agent/ByteBuddyAgent.java 2018-11-30 11:42:22.236685381 +0000 +@@ -541,8 +541,7 @@ + ForStandardToolsJarVm.JVM_ROOT, + ForStandardToolsJarVm.JDK_ROOT, + ForStandardToolsJarVm.MACINTOSH, +- ForUserDefinedToolsJar.INSTANCE, +- ForUnixHotSpotVm.INSTANCE); ++ ForUserDefinedToolsJar.INSTANCE); + + /** + * Attempts the creation of an accessor for a specific JVM's attachment API. +@@ -922,28 +921,6 @@ + } + } + } +- +- /** +- * An attachment provider using a custom protocol implementation for HotSpot on Unix. +- */ +- enum ForUnixHotSpotVm implements AttachmentProvider { +- +- /** +- * The singleton instance. +- */ +- INSTANCE; +- +- /** +- * {@inheritDoc} +- */ +- public Accessor attempt() { +- try { +- return new Accessor.Simple.WithoutExternalAttachment(VirtualMachine.ForHotSpot.OnUnix.assertAvailability()); +- } catch (Throwable ignored) { +- return Accessor.Unavailable.INSTANCE; +- } +- } +- } + + /** + * A compound attachment provider that attempts the attachment by delegation to other providers. If +--- byte-buddy-agent/src/main/java/net/bytebuddy/agent/VirtualMachine.java.orig 2018-11-30 11:22:55.830341642 +0000 ++++ byte-buddy-agent/src/main/java/net/bytebuddy/agent/VirtualMachine.java 2018-11-30 11:38:21.698438915 +0000 +@@ -16,8 +16,6 @@ + package net.bytebuddy.agent; + + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +-import org.newsclub.net.unix.AFUNIXSocket; +-import org.newsclub.net.unix.AFUNIXSocketAddress; + + import java.io.File; + import java.io.IOException; +@@ -172,213 +170,5 @@ + */ + protected abstract void write(byte[] buffer) throws IOException; + +- /** +- * A virtual machine implementation for a HotSpot VM running on Unix. +- */ +- public static class OnUnix extends ForHotSpot { +- +- /** +- * The default amount of attempts to connect. +- */ +- private static final int DEFAULT_ATTEMPTS = 10; +- +- /** +- * The default pause between two attempts. +- */ +- private static final long DEFAULT_PAUSE = 200; +- +- /** +- * The default socket timeout. +- */ +- private static final long DEFAULT_TIMEOUT = 5000; +- +- /** +- * The temporary directory on Unix systems. +- */ +- private static final String TEMPORARY_DIRECTORY = "/tmp"; +- +- /** +- * The name prefix for a socket. +- */ +- private static final String SOCKET_FILE_PREFIX = ".java_pid"; +- +- /** +- * The name prefix for an attachment file indicator. +- */ +- private static final String ATTACH_FILE_PREFIX = ".attach_pid"; +- +- /** +- * The Unix socket to use for communication. The containing object is supposed to be an instance +- * of {@link AFUNIXSocket} which is however not set to avoid eager loading +- */ +- private final Object socket; +- +- /** +- * The number of attempts to connect. +- */ +- private final int attempts; +- +- /** +- * The time to pause between attempts. +- */ +- private final long pause; +- +- /** +- * The socket timeout. +- */ +- private final long timeout; +- +- /** +- * The time unit of the pause time. +- */ +- private final TimeUnit timeUnit; +- +- /** +- * Creates a new VM implementation for a HotSpot VM running on Unix. +- * +- * @param processId The process id of the target VM. +- * @param socket The Unix socket to use for communication. +- * @param attempts The number of attempts to connect. +- * @param pause The pause time between two VMs. +- * @param timeout The socket timeout. +- * @param timeUnit The time unit of the pause time. +- */ +- public OnUnix(String processId, Object socket, int attempts, long pause, long timeout, TimeUnit timeUnit) { +- super(processId); +- this.socket = socket; +- this.attempts = attempts; +- this.pause = pause; +- this.timeout = timeout; +- this.timeUnit = timeUnit; +- } +- +- /** +- * Asserts the availability of this virtual machine implementation. If the Unix socket library is missing or +- * if this VM does not support Unix socket communication, a {@link Throwable} is thrown. +- * +- * @return This virtual machine type. +- * @throws Throwable If this attachment method is not available. +- */ +- public static Class assertAvailability() throws Throwable { +- try { +- Class moduleType = Class.forName("java.lang.Module"); +- Method getModule = Class.class.getMethod("getModule"), canRead = moduleType.getMethod("canRead", moduleType); +- Object thisModule = getModule.invoke(OnUnix.class), otherModule = getModule.invoke(AFUNIXSocket.class); +- if (!(Boolean) canRead.invoke(thisModule, otherModule)) { +- moduleType.getMethod("addReads", moduleType).invoke(thisModule, otherModule); +- } +- return doAssertAvailability(); +- } catch (ClassNotFoundException ignored) { +- return doAssertAvailability(); +- } +- } +- +- /** +- * Asserts the availability of this virtual machine implementation. +- * +- * @return This virtual machine type. +- */ +- private static Class doAssertAvailability() { +- if (!AFUNIXSocket.isSupported()) { +- throw new IllegalStateException("POSIX sockets are not supported on the current system"); +- } else if (!System.getProperty("java.vm.name").toLowerCase(Locale.US).contains("hotspot")) { +- throw new IllegalStateException("Cannot apply attachment on non-Hotspot compatible VM"); +- } else { +- return OnUnix.class; +- } +- } +- +- /** +- * Attaches to the supplied VM process. +- * +- * @param processId The process id of the target VM. +- * @return An appropriate virtual machine implementation. +- * @throws IOException If an I/O exception occurs. +- */ +- public static VirtualMachine attach(String processId) throws IOException { +- return new OnUnix(processId, AFUNIXSocket.newInstance(), DEFAULT_ATTEMPTS, DEFAULT_PAUSE, DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); +- } +- +- /** +- * {@inheritDoc} +- */ +- @SuppressFBWarnings(value = "DMI_HARDCODED_ABSOLUTE_FILENAME", justification = "This is a Unix-specific implementation") +- protected void connect() throws IOException { +- File socketFile = new File(TEMPORARY_DIRECTORY, SOCKET_FILE_PREFIX + processId); +- if (!socketFile.exists()) { +- String target = ATTACH_FILE_PREFIX + processId, path = "/proc/" + processId + "/cwd/" + target; +- File attachFile = new File(path); +- try { +- if (!attachFile.createNewFile() && !attachFile.isFile()) { +- throw new IllegalStateException("Could not create attach file: " + attachFile); +- } +- } catch (IOException ignored) { +- attachFile = new File(TEMPORARY_DIRECTORY, target); +- if (!attachFile.createNewFile() && !attachFile.isFile()) { +- throw new IllegalStateException("Could not create attach file: " + attachFile); +- } +- } +- try { +- // The HotSpot attachment API attempts to send the signal to all children of a process +- Process process = Runtime.getRuntime().exec("kill -3 " + processId); +- int attempts = this.attempts; +- boolean killed = false; +- do { +- try { +- if (process.exitValue() != 0) { +- throw new IllegalStateException("Error while sending signal to target VM: " + processId); +- } +- killed = true; +- break; +- } catch (IllegalThreadStateException ignored) { +- attempts -= 1; +- Thread.sleep(timeUnit.toMillis(pause)); +- } +- } while (attempts > 0); +- if (!killed) { +- throw new IllegalStateException("Target VM did not respond to signal: " + processId); +- } +- attempts = this.attempts; +- while (attempts-- > 0 && !socketFile.exists()) { +- Thread.sleep(timeUnit.toMillis(pause)); +- } +- if (!socketFile.exists()) { +- throw new IllegalStateException("Target VM did not respond: " + processId); +- } +- } catch (InterruptedException exception) { +- throw new IllegalStateException("Interrupted during wait for process", exception); +- } finally { +- if (!attachFile.delete()) { +- attachFile.deleteOnExit(); +- } +- } +- } +- if (timeout != 0) { +- ((AFUNIXSocket) socket).setSoTimeout((int) timeUnit.toMillis(timeout)); +- } +- ((AFUNIXSocket) socket).connect(new AFUNIXSocketAddress(socketFile)); +- } +- +- /** +- * {@inheritDoc} +- */ +- public int read(byte[] buffer) throws IOException { +- return ((AFUNIXSocket) this.socket).getInputStream().read(buffer); +- } +- +- /** +- * {@inheritDoc} +- */ +- public void write(byte[] buffer) throws IOException { +- ((AFUNIXSocket) this.socket).getOutputStream().write(buffer); +- } +- +- /** +- * {@inheritDoc} +- */ +- public void detach() throws IOException { +- ((AFUNIXSocket) this.socket).close(); +- } +- } + } + }