!3 [sync] PR-2: upgrade to version 1.12.0

From: @openeuler-sync-bot 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
This commit is contained in:
openeuler-ci-bot 2022-10-28 06:28:12 +00:00 committed by Gitee
commit 59e1975ae9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 2675 additions and 536 deletions

View File

@ -1,48 +1,38 @@
--- 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
From 395fcc56d403d0625fe4930af4b2b772b0958fe1 Mon Sep 17 00:00:00 2001
From: Marian Koncek <mkoncek@redhat.com>
Date: Tue, 9 Nov 2021 11:55:22 +0100
Subject: [PATCH] Avoid bundling asm
---
byte-buddy/pom.xml | 70 ++++++++++------------------------------------
1 file changed, 15 insertions(+), 55 deletions(-)
diff --git a/byte-buddy/pom.xml b/byte-buddy/pom.xml
index 403f684..0d1d98c 100644
--- a/byte-buddy/pom.xml
+++ b/byte-buddy/pom.xml
@@ -26,8 +26,6 @@
-->
<properties>
- <shade.source>org.objectweb.asm</shade.source>
- <shade.target>net.bytebuddy.jar.asm</shade.target>
<packages.list>
<packages.list.external>
net.bytebuddy,
net.bytebuddy.agent.builder,
@@ -61,10 +59,7 @@
net.bytebuddy.pool,
@@ -62,9 +60,6 @@
net.bytebuddy.utility,
net.bytebuddy.utility.privilege,
- net.bytebuddy.utility.visitor,
net.bytebuddy.utility.visitor,
- ${shade.target},
- ${shade.target}.signature,
- ${shade.target}.commons
+ net.bytebuddy.utility.visitor
</packages.list>
</properties>
@@ -77,7 +72,17 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>byte-buddy-dep</artifactId>
- <version>${project.version}</version>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>${version.asm}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm-commons</artifactId>
+ <version>${version.asm}</version>
</dependency>
</dependencies>
@@ -99,47 +104,19 @@
</packages.list.external>
<packages.list.internal>
net.bytebuddy.utility.dispatcher
@@ -120,44 +115,6 @@
<createDependencyReducedPom>true</createDependencyReducedPom>
<createSourcesJar>true</createSourcesJar>
<createSourcesJar>${bytebuddy.extras}</createSourcesJar>
<shadeSourcesContent>true</shadeSourcesContent>
- <relocations>
- <relocation>
@ -52,22 +42,41 @@
- </relocations>
- <filters>
- <filter>
- <artifact>net.bytebuddy:byte-buddy-dep:*</artifact>
- <excludes>
- <exclude>META-INF/MANIFEST.MF</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.ow2.asm:*</artifact>
- <excludes>
- <exclude>META-INF/MANIFEST.MF</exclude>
- <exclude>**/module-info.class</exclude>
- <exclude>**/LICENSE</exclude>
- <exclude>**/NOTICE</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.ow2.asm:asm-commons</artifact>
- <includes>
- <include>org/objectweb/asm/commons/Remapper.class</include>
- <include>org/objectweb/asm/commons/SimpleRemapper.class</include>
- <include>org/objectweb/asm/commons/ClassRemapper.class</include>
- <include>org/objectweb/asm/commons/AnnotationRemapper.class</include>
- <include>org/objectweb/asm/commons/FieldRemapper.class</include>
- <include>org/objectweb/asm/commons/MethodRemapper.class</include>
- <include>org/objectweb/asm/commons/ModuleRemapper.class</include>
- <include>org/objectweb/asm/commons/SignatureRemapper.class</include>
- <include>org/objectweb/asm/commons/AnnotationRemapper.**</include>
- <include>org/objectweb/asm/commons/ClassRemapper.**</include>
- <include>org/objectweb/asm/commons/FieldRemapper.**</include>
- <include>org/objectweb/asm/commons/MethodRemapper.**</include>
- <include>org/objectweb/asm/commons/ModuleHashesAttribute.**</include>
- <include>org/objectweb/asm/commons/ModuleRemapper.**</include>
- <include>org/objectweb/asm/commons/RecordComponentRemapper.**</include>
- <include>org/objectweb/asm/commons/Remapper.**</include>
- <include>org/objectweb/asm/commons/SignatureRemapper.**</include>
- <include>org/objectweb/asm/commons/SimpleRemapper.**</include>
- </includes>
- </filter>
- </filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>net.bytebuddy.build.Plugin$Engine$Default</mainClass>
@@ -166,21 +123,14 @@
<resource>META-INF/LICENSE</resource>
</transformer>
</transformers>
+ <artifactSet>
@ -93,3 +102,23 @@
</plugin>
<!-- Disable pitest as it fails for empty modules -->
<plugin>
@@ -243,6 +193,16 @@
<artifactId>asm</artifactId>
<version>${version.asm}</version>
</dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>${version.asm}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm-commons</artifactId>
+ <version>${version.asm}</version>
+ </dependency>
</dependencies>
<executions>
<execution>
--
2.31.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
From 9763d7d30bcbb8bf56a6682bb7362f3de33a0802 Mon Sep 17 00:00:00 2001
From: Marian Koncek <mkoncek@redhat.com>
Date: Thu, 4 Feb 2021 15:17:13 +0100
Subject: [PATCH] Remove Java 14 tests
---
.../test/precompiled/SampleRecord.java | 24 -------------------
1 file changed, 24 deletions(-)
delete mode 100644 byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/SampleRecord.java
diff --git a/byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/SampleRecord.java b/byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/SampleRecord.java
deleted file mode 100644
index 522eefa..0000000
--- a/byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/SampleRecord.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2014 - Present Rafael Winterhalter
- *
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.bytebuddy.test.precompiled;
-
-import net.bytebuddy.description.type.AbstractTypeDescriptionTest;
-
-import java.util.List;
-
-public record SampleRecord(@AbstractTypeDescriptionTest.SampleAnnotation @TypeAnnotation(42) List<@TypeAnnotation(84) String> foo) {
- /* empty */
-}
--
2.29.2

View File

@ -0,0 +1,53 @@
From b7b286c16c4aba60ce47e0df3f6e97cfb005b21c Mon Sep 17 00:00:00 2001
From: Marian Koncek <mkoncek@redhat.com>
Date: Tue, 9 Nov 2021 12:23:28 +0100
Subject: [PATCH] Remove JDK 15 sealed classes
---
.../bytebuddy/test/precompiled/Sealed.java | 34 -------------------
1 file changed, 34 deletions(-)
delete mode 100644 byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/Sealed.java
diff --git a/byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/Sealed.java b/byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/Sealed.java
deleted file mode 100644
index 28d9835..0000000
--- a/byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/Sealed.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2014 - Present Rafael Winterhalter
- *
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.bytebuddy.test.precompiled;
-
-public sealed class Sealed permits Sealed.SubNonSealed, Sealed.SubSealed, Sealed.SubFinal {
-
- public static non-sealed class SubNonSealed extends Sealed {
- /* empty */
- }
-
- public static sealed class SubSealed extends Sealed permits SubSealed.SubSubFinal {
-
- public static final class SubSubFinal extends SubSealed {
- /* empty */
- }
- }
-
- public static final class SubFinal extends Sealed {
- /* empty */
- }
-}
--
2.31.1

BIN
byte-buddy-1.12.0.tar.gz Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,30 +1,20 @@
%bcond_with bootstrap
Name: byte-buddy
Version: 1.9.5
Version: 1.12.0
Release: 1
Summary: Runtime code generation for the Java virtual machine
License: ASL 2.0
License: Apache-2.0
URL: http://bytebuddy.net/
Source0: https://github.com/raphw/byte-buddy/archive/byte-buddy-%{version}.tar.gz
Patch0: no-unixsocket.patch
Patch1: avoid-bundling-asm.patch
Source1: xmvn-reactor
Patch0: 0001-Avoid-bundling-asm.patch
Patch1: 0002-Remove-dependencies.patch
Patch2: 0003-Remove-Java-14-tests.patch
Patch3: 0004-Remove-JDK-15-sealed-classes.patch
BuildRequires: maven-local
%if %{without bootstrap}
BuildRequires: mvn(junit:junit) mvn(net.bytebuddy:byte-buddy)
BuildRequires: mvn(net.bytebuddy:byte-buddy-dep) mvn(net.bytebuddy:byte-buddy-maven-plugin)
BuildRequires: mvn(org.apache.maven:maven-compat)
BuildRequires: mvn(org.apache.maven.plugin-testing:maven-plugin-testing-harness)
BuildRequires: mvn(org.mockito:mockito-core) mvn(org.ow2.asm:asm-analysis)
BuildRequires: mvn(org.ow2.asm:asm-util)
%endif
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) 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) mvn(org.eclipse.aether:aether-util)
BuildRequires: mvn(org.ow2.asm:asm) mvn(org.ow2.asm:asm-commons)
BuildRequires: java-1.8.0-openjdk-devel maven
Requires: byte-buddy-agent byte-buddy-maven-plugin byte-buddy-parent
BuildArch: noarch
%description
@ -36,18 +26,21 @@ interfaces for the creation of runtime proxies.
%package agent
Summary: Byte Buddy Java agent
Requires: byte-buddy
%description agent
The Byte Buddy Java agent allows to access the JVM's HotSwap feature.
%package maven-plugin
Summary: Byte Buddy Maven plugin
Requires: byte-buddy
%description maven-plugin
A plugin for post-processing class files via Byte Buddy in a Maven build.
%package parent
Summary: Byte Buddy parent POM
Requires: byte-buddy
%description parent
The parent artifact contains configuration information that
@ -61,18 +54,24 @@ This package contains API documentation for %{name}.
%prep
%setup -q -n %{name}-%{name}-%{version}
%patch0
%patch1
find -name *.jar -delete
find -name *.class -delete
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
rm byte-buddy-agent/src/test/java/net/bytebuddy/agent/VirtualMachineAttachmentTest.java
rm byte-buddy-agent/src/test/java/net/bytebuddy/agent/VirtualMachineForOpenJ9Test.java
mv byte-buddy-dep/src/precompiled/java/net/bytebuddy/build/*.java \
byte-buddy-dep/src/main/java/net/bytebuddy/build
mkdir -p byte-buddy-dep/src/test/java/net/bytebuddy/test/precompiled/
mv byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/*.java \
byte-buddy-dep/src/test/java/net/bytebuddy/test/precompiled/
%pom_disable_module byte-buddy-android
%pom_disable_module byte-buddy-android-test
%pom_disable_module byte-buddy-benchmark
%pom_disable_module byte-buddy-gradle-plugin
%pom_remove_plugin :jacoco-maven-plugin
%pom_remove_plugin :license-maven-plugin
%pom_remove_plugin :pitest-maven
@ -81,39 +80,74 @@ mv byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/*.java \
%pom_remove_plugin :jitwatch-jarscan-maven-plugin
%pom_remove_plugin :clirr-maven-plugin
%pom_remove_plugin :maven-release-plugin
%pom_remove_plugin :nexus-staging-maven-plugin
%pom_remove_plugin :byte-buddy-maven-plugin byte-buddy-dep
%pom_xpath_set "pom:createSourcesJar" "false" byte-buddy
%pom_remove_dep :findbugs-annotations
sed -i -e '/SuppressFBWarnings/d' $(grep -lr SuppressFBWarnings)
%pom_remove_plugin -r :modulemaker-maven-plugin
%if %{with bootstrap}
%pom_remove_plugin :byte-buddy-maven-plugin byte-buddy-dep
%endif
%pom_remove_dep org.ow2.asm:asm-deprecated
%pom_remove_plugin :maven-shade-plugin byte-buddy
%pom_remove_plugin :maven-shade-plugin byte-buddy-benchmark
%pom_remove_dep net.java.dev.jna:jna byte-buddy
%pom_remove_dep net.java.dev.jna:jna byte-buddy-dep
%pom_remove_dep net.java.dev.jna:jna byte-buddy-agent
%pom_remove_dep net.java.dev.jna:jna-platform byte-buddy
%pom_remove_dep net.java.dev.jna:jna-platform byte-buddy-dep
%pom_remove_dep net.java.dev.jna:jna-platform byte-buddy-agent
cp %{SOURCE1} ./.xmvn-reactor
echo `pwd` > absolute_prefix.log
sed -i 's/\//\\\//g' absolute_prefix.log
absolute_prefix=`head -n 1 absolute_prefix.log`
sed -i 's/absolute-prefix/'"$absolute_prefix"'/g' .xmvn-reactor
%build
%if %{with bootstrap}
%mvn_build -s -f -- -P'java8,!checks'
%else
%mvn_build -s -- -P'java8,!checks' -Dsourcecode.test.version=1.8 -Dmaven.test.failure.ignore=true
%endif
mvn package -Dsourcecode.test.version=1.8 -Dmaven.test.failure.ignore=true -P'java8,!checks' verify org.apache.maven.plugins:maven-javadoc-plugin:aggregate
%install
%mvn_install
%files -f .mfiles-%{name} -f .mfiles-%{name}-dep
%files
%attr(0644,root,root) /usr/share/maven-metadata/byte-buddy.xml
%attr(0755,root,root) %dir /usr/share/java/byte-buddy
%attr(0644,root,root) /usr/share/java/byte-buddy/byte-buddy.jar
%attr(0755,root,root) %dir /usr/share/maven-poms/byte-buddy
%attr(0644,root,root) /usr/share/maven-poms/byte-buddy/byte-buddy.pom
%attr(0755,root,root) %dir /usr/share/java/byte-buddy
%attr(0644,root,root) /usr/share/java/byte-buddy/byte-buddy-dep.jar
%attr(0755,root,root) %dir /usr/share/maven-poms/byte-buddy
%attr(0644,root,root) /usr/share/maven-poms/byte-buddy/byte-buddy-dep.pom
%doc README.md release-notes.md
%license LICENSE NOTICE
%files agent -f .mfiles-%{name}-agent
%files agent
%attr(0755,root,root) %dir /usr/share/java/byte-buddy
%attr(0644,root,root) /usr/share/java/byte-buddy/byte-buddy-agent.jar
%attr(0755,root,root) %dir /usr/share/maven-poms/byte-buddy
%attr(0644,root,root) /usr/share/maven-poms/byte-buddy/byte-buddy-agent.pom
%license LICENSE NOTICE
%files maven-plugin -f .mfiles-%{name}-maven-plugin
%files maven-plugin
%attr(0755,root,root) %dir /usr/share/java/byte-buddy
%attr(0644,root,root) /usr/share/java/byte-buddy/byte-buddy-maven-plugin.jar
%attr(0755,root,root) %dir /usr/share/maven-poms/byte-buddy
%attr(0644,root,root) /usr/share/maven-poms/byte-buddy/byte-buddy-maven-plugin.pom
%files parent -f .mfiles-%{name}-parent
%files parent
%attr(0755,root,root) %dir /usr/share/maven-poms/byte-buddy
%attr(0644,root,root) /usr/share/maven-poms/byte-buddy/byte-buddy-parent.pom
%license LICENSE NOTICE
%files javadoc -f .mfiles-javadoc
%files javadoc
/usr/share/javadoc/byte-buddy
%license LICENSE NOTICE
%changelog
* Thu Jun 16 2022 Ge Wang <wangge20@h-partners.com> - 1.12.0-1
- Upgrade to version 1.12.0
* Fri Aug 14 2020 leiju <leiju4@huawei.com> - 1.9.5-1
- Package init

View File

@ -1,460 +0,0 @@
--- 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 @@
<bytebuddy.agent>net.bytebuddy.agent.Installer</bytebuddy.agent>
<attach.package.sun>com.sun.tools.attach</attach.package.sun>
<attach.package.ibm>com.ibm.tools.attach</attach.package.ibm>
- <version.unixsocket>2.0.4</version.unixsocket>
<packages.list>net.bytebuddy.agent</packages.list>
</properties>
@@ -30,12 +29,6 @@
<dependencies>
<dependency>
- <groupId>com.kohlschutter.junixsocket</groupId>
- <artifactId>junixsocket-native-common</artifactId>
- <version>${version.unixsocket}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
--- 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();
- }
- }
}
}
--- byte-buddy-agent/src/test/java/net/bytebuddy/test/utility/UnixSocketRule.java 2018-11-22 17:18:25.000000000 +0000
+++ /dev/null 2018-10-26 11:27:39.627999956 +0100
@@ -1,48 +0,0 @@
-package net.bytebuddy.test.utility;
-
-import org.junit.rules.MethodRule;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.Statement;
-import org.newsclub.net.unix.AFUNIXSocket;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.util.logging.Logger;
-
-public class UnixSocketRule implements MethodRule {
-
- private final boolean enabled;
-
- public UnixSocketRule() {
- boolean enabled;
- try {
- Class.forName(AFUNIXSocket.class.getName(), true, UnixSocketRule.class.getClassLoader());
- enabled = true;
- } catch (Throwable ignored) {
- enabled = false;
- }
- this.enabled = enabled;
- }
-
- public Statement apply(Statement base, FrameworkMethod method, Object target) {
- return enabled || method.getAnnotation(Enforce.class) == null
- ? base
- : new NoOpStatement();
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.METHOD)
- public @interface Enforce {
-
- }
-
- private static class NoOpStatement extends Statement {
-
- public void evaluate() {
- Logger.getLogger("net.bytebuddy").warning("Ignoring Unix sockets on this machine");
- }
- }
-}
-
--- byte-buddy-agent/src/test/java/net/bytebuddy/agent/VirtualMachineForHotSpotTest.java 2018-11-22 17:18:25.000000000 +0000
+++ /dev/null 2018-10-26 11:27:39.627999956 +0100
@@ -1,116 +0,0 @@
-package net.bytebuddy.agent;
-
-import net.bytebuddy.test.utility.UnixSocketRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.MethodRule;
-import org.mockito.InOrder;
-
-import java.io.IOException;
-
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.spy;
-
-public class VirtualMachineForHotSpotTest {
-
- @Rule
- public MethodRule unixSocketRule = new UnixSocketRule();
-
- @Test
- @UnixSocketRule.Enforce
- public void testAttachment() throws Exception {
- VirtualMachine.ForHotSpot virtualMachine = spy(new PseudoMachine(
- "0".getBytes("UTF-8"),
- new byte[]{10}
- ));
- virtualMachine.loadAgent("foo", "bar");
- InOrder order = inOrder(virtualMachine);
- order.verify(virtualMachine).connect();
- order.verify(virtualMachine).write("1".getBytes("UTF-8"));
- order.verify(virtualMachine).write(new byte[1]);
- order.verify(virtualMachine).write("load".getBytes("UTF-8"));
- order.verify(virtualMachine).write(new byte[1]);
- order.verify(virtualMachine).write("instrument".getBytes("UTF-8"));
- order.verify(virtualMachine).write(new byte[1]);
- order.verify(virtualMachine).write(Boolean.FALSE.toString().getBytes("UTF-8"));
- order.verify(virtualMachine).write(new byte[1]);
- order.verify(virtualMachine).write("foo=bar".getBytes("UTF-8"));
- order.verify(virtualMachine).write(new byte[1]);
- }
-
- @Test
- @UnixSocketRule.Enforce
- public void testAttachmentWithoutArgument() throws Exception {
- VirtualMachine.ForHotSpot virtualMachine = spy(new PseudoMachine(
- "0".getBytes("UTF-8"),
- new byte[]{10}
- ));
- virtualMachine.loadAgent("foo", null);
- InOrder order = inOrder(virtualMachine);
- order.verify(virtualMachine).connect();
- order.verify(virtualMachine).write("1".getBytes("UTF-8"));
- order.verify(virtualMachine).write(new byte[1]);
- order.verify(virtualMachine).write("load".getBytes("UTF-8"));
- order.verify(virtualMachine).write(new byte[1]);
- order.verify(virtualMachine).write("instrument".getBytes("UTF-8"));
- order.verify(virtualMachine).write(new byte[1]);
- order.verify(virtualMachine).write(Boolean.FALSE.toString().getBytes("UTF-8"));
- order.verify(virtualMachine).write(new byte[1]);
- order.verify(virtualMachine).write("foo".getBytes("UTF-8"));
- order.verify(virtualMachine).write(new byte[1]);
- }
-
- @Test(expected = IOException.class)
- @UnixSocketRule.Enforce
- public void testAttachmentIncompatibleProtocol() throws Exception {
- new PseudoMachine(
- "1".getBytes("UTF-8"),
- "0".getBytes("UTF-8"),
- "1".getBytes("UTF-8"),
- new byte[]{10}
- ).loadAgent("foo", null);
- }
-
- @Test(expected = IllegalStateException.class)
- @UnixSocketRule.Enforce
- public void testAttachmentUnknownError() throws Exception {
- new PseudoMachine(
- "1".getBytes("UTF-8"),
- new byte[]{10},
- "foo".getBytes("UTF-8")
- ).loadAgent("foo", null);
- }
-
- private static class PseudoMachine extends VirtualMachine.ForHotSpot {
-
- private final byte[][] read;
-
- private int index;
-
- private PseudoMachine(byte[]... read) {
- super(null);
- this.read = read;
- }
-
- public void detach() {
- /* empty */
- }
-
- protected void connect() {
- /* empty */
- }
-
- protected int read(byte[] buffer) {
- if (index == read.length) {
- return -1;
- }
- byte[] read = this.read[index++];
- System.arraycopy(read, 0, buffer, 0, read.length);
- return read.length;
- }
-
- protected void write(byte[] buffer) {
- /* empty */
- }
- }
-}
\ No newline at end of file

221
xmvn-reactor Normal file
View File

@ -0,0 +1,221 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://fedorahosted.org/xmvn/METADATA/3.0.0">
<artifacts>
<artifact>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-parent</artifactId>
<extension>pom</extension>
<version>1.12.0</version>
<path>absolute-prefix/pom.xml</path>
<properties>
<type>pom</type>
</properties>
</artifact>
<artifact>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>1.12.0</version>
<path>absolute-prefix/byte-buddy-agent/target/byte-buddy-agent-1.12.0.jar</path>
<properties>
<type>jar</type>
<requiresJava>1.8</requiresJava>
</properties>
</artifact>
<artifact>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<extension>pom</extension>
<version>1.12.0</version>
<path>absolute-prefix/byte-buddy-agent/pom.xml</path>
<properties>
<type>jar</type>
<requiresJava>1.8</requiresJava>
</properties>
</artifact>
<artifact>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-dep</artifactId>
<version>1.12.0</version>
<path>absolute-prefix/byte-buddy-dep/target/byte-buddy-dep-1.12.0.jar</path>
<properties>
<type>jar</type>
<requiresJava>1.8</requiresJava>
</properties>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<requestedVersion>9.2</requestedVersion>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<requestedVersion>9.2</requestedVersion>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-analysis</artifactId>
</exclusion>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</artifact>
<artifact>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-dep</artifactId>
<extension>pom</extension>
<version>1.12.0</version>
<path>absolute-prefix/byte-buddy-dep/pom.xml</path>
<properties>
<type>jar</type>
<requiresJava>1.8</requiresJava>
</properties>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<requestedVersion>9.2</requestedVersion>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<requestedVersion>9.2</requestedVersion>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-analysis</artifactId>
</exclusion>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</artifact>
<artifact>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.12.0</version>
<path>absolute-prefix/byte-buddy/target/byte-buddy-1.12.0.jar</path>
<properties>
<type>jar</type>
<requiresJava>1.8</requiresJava>
</properties>
<dependencies>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-dep</artifactId>
<requestedVersion>1.12.0</requestedVersion>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<requestedVersion>9.2</requestedVersion>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<requestedVersion>9.2</requestedVersion>
</dependency>
</dependencies>
</artifact>
<artifact>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<extension>pom</extension>
<version>1.12.0</version>
<path>absolute-prefix/byte-buddy/pom.xml</path>
<properties>
<type>jar</type>
<requiresJava>1.8</requiresJava>
</properties>
<dependencies>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-dep</artifactId>
<requestedVersion>1.12.0</requestedVersion>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<requestedVersion>9.2</requestedVersion>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<requestedVersion>9.2</requestedVersion>
</dependency>
</dependencies>
</artifact>
<artifact>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-maven-plugin</artifactId>
<version>1.12.0</version>
<path>absolute-prefix/byte-buddy-maven-plugin/target/byte-buddy-maven-plugin-1.12.0.jar</path>
<properties>
<type>maven-plugin</type>
<requiresJava>1.8</requiresJava>
</properties>
<dependencies>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<requestedVersion>1.12.0</requestedVersion>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<requestedVersion>3.2.5</requestedVersion>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<requestedVersion>1.1.0</requestedVersion>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-util</artifactId>
<requestedVersion>1.1.0</requestedVersion>
</dependency>
</dependencies>
</artifact>
<artifact>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-maven-plugin</artifactId>
<extension>pom</extension>
<version>1.12.0</version>
<path>absolute-prefix/byte-buddy-maven-plugin/pom.xml</path>
<properties>
<type>maven-plugin</type>
<requiresJava>1.8</requiresJava>
</properties>
<dependencies>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<requestedVersion>1.12.0</requestedVersion>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<requestedVersion>3.2.5</requestedVersion>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<requestedVersion>1.1.0</requestedVersion>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-util</artifactId>
<requestedVersion>1.1.0</requestedVersion>
</dependency>
</dependencies>
</artifact>
</artifacts>
</metadata>