From 9cdfefe39242a441ac8ac1e67f07e8e91d1f972d Mon Sep 17 00:00:00 2001 From: eabdullin Date: Thu, 13 Mar 2025 13:50:27 +0000 Subject: [PATCH] import CS byte-buddy-1.14.2-21.module_el9+1171+eb38a622 --- .byte-buddy.metadata | 2 +- .gitignore | 2 +- SOURCES/0001-Avoid-bundling-asm.patch | 100 +++ ...a.patch => 0002-Remove-dependencies.patch} | 758 +++++++----------- SOURCES/0003-Fix-broken-modular-jars.patch | 36 + SOURCES/avoid-bundling-asm.patch | 104 --- SPECS/byte-buddy.spec | 202 +++-- 7 files changed, 590 insertions(+), 614 deletions(-) create mode 100644 SOURCES/0001-Avoid-bundling-asm.patch rename SOURCES/{0001-Remove-dependency-on-jna.patch => 0002-Remove-dependencies.patch} (79%) create mode 100644 SOURCES/0003-Fix-broken-modular-jars.patch delete mode 100644 SOURCES/avoid-bundling-asm.patch diff --git a/.byte-buddy.metadata b/.byte-buddy.metadata index f1f80e0..d9900e4 100644 --- a/.byte-buddy.metadata +++ b/.byte-buddy.metadata @@ -1 +1 @@ -f22989caeb364be1c4cdccfe48682a63c4147d23 SOURCES/byte-buddy-1.10.1.tar.gz +d9856183f1add64cb10c6b47f4215efa31ed3a1f SOURCES/byte-buddy-1.14.2.tar.gz diff --git a/.gitignore b/.gitignore index be92290..b3c51ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/byte-buddy-1.10.1.tar.gz +SOURCES/byte-buddy-1.14.2.tar.gz diff --git a/SOURCES/0001-Avoid-bundling-asm.patch b/SOURCES/0001-Avoid-bundling-asm.patch new file mode 100644 index 0000000..bc8bcd1 --- /dev/null +++ b/SOURCES/0001-Avoid-bundling-asm.patch @@ -0,0 +1,100 @@ +From beaed3d4ce80ae695f7f2a3e02e11c39fbb4e1f8 Mon Sep 17 00:00:00 2001 +From: Marian Koncek +Date: Thu, 23 Feb 2023 13:59:25 +0100 +Subject: [PATCH] Avoid bundling asm + +--- + byte-buddy/pom.xml | 56 +++++++++------------------------------------- + 1 file changed, 11 insertions(+), 45 deletions(-) + +diff --git a/byte-buddy/pom.xml b/byte-buddy/pom.xml +index 625e0d6..97ac874 100644 +--- a/byte-buddy/pom.xml ++++ b/byte-buddy/pom.xml +@@ -26,8 +26,6 @@ + --> + + +- org.objectweb.asm +- net.bytebuddy.jar.asm + + net.bytebuddy, + net.bytebuddy.agent.builder, +@@ -62,10 +60,7 @@ + net.bytebuddy.utility, + net.bytebuddy.utility.nullability, + net.bytebuddy.utility.privilege, +- net.bytebuddy.utility.visitor, +- ${shade.target}, +- ${shade.target}.signature, +- ${shade.target}.commons ++ net.bytebuddy.utility.visitor + + + net.bytebuddy.utility.dispatcher +@@ -166,6 +161,16 @@ + asm + ${version.asm} + ++ ++ org.ow2.asm ++ asm ++ ${version.asm} ++ ++ ++ org.ow2.asm ++ asm-commons ++ ${version.asm} ++ + + + +@@ -253,45 +258,6 @@ + true + ${bytebuddy.extras} + true +- +- +- ${shade.source} +- ${shade.target} +- +- +- +- +- net.bytebuddy:byte-buddy-dep:* +- +- META-INF/MANIFEST.MF +- META-INF/maven/** +- +- +- +- org.ow2.asm:* +- +- META-INF/MANIFEST.MF +- **/module-info.class +- **/LICENSE +- **/NOTICE +- +- +- +- org.ow2.asm:asm-commons +- +- org/objectweb/asm/commons/AnnotationRemapper.** +- org/objectweb/asm/commons/ClassRemapper.** +- org/objectweb/asm/commons/FieldRemapper.** +- org/objectweb/asm/commons/MethodRemapper.** +- org/objectweb/asm/commons/ModuleHashesAttribute.** +- org/objectweb/asm/commons/ModuleRemapper.** +- org/objectweb/asm/commons/RecordComponentRemapper.** +- org/objectweb/asm/commons/Remapper.** +- org/objectweb/asm/commons/SignatureRemapper.** +- org/objectweb/asm/commons/SimpleRemapper.** +- +- +- + + + net.bytebuddy.build.Plugin$Engine$Default +-- +2.39.1 + diff --git a/SOURCES/0001-Remove-dependency-on-jna.patch b/SOURCES/0002-Remove-dependencies.patch similarity index 79% rename from SOURCES/0001-Remove-dependency-on-jna.patch rename to SOURCES/0002-Remove-dependencies.patch index ffbb24f..4f19e9f 100644 --- a/SOURCES/0001-Remove-dependency-on-jna.patch +++ b/SOURCES/0002-Remove-dependencies.patch @@ -1,14 +1,15 @@ -From 9f9ca4a15ef217284557d1fa88dfed8551a365ae Mon Sep 17 00:00:00 2001 +From f7e74e70c82177c5a6b45a9c21e1d3950fb3eca1 Mon Sep 17 00:00:00 2001 From: Marian Koncek -Date: Thu, 12 Sep 2019 11:18:51 +0200 -Subject: [PATCH] Remove dependency on jna +Date: Thu, 23 Feb 2023 11:19:59 +0100 +Subject: [PATCH] Remove dependencies --- - .../net/bytebuddy/agent/VirtualMachine.java | 2234 +++-------------- - 1 file changed, 357 insertions(+), 1877 deletions(-) + .../net/bytebuddy/agent/VirtualMachine.java | 2006 +---------------- + .../dynamic/loading/ClassInjector.java | 95 +- + 2 files changed, 2 insertions(+), 2099 deletions(-) diff --git a/byte-buddy-agent/src/main/java/net/bytebuddy/agent/VirtualMachine.java b/byte-buddy-agent/src/main/java/net/bytebuddy/agent/VirtualMachine.java -index 6e16424..e2138c1 100644 +index 7a748ad..d15d47d 100644 --- a/byte-buddy-agent/src/main/java/net/bytebuddy/agent/VirtualMachine.java +++ b/byte-buddy-agent/src/main/java/net/bytebuddy/agent/VirtualMachine.java @@ -15,11 +15,6 @@ @@ -21,9 +22,9 @@ index 6e16424..e2138c1 100644 -import com.sun.jna.win32.StdCallLibrary; -import com.sun.jna.win32.W32APIOptions; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - - import java.io.*; -@@ -149,11 +144,6 @@ public interface VirtualMachine { + import net.bytebuddy.agent.utility.nullability.MaybeNull; + import net.bytebuddy.agent.utility.nullability.UnknownNull; +@@ -151,15 +146,7 @@ public interface VirtualMachine { * {@inheritDoc} */ public Class run() { @@ -32,10 +33,15 @@ index 6e16424..e2138c1 100644 - } catch (ClassNotFoundException exception) { - throw new IllegalStateException("Optional JNA dependency is not available", exception); - } - return System.getProperty("java.vm.vendor").toUpperCase(Locale.US).contains("J9") - ? ForOpenJ9.class - : ForHotSpot.class; -@@ -227,23 +217,6 @@ public interface VirtualMachine { +- return System.getProperty("java.vm.name", "").toUpperCase(Locale.US).contains("J9") +- ? ForOpenJ9.class +- : ForHotSpot.class; +- ++ throw new IllegalStateException("Optional JNA dependency is not available"); + } + } + +@@ -229,23 +216,6 @@ public interface VirtualMachine { this.connection = connection; } @@ -59,40 +65,26 @@ index 6e16424..e2138c1 100644 /** * Attaches to the supplied process id using the supplied connection factory. * -@@ -679,1905 +652,412 @@ public interface VirtualMachine { +@@ -681,1980 +651,6 @@ public interface VirtualMachine { */ protected abstract int read(T connection, byte[] buffer) throws IOException; } -+ } -+ } - +- - /** - * Implements a connection for a Posix socket in JNA. - */ - class ForJnaPosixSocket extends OnPersistentByteChannel { -+ /** -+ * A virtual machine attachment implementation for OpenJ9 or any compatible JVM. -+ */ -+ class ForOpenJ9 extends AbstractBase { - +- - /** - * The JNA library to use. - */ - private final PosixLibrary library; -+ /** -+ * The temporary folder for attachment files for OpenJ9 VMs. -+ */ -+ private static final String IBM_TEMPORARY_FOLDER = "com.ibm.tools.attach.directory"; - +- - /** - * The POSIX socket. - */ - private final File socket; -+ /** -+ * The socket on which this VM and the target VM communicate. -+ */ -+ private final Socket socket; - +- - /** - * Creates a connection for a virtual posix socket implemented in JNA. - * @@ -103,44 +95,18 @@ index 6e16424..e2138c1 100644 - this.library = library; - this.socket = socket; - } -+ /** -+ * Creates a new virtual machine connection for OpenJ9. -+ * -+ * @param socket The socket on which this VM and the target VM communicate. -+ */ -+ protected ForOpenJ9(Socket socket) { -+ this.socket = socket; -+ } - +- - @Override - protected Integer connect() { - int handle = library.socket(1, 1, 0); -+ /** -+ * Attaches to the supplied process id. -+ * -+ * @param processId The process id. -+ * @param timeout The timeout for establishing the socket connection. -+ * @param dispatcher The connector to use to communicate with the target VM. -+ * @return A suitable virtual machine implementation. -+ * @throws IOException If an IO exception occurs during establishing the connection. -+ */ -+ public static VirtualMachine attach(String processId, int timeout, Dispatcher dispatcher) throws IOException { -+ File directory = new File(System.getProperty(IBM_TEMPORARY_FOLDER, dispatcher.getTemporaryFolder()), ".com_ibm_tools_attach"); -+ RandomAccessFile attachLock = new RandomAccessFile(new File(directory, "_attachlock"), "rw"); -+ try { -+ FileLock attachLockLock = attachLock.getChannel().lock(); -+ try { -+ List virtualMachines; -+ RandomAccessFile master = new RandomAccessFile(new File(directory, "_master"), "rw"); - try { +- try { - PosixLibrary.SocketAddress address = new PosixLibrary.SocketAddress(); -+ FileLock masterLock = master.getChannel().lock(); - try { +- try { - address.setPath(socket.getAbsolutePath()); - library.connect(handle, address, address.size()); - return handle; - } finally { -- address.clear(); +- address = null; - } - } catch (RuntimeException exception) { - library.close(handle); @@ -267,10 +233,7 @@ index 6e16424..e2138c1 100644 - System.arraycopy(new byte[]{0}, 0, this.path, path.length(), 1); - } catch (UnsupportedEncodingException exception) { - throw new IllegalStateException(exception); -+ File[] vmFolder = directory.listFiles(); -+ if (vmFolder == null) { -+ throw new IllegalStateException("No descriptor files found in " + directory); - } +- } - } - - @Override @@ -313,58 +276,25 @@ index 6e16424..e2138c1 100644 - * @param timeUnit The time unit of the pause time. - * @return An appropriate connection factory. - */ +- @SuppressWarnings("deprecation") - public static Connection.Factory withDefaultTemporaryFolder(int attempts, long pause, TimeUnit timeUnit) { - String temporaryDirectory; - if (Platform.isMac()) { -- temporaryDirectory = System.getenv("TMPDIR"); -- if (temporaryDirectory == null) { -- temporaryDirectory = "/tmp"; -+ long userId = dispatcher.userId(); -+ virtualMachines = new ArrayList(); -+ for (File aVmFolder : vmFolder) { -+ if (aVmFolder.isDirectory() && dispatcher.getOwnerIdOf(aVmFolder) == userId) { -+ File attachInfo = new File(aVmFolder, "attachInfo"); -+ if (attachInfo.isFile()) { -+ Properties virtualMachine = new Properties(); -+ FileInputStream inputStream = new FileInputStream(attachInfo); -+ try { -+ virtualMachine.load(inputStream); -+ } finally { -+ inputStream.close(); -+ } -+ int targetProcessId = Integer.parseInt(virtualMachine.getProperty("processId")); -+ long targetUserId; -+ try { -+ targetUserId = Long.parseLong(virtualMachine.getProperty("userUid")); -+ } catch (NumberFormatException ignored) { -+ targetUserId = 0L; -+ } -+ if (userId != 0L && targetUserId == 0L) { -+ targetUserId = dispatcher.getOwnerIdOf(attachInfo); -+ } -+ if (targetProcessId == 0L || dispatcher.isExistingProcess(targetProcessId)) { -+ virtualMachines.add(virtualMachine); -+ } else if (userId == 0L || targetUserId == userId) { -+ File[] vmFile = aVmFolder.listFiles(); -+ if (vmFile != null) { -+ for (File aVmFile : vmFile) { -+ if (!aVmFile.delete()) { -+ aVmFile.deleteOnExit(); -+ } -+ } -+ } -+ if (!aVmFolder.delete()) { -+ aVmFolder.deleteOnExit(); -+ } -+ } -+ } -+ } - } +- MacLibrary library = Native.loadLibrary("c", MacLibrary.class); +- Memory memory = new Memory(4096); +- try { +- long length = library.confstr(MacLibrary.CS_DARWIN_USER_TEMP_DIR, memory, memory.size()); +- if (length == 0 || length > 4096) { +- temporaryDirectory = "/tmp"; +- } else { +- temporaryDirectory = memory.getString(0); +- } +- } finally { +- memory = null; +- } - } else { - temporaryDirectory = "/tmp"; -+ } finally { -+ masterLock.release(); - } +- } - return new Factory(temporaryDirectory, attempts, pause, timeUnit); - } - @@ -376,9 +306,28 @@ index 6e16424..e2138c1 100644 - @Override - public Connection doConnect(File socket) { - return new Connection.ForJnaPosixSocket(library, socket); -+ } finally { -+ master.close(); - } +- } +- +- /** +- * A library for reading a Mac user's temporary directory. +- */ +- public interface MacLibrary extends Library { +- +- /** +- * The temporary directory. +- */ +- int CS_DARWIN_USER_TEMP_DIR = 65537; +- +- /** +- * Reads a configuration dependant variable into a memory segment. +- * +- * @param name The name of the variable. +- * @param buffer The buffer to read the variable into. +- * @param length The length of the buffer. +- * @return The amount of bytes written to the buffer. +- */ +- long confstr(int name, Pointer buffer, long length); +- } - } - } - @@ -444,13 +393,7 @@ index 6e16424..e2138c1 100644 - throw new IllegalArgumentException("Unknown protocol version: " + protocol); - } else if (argument.length > 4) { - throw new IllegalArgumentException("Cannot supply more then four arguments to Windows attach mechanism: " + Arrays.asList(argument)); -+ Properties target = null; -+ for (Properties virtualMachine : virtualMachines) { -+ if (virtualMachine.getProperty("processId").equalsIgnoreCase(processId)) { -+ target = virtualMachine; -+ break; -+ } - } +- } - String name = "\\\\.\\pipe\\javatool" + Math.abs(random.nextInt() + 1); - WinNT.HANDLE pipe = Kernel32.INSTANCE.CreateNamedPipe(name, - WinBase.PIPE_ACCESS_INBOUND, @@ -462,11 +405,8 @@ index 6e16424..e2138c1 100644 - null); - if (pipe == null) { - throw new Win32Exception(Native.getLastError()); -+ if (target == null) { -+ throw new IllegalStateException("Could not locate target process info in " + directory); - } -+ ServerSocket serverSocket = new ServerSocket(0); - try { +- } +- try { - WinDef.LPVOID data = attachLibrary.allocate_remote_argument(process, - name, - argument.length < 1 ? null : argument[0], @@ -476,19 +416,12 @@ index 6e16424..e2138c1 100644 - if (data == null) { - throw new Win32Exception(Native.getLastError()); - } -+ serverSocket.setSoTimeout(timeout); -+ File receiver = new File(directory, target.getProperty("vmId")); -+ String key = Long.toHexString(new SecureRandom().nextLong()); -+ File reply = new File(receiver, "replyInfo"); - try { +- try { - WinNT.HANDLE thread = library.CreateRemoteThread(process, null, 0, code.getPointer(), data.getPointer(), null, null); - if (thread == null) { - throw new Win32Exception(Native.getLastError()); -+ if (reply.createNewFile()) { -+ dispatcher.setPermissions(reply, 0600); - } -+ FileOutputStream outputStream = new FileOutputStream(reply); - try { +- } +- try { - int result = Kernel32.INSTANCE.WaitForSingleObject(thread, WinBase.INFINITE); - if (result != 0) { - throw new Win32Exception(result); @@ -497,7 +430,7 @@ index 6e16424..e2138c1 100644 - if (!library.GetExitCodeThread(thread, exitCode)) { - throw new Win32Exception(Native.getLastError()); - } else if (exitCode.getValue() != 0) { -- throw new IllegalStateException("Target could not dispatch command successfully"); +- throw new IllegalStateException("Target VM could not dispatch command successfully: " + exitCode.getValue()); - } - if (!Kernel32.INSTANCE.ConnectNamedPipe(pipe, null)) { - int code = Native.getLastError(); @@ -506,11 +439,7 @@ index 6e16424..e2138c1 100644 - } - } - return new NamedPipeResponse(pipe); -+ outputStream.write(key.getBytes("UTF-8")); -+ outputStream.write("\n".getBytes("UTF-8")); -+ outputStream.write(Long.toString(serverSocket.getLocalPort()).getBytes("UTF-8")); -+ outputStream.write("\n".getBytes("UTF-8")); - } finally { +- } finally { - if (!Kernel32.INSTANCE.CloseHandle(thread)) { - throw new Win32Exception(Native.getLastError()); - } @@ -518,8 +447,7 @@ index 6e16424..e2138c1 100644 - } finally { - if (!library.VirtualFreeEx(process, data.getPointer(), 0, MEM_RELEASE)) { - throw new Win32Exception(Native.getLastError()); -+ outputStream.close(); - } +- } - } - } catch (Throwable throwable) { - if (!Kernel32.INSTANCE.CloseHandle(pipe)) { @@ -591,14 +519,15 @@ index 6e16424..e2138c1 100644 - * @param threadId A pointer to the thread id or {@code null} if no thread reference is set. - * @return A handle to the created remote thread or {@code null} if the creation failed. - */ +- @MaybeNull - @SuppressWarnings("checkstyle:methodname") - WinNT.HANDLE CreateRemoteThread(WinNT.HANDLE process, -- WinBase.SECURITY_ATTRIBUTES securityAttributes, +- @MaybeNull WinBase.SECURITY_ATTRIBUTES securityAttributes, - int stackSize, - Pointer code, - Pointer argument, -- WinDef.DWORD creationFlags, -- Pointer threadId); +- @MaybeNull WinDef.DWORD creationFlags, +- @MaybeNull Pointer threadId); - - /** - * Receives the exit code of a given thread. @@ -622,6 +551,7 @@ index 6e16424..e2138c1 100644 - * @param process A handle to the target process. - * @return A pointer to the allocated code or {@code null} if the code could not be allocated. - */ +- @MaybeNull - @SuppressWarnings("checkstyle:methodname") - WinDef.LPVOID allocate_remote_code(WinNT.HANDLE process); - @@ -636,13 +566,14 @@ index 6e16424..e2138c1 100644 - * @param argument3 The forth argument or {@code null} if no such argument is provided. - * @return A pointer to the allocated argument or {@code null} if the argument could not be allocated. - */ +- @MaybeNull - @SuppressWarnings("checkstyle:methodname") - WinDef.LPVOID allocate_remote_argument(WinNT.HANDLE process, - String pipe, -- String argument0, -- String argument1, -- String argument2, -- String argument3); +- @MaybeNull String argument0, +- @MaybeNull String argument1, +- @MaybeNull String argument2, +- @MaybeNull String argument3); - } - - /** @@ -702,6 +633,12 @@ index 6e16424..e2138c1 100644 - public static class Factory implements Connection.Factory { - - /** +- * The name of the native code library that is included in this artifact to support Windows attachment. +- * This property can be set by other libraries that shade Byte Buddy agent and relocates the library. +- */ +- public static final String LIBRARY_NAME = "net.bytebuddy.library.name"; +- +- /** - * The library to use for communicating with Windows native functions. - */ - private final WindowsLibrary library; @@ -717,7 +654,7 @@ index 6e16424..e2138c1 100644 - @SuppressWarnings("deprecation") - public Factory() { - library = Native.loadLibrary("kernel32", WindowsLibrary.class, W32APIOptions.DEFAULT_OPTIONS); -- attachLibrary = Native.loadLibrary("attach_hotspot_windows", WindowsAttachLibrary.class); +- attachLibrary = Native.loadLibrary(System.getProperty(LIBRARY_NAME, "attach_hotspot_windows"), WindowsAttachLibrary.class); - } - - /** @@ -810,13 +747,13 @@ index 6e16424..e2138c1 100644 - return new Response(library, door.descriptorPointer.getInt(4)); - } - } finally { -- result.clear(); +- result = null; - } - } finally { -- dataPointer.clear(); +- dataPointer = null; - } - } finally { -- door.clear(); +- door = null; - } - } finally { - library.close(handle); @@ -894,6 +831,7 @@ index 6e16424..e2138c1 100644 - /** - * A pointer to the operation argument. - */ +- @MaybeNull - public Pointer dataPointer; - - /** @@ -904,6 +842,7 @@ index 6e16424..e2138c1 100644 - /** - * A pointer to the operation descriptor. - */ +- @MaybeNull - public Pointer descriptorPointer; - - /** @@ -914,6 +853,7 @@ index 6e16424..e2138c1 100644 - /** - * A pointer to the operation result. - */ +- @UnknownNull - public Pointer resultPointer; - - /** @@ -1022,6 +962,11 @@ index 6e16424..e2138c1 100644 - private static final String IBM_TEMPORARY_FOLDER = "com.ibm.tools.attach.directory"; - - /** +- * A secure random for generating randomized ids. +- */ +- private static final SecureRandom SECURE_RANDOM = new SecureRandom(); +- +- /** - * The socket on which this VM and the target VM communicate. - */ - private final Socket socket; @@ -1058,7 +1003,7 @@ index 6e16424..e2138c1 100644 - * @throws IOException If an IO exception occurs during establishing the connection. - */ - public static VirtualMachine attach(String processId, int timeout, Dispatcher dispatcher) throws IOException { -- File directory = new File(System.getProperty(IBM_TEMPORARY_FOLDER, dispatcher.getTemporaryFolder()), ".com_ibm_tools_attach"); +- File directory = new File(System.getProperty(IBM_TEMPORARY_FOLDER, dispatcher.getTemporaryFolder(processId)), ".com_ibm_tools_attach"); - RandomAccessFile attachLock = new RandomAccessFile(new File(directory, "_attachlock"), "rw"); - try { - FileLock attachLockLock = attachLock.getChannel().lock(); @@ -1133,7 +1078,10 @@ index 6e16424..e2138c1 100644 - try { - serverSocket.setSoTimeout(timeout); - File receiver = new File(directory, target.getProperty("vmId")); -- String key = Long.toHexString(new SecureRandom().nextLong()); +- String key; +- synchronized (SECURE_RANDOM) { +- key = Long.toHexString(SECURE_RANDOM.nextLong()); +- } - File reply = new File(receiver, "replyInfo"); - try { - if (reply.createNewFile()) { @@ -1185,6 +1133,7 @@ index 6e16424..e2138c1 100644 - if (answer.contains(' ' + key + ' ')) { - return new ForOpenJ9(socket); - } else { +- socket.close(); - throw new IllegalStateException("Unexpected answered to attachment: " + answer); - } - } finally { @@ -1242,7 +1191,7 @@ index 6e16424..e2138c1 100644 - /** - * {@inheritDoc} - */ -- public void loadAgent(String jarFile, String argument) throws IOException { +- public void loadAgent(String jarFile, @MaybeNull String argument) throws IOException { - write(socket, ("ATTACH_LOADAGENT(instrument," + jarFile + '=' + (argument == null ? "" : argument) + ')').getBytes("UTF-8")); - String answer = new String(read(socket), "UTF-8"); - if (answer.startsWith("ATTACH_ERR")) { @@ -1255,7 +1204,7 @@ index 6e16424..e2138c1 100644 - /** - * {@inheritDoc} - */ -- public void loadAgentPath(String path, String argument) throws IOException { +- public void loadAgentPath(String path, @MaybeNull String argument) throws IOException { - write(socket, ("ATTACH_LOADAGENTPATH(" + path + (argument == null ? "" : (',' + argument)) + ')').getBytes("UTF-8")); - String answer = new String(read(socket), "UTF-8"); - if (answer.startsWith("ATTACH_ERR")) { @@ -1268,7 +1217,7 @@ index 6e16424..e2138c1 100644 - /** - * {@inheritDoc} - */ -- public void loadAgentLibrary(String library, String argument) throws IOException { +- public void loadAgentLibrary(String library, @MaybeNull String argument) throws IOException { - write(socket, ("ATTACH_LOADAGENTLIBRARY(" + library + (argument == null ? "" : (',' + argument)) + ')').getBytes("UTF-8")); - String answer = new String(read(socket), "UTF-8"); - if (answer.startsWith("ATTACH_ERR")) { @@ -1366,9 +1315,10 @@ index 6e16424..e2138c1 100644 - /** - * Returns this machine's temporary folder. - * +- * @param processId The target process's id. - * @return The temporary folder. - */ -- String getTemporaryFolder(); +- String getTemporaryFolder(String processId); - - /** - * Returns the process id of this process. @@ -1471,7 +1421,13 @@ index 6e16424..e2138c1 100644 - /** - * {@inheritDoc} - */ -- public String getTemporaryFolder() { +- public String getTemporaryFolder(String processId) { +- if (Platform.isLinux()) { +- File file = new File("/proc/" + processId + "/root/tmp"); +- if (file.isDirectory() && file.canRead()) { +- return file.getAbsolutePath(); +- } +- } - String temporaryFolder = System.getenv("TMPDIR"); - return temporaryFolder == null ? "/tmp" : temporaryFolder; - } @@ -1505,13 +1461,15 @@ index 6e16424..e2138c1 100644 - try { - // The binding for 'stat' is very platform dependant. To avoid the complexity of binding the correct method, - // stat is called as a separate command. This is less efficient but more portable. -- Process process = Runtime.getRuntime().exec("stat -c=%u " + file.getAbsolutePath()); +- Process process = Runtime.getRuntime().exec(new String[]{"stat", +- Platform.isMac() ? "-f" : "-c", +- "%u", +- file.getAbsolutePath()}); - int attempts = this.attempts; - boolean exited = false; - String line = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8")).readLine(); - do { -+ Map locks = new HashMap(); - try { +- try { - if (process.exitValue() != 0) { - throw new IllegalStateException("Error while executing stat"); - } @@ -1522,28 +1480,15 @@ index 6e16424..e2138c1 100644 - Thread.sleep(timeUnit.toMillis(pause)); - } catch (InterruptedException exception) { - Thread.currentThread().interrupt(); -- throw new IllegalStateException("Interrupted while waiting for stat", exception); -+ String pid = Long.toString(dispatcher.pid()); -+ for (Properties virtualMachine : virtualMachines) { -+ if (!virtualMachine.getProperty("processId").equalsIgnoreCase(pid)) { -+ String attachNotificationSync = virtualMachine.getProperty("attachNotificationSync"); -+ RandomAccessFile syncFile = new RandomAccessFile(attachNotificationSync == null -+ ? new File(directory, "attachNotificationSync") -+ : new File(attachNotificationSync), "rw"); -+ try { -+ locks.put(syncFile, syncFile.getChannel().lock()); -+ } catch (IOException ignored) { -+ syncFile.close(); -+ } -+ } - } +- throw new IllegalStateException(exception); +- } - } - } while (--attempts > 0); - if (!exited) { - process.destroy(); - throw new IllegalStateException("Command for stat did not exit in time"); - } -- return Integer.parseInt(line.substring(1)); +- return Integer.parseInt(line); - } catch (IOException exception) { - throw new IllegalStateException("Unable to execute stat command", exception); - } @@ -1591,27 +1536,16 @@ index 6e16424..e2138c1 100644 - try { - library.semop(semaphore, target, 1); - } catch (LastErrorException exception) { -- if (acceptUnavailable && Native.getLastError() == PosixLibrary.EAGAIN) { +- if (acceptUnavailable && (Native.getLastError() == PosixLibrary.EAGAIN +- || Native.getLastError() == PosixLibrary.EDEADLK)) { - break; - } else { - throw exception; -+ int notifications = 0; -+ File[] item = directory.listFiles(); -+ if (item != null) { -+ for (File anItem : item) { -+ String name = anItem.getName(); -+ if (!name.startsWith(".trash_") -+ && !name.equalsIgnoreCase("_attachlock") -+ && !name.equalsIgnoreCase("_master") -+ && !name.equalsIgnoreCase("_notifier")) { -+ notifications += 1; -+ } -+ } - } +- } - } - } - } finally { -- target.clear(); +- target = null; - } - } - @@ -1636,6 +1570,11 @@ index 6e16424..e2138c1 100644 - int EAGAIN = 11; - - /** +- * Indicates a dead lock on a resource. +- */ +- int EDEADLK = 35; +- +- /** - * Indicates that a semaphore's operations should be undone at process shutdown. - */ - short SEM_UNDO = 0x1000; @@ -1773,7 +1712,7 @@ index 6e16424..e2138c1 100644 - /** - * {@inheritDoc} - */ -- public String getTemporaryFolder() { +- public String getTemporaryFolder(String processId) { - WinDef.DWORD length = new WinDef.DWORD(WinDef.MAX_PATH); - char[] path = new char[length.intValue()]; - if (Kernel32.INSTANCE.GetTempPath(length, path).intValue() == 0) { @@ -1892,21 +1831,10 @@ index 6e16424..e2138c1 100644 - mutex = library.OpenMutex(WinNT.STANDARD_RIGHTS_REQUIRED | WinNT.SYNCHRONIZE | 0x0001, false, CREATION_MUTEX_NAME); - if (mutex == null) { - throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); -+ boolean global = Boolean.parseBoolean(target.getProperty("globalSemaphore")); -+ dispatcher.incrementSemaphore(directory, "_notifier", global, notifications); -+ try { -+ Socket socket = serverSocket.accept(); -+ String answer = new String(read(socket), "UTF-8"); -+ if (answer.contains(' ' + key + ' ')) { -+ return new ForOpenJ9(socket); -+ } else { -+ throw new IllegalStateException("Unexpected answered to attachment: " + answer); - } +- } - } else { - throw new Win32Exception(lastError); -+ } finally { -+ dispatcher.decrementSemaphore(directory, "_notifier", global, notifications); - } +- } - } - int result = Kernel32.INSTANCE.WaitForSingleObject(mutex, 2000); - switch (result) { @@ -1914,9 +1842,7 @@ index 6e16424..e2138c1 100644 - case WinError.WAIT_TIMEOUT: - throw new Win32Exception(result); - default: -+ } finally { -+ for (Map.Entry entry : locks.entrySet()) { - try { +- try { - String target = (global ? "Global\\" : "") - + (directory.getAbsolutePath() + '_' + name).replaceAll("[^a-zA-Z0-9_]", "") - + "_semaphore"; @@ -1941,62 +1867,27 @@ index 6e16424..e2138c1 100644 - } finally { - if (!library.ReleaseMutex(mutex)) { - throw new Win32Exception(Native.getLastError()); -+ try { -+ entry.getValue().release(); -+ } finally { -+ entry.getKey().close(); - } -+ } catch (Throwable ignored) { -+ /* do nothing */ - } -+ } - } - } finally { -- securityAttributes.clear(); -+ if (!reply.delete()) { -+ reply.deleteOnExit(); -+ } - } - } finally { -- securityDescriptor.clear(); -+ serverSocket.close(); - } -+ } finally { -+ attachLockLock.release(); - } -+ } finally { -+ attachLock.close(); -+ } -+ } - +- } +- } +- } +- } finally { +- securityAttributes = null; +- } +- } finally { +- securityDescriptor = null; +- } +- } +- - /** - * A library for interacting with Windows. - */ - protected interface WindowsLibrary extends StdCallLibrary { -+ /** -+ * {@inheritDoc} -+ */ -+ public Properties getSystemProperties() throws IOException { -+ write(socket, "ATTACH_GETSYSTEMPROPERTIES".getBytes("UTF-8")); -+ Properties properties = new Properties(); -+ properties.load(new ByteArrayInputStream(read(socket))); -+ return properties; -+ } - +- - /** - * Indicates that a semaphore requires all access rights. - */ - int SEMAPHORE_ALL_ACCESS = 0x1F0003; -+ /** -+ * {@inheritDoc} -+ */ -+ public Properties getAgentProperties() throws IOException { -+ write(socket, "ATTACH_GETAGENTPROPERTIES".getBytes("UTF-8")); -+ Properties properties = new Properties(); -+ properties.load(new ByteArrayInputStream(read(socket))); -+ return properties; -+ } - +- - /** - * Opens an existing semaphore. - * @@ -2005,21 +1896,10 @@ index 6e16424..e2138c1 100644 - * @param name The semaphore's name. - * @return The handle or {@code null} if the handle could not be created. - */ +- @MaybeNull - @SuppressWarnings("checkstyle:methodname") - WinNT.HANDLE OpenSemaphoreW(int access, boolean inheritHandle, String name); -+ /** -+ * {@inheritDoc} -+ */ -+ public void loadAgent(String jarFile, String argument) throws IOException { -+ write(socket, ("ATTACH_LOADAGENT(instrument," + jarFile + '=' + (argument == null ? "" : argument) + ')').getBytes("UTF-8")); -+ String answer = new String(read(socket), "UTF-8"); -+ if (answer.startsWith("ATTACH_ERR")) { -+ throw new IllegalStateException("Target VM failed loading agent: " + answer); -+ } else if (!answer.startsWith("ATTACH_ACK") && !answer.startsWith("ATTACH_RESULT=")) { -+ throw new IllegalStateException("Unexpected response: " + answer); -+ } -+ } - +- - /** - * Creates a new semaphore. - * @@ -2029,21 +1909,13 @@ index 6e16424..e2138c1 100644 - * @param name The semaphore's name. - * @return The handle or {@code null} if the handle could not be created. - */ +- @MaybeNull - @SuppressWarnings("checkstyle:methodname") -- WinNT.HANDLE CreateSemaphoreW(WinBase.SECURITY_ATTRIBUTES securityAttributes, long count, long maximumCount, String name); -+ /** -+ * {@inheritDoc} -+ */ -+ public void loadAgentPath(String path, String argument) throws IOException { -+ write(socket, ("ATTACH_LOADAGENTPATH(" + path + (argument == null ? "" : (',' + argument)) + ')').getBytes("UTF-8")); -+ String answer = new String(read(socket), "UTF-8"); -+ if (answer.startsWith("ATTACH_ERR")) { -+ throw new IllegalStateException("Target VM failed loading native agent: " + answer); -+ } else if (!answer.startsWith("ATTACH_ACK") && !answer.startsWith("ATTACH_RESULT=")) { -+ throw new IllegalStateException("Unexpected response: " + answer); -+ } -+ } - +- WinNT.HANDLE CreateSemaphoreW(@MaybeNull WinBase.SECURITY_ATTRIBUTES securityAttributes, +- long count, +- long maximumCount, +- String name); +- - /** - * Releases the semaphore. - * @@ -2053,20 +1925,8 @@ index 6e16424..e2138c1 100644 - * @return {@code true} if the semaphore was successfully released. - */ - @SuppressWarnings("checkstyle:methodname") -- boolean ReleaseSemaphore(WinNT.HANDLE handle, long count, Long previousCount); -+ /** -+ * {@inheritDoc} -+ */ -+ public void loadAgentLibrary(String library, String argument) throws IOException { -+ write(socket, ("ATTACH_LOADAGENTLIBRARY(" + library + (argument == null ? "" : (',' + argument)) + ')').getBytes("UTF-8")); -+ String answer = new String(read(socket), "UTF-8"); -+ if (answer.startsWith("ATTACH_ERR")) { -+ throw new IllegalStateException("Target VM failed loading native library: " + answer); -+ } else if (!answer.startsWith("ATTACH_ACK") && !answer.startsWith("ATTACH_RESULT=")) { -+ throw new IllegalStateException("Unexpected response: " + answer); -+ } -+ } - +- boolean ReleaseSemaphore(WinNT.HANDLE handle, long count, @MaybeNull Long previousCount); +- - /** - * Create or opens a mutex. - * @@ -2075,24 +1935,10 @@ index 6e16424..e2138c1 100644 - * @param name The mutex name. - * @return The handle to the mutex or {@code null} if the mutex could not be created. - */ +- @MaybeNull - @SuppressWarnings("checkstyle:methodname") - WinNT.HANDLE CreateMutex(SecurityAttributes attributes, boolean owner, String name); -+ /** -+ * {@inheritDoc} -+ */ -+ public void startManagementAgent(Properties properties) throws IOException { -+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); -+ properties.store(outputStream, null); -+ write(socket, "ATTACH_START_MANAGEMENT_AGENT".getBytes("UTF-8")); -+ write(socket, outputStream.toByteArray()); -+ String answer = new String(read(socket), "UTF-8"); -+ if (answer.startsWith("ATTACH_ERR")) { -+ throw new IllegalStateException("Target VM could not start management agent: " + answer); -+ } else if (!answer.startsWith("ATTACH_ACK") && !answer.startsWith("ATTACH_RESULT=")) { -+ throw new IllegalStateException("Unexpected response: " + answer); -+ } -+ } - +- - /** - * Opens an existing object. - * @@ -2103,23 +1949,7 @@ index 6e16424..e2138c1 100644 - */ - @SuppressWarnings("checkstyle:methodname") - WinNT.HANDLE OpenMutex(int access, boolean inherit, String name); -+ /** -+ * {@inheritDoc} -+ */ -+ public String startLocalManagementAgent() throws IOException { -+ write(socket, "ATTACH_START_LOCAL_MANAGEMENT_AGENT".getBytes("UTF-8")); -+ String answer = new String(read(socket), "UTF-8"); -+ if (answer.startsWith("ATTACH_ERR")) { -+ throw new IllegalStateException("Target VM could not start management agent: " + answer); -+ } else if (answer.startsWith("ATTACH_ACK")) { -+ return answer.substring("ATTACH_ACK".length()); -+ } else if (answer.startsWith("ATTACH_RESULT=")) { -+ return answer.substring("ATTACH_RESULT=".length()); -+ } else { -+ throw new IllegalStateException("Unexpected response: " + answer); -+ } -+ } - +- - /** - * Releases the supplied mutex. - * @@ -2128,18 +1958,7 @@ index 6e16424..e2138c1 100644 - */ - @SuppressWarnings("checkstyle:methodname") - boolean ReleaseMutex(WinNT.HANDLE handle); -+ /** -+ * {@inheritDoc} -+ */ -+ public void detach() throws IOException { -+ try { -+ write(socket, "ATTACH_DETACH".getBytes("UTF-8")); -+ read(socket); // The answer is intentionally ignored. -+ } finally { -+ socket.close(); -+ } -+ } - +- - /** - * A structure representing a mutex's security attributes. - */ @@ -2149,11 +1968,13 @@ index 6e16424..e2138c1 100644 - /** - * The descriptor's length. - */ +- @MaybeNull - public WinDef.DWORD length; - - /** - * A pointer to the descriptor. - */ +- @MaybeNull - public Pointer securityDescriptor; - - /** @@ -2167,72 +1988,23 @@ index 6e16424..e2138c1 100644 - return Arrays.asList("length", "securityDescriptor", "inherit"); - } - } -+ /** -+ * Writes the supplied value to the target socket. -+ * -+ * @param socket The socket to write to. -+ * @param value The value being written. -+ * @throws IOException If an I/O exception occurs. -+ */ -+ private static void write(Socket socket, byte[] value) throws IOException { -+ socket.getOutputStream().write(value); -+ socket.getOutputStream().write(0); -+ socket.getOutputStream().flush(); -+ } -+ -+ /** -+ * Reads a {@code '\0'}-terminated value from the target socket. -+ * -+ * @param socket The socket to read from. -+ * @return The value that was read. -+ * @throws IOException If an I/O exception occurs. -+ */ -+ private static byte[] read(Socket socket) throws IOException { -+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); -+ byte[] buffer = new byte[1024]; -+ int length; -+ while ((length = socket.getInputStream().read(buffer)) != -1) { -+ if (length > 0 && buffer[length - 1] == 0) { -+ outputStream.write(buffer, 0, length - 1); -+ break; -+ } else { -+ outputStream.write(buffer, 0, length); - } -+ } -+ return outputStream.toByteArray(); -+ } - +- } +- - /** - * A handle for an attachment which is represented by a pair of handles. - */ - protected static class AttachmentHandle implements Closeable { -+ /** -+ * A dispatcher for native operations being used for communication with an OpenJ9 virtual machine. -+ */ -+ public interface Dispatcher { - +- - /** - * The parent handle. - */ - private final WinNT.HANDLE parent; -+ /** -+ * Returns this machine's temporary folder. -+ * -+ * @return The temporary folder. -+ */ -+ String getTemporaryFolder(); - +- - /** - * The child handle. - */ - private final WinNT.HANDLE child; -+ /** -+ * Returns the process id of this process. -+ * -+ * @return The process id of this process. -+ */ -+ int pid(); - +- - /** - * Creates a new attachment handle. - * @@ -2243,13 +2015,7 @@ index 6e16424..e2138c1 100644 - this.parent = parent; - this.child = child; - } -+ /** -+ * Returns the user id of this process. -+ * -+ * @return The user id of this process -+ */ -+ int userId(); - +- - /** - * Returns the handle on which signals are to be sent. - * @@ -2258,14 +2024,7 @@ index 6e16424..e2138c1 100644 - protected WinNT.HANDLE getHandle() { - return child; - } -+ /** -+ * Returns {@code true} if the supplied process id is a running process. -+ * -+ * @param processId The process id to evaluate. -+ * @return {@code true} if the supplied process id is currently running. -+ */ -+ boolean isExistingProcess(int processId); - +- - /** - * {@inheritDoc} - */ @@ -2284,44 +2043,135 @@ index 6e16424..e2138c1 100644 - } - } - } -+ /** -+ * Returns the user id of the owner of the supplied file. -+ * -+ * @param file The file for which to locate the owner. -+ * @return The owner id of the supplied file. -+ */ -+ int getOwnerIdOf(File file); -+ -+ /** -+ * Sets permissions for the supplied file. -+ * -+ * @param file The file for which to set the permissions. -+ * @param permissions The permission bits to set. -+ */ -+ void setPermissions(File file, int permissions); -+ -+ /** -+ * Increments a semaphore. -+ * -+ * @param directory The sempahore's control directory. -+ * @param name The semaphore's name. -+ * @param global {@code true} if the semaphore is in the global namespace (only applicable on Windows). -+ * @param count The amount of increments. -+ */ -+ void incrementSemaphore(File directory, String name, boolean global, int count); -+ -+ /** -+ * Decrements a semaphore. -+ * -+ * @param directory The sempahore's control directory. -+ * @param name The semaphore's name. -+ * @param global {@code true} if the semaphore is in the global namespace (only applicable on Windows). -+ * @param count The amount of decrements. -+ */ -+ void decrementSemaphore(File directory, String name, boolean global, int count); + } + } + } +diff --git a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/loading/ClassInjector.java b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/loading/ClassInjector.java +index 5880b2d..9d4b989 100644 +--- a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/loading/ClassInjector.java ++++ b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/loading/ClassInjector.java +@@ -15,7 +15,6 @@ + */ + package net.bytebuddy.dynamic.loading; + +-import com.sun.jna.*; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import net.bytebuddy.ByteBuddy; + import net.bytebuddy.ClassFileVersion; +@@ -2777,79 +2776,13 @@ public interface ClassInjector { + return new Unavailable("J9 does not support JNA-based class definition"); + } + try { +- Map options = new HashMap(); +- options.put(Library.OPTION_ALLOW_OBJECTS, Boolean.TRUE); +- if (Platform.isWindows() && !Platform.is64Bit()) { +- options.put(Library.OPTION_FUNCTION_MAPPER, Windows32BitFunctionMapper.INSTANCE); +- } +- return new Enabled(Native.loadLibrary("jvm", Jvm.class, options)); ++ return new Unavailable("JNA is not available"); + } catch (Throwable throwable) { + return new Unavailable(throwable.getMessage()); + } + } + } + +- /** +- * A mapper for 32-bit Windows functions where names are defined with different convention. +- */ +- enum Windows32BitFunctionMapper implements FunctionMapper { +- +- /** +- * The singleton instance. +- */ +- INSTANCE; +- +- /** +- * {@inheritDoc} +- */ +- public String getFunctionName(NativeLibrary library, Method method) { +- if (method.getName().equals("JVM_DefineClass")) { +- return "_JVM_DefineClass@24"; +- } +- return method.getName(); +- } +- } +- +- /** +- * An enabled dispatcher for JNA-based class injection. +- */ +- @HashCodeAndEqualsPlugin.Enhance +- class Enabled implements Dispatcher { +- +- /** +- * The JNA-dispatcher to use for invoking JNI's class definition utilities. +- */ +- private final Jvm jvm; +- +- /** +- * Creates a new dispatcher for a JNI's class definition utilities. +- * +- * @param jvm The JNA-dispatcher to use for invoking JNI's class definition utilities. +- */ +- protected Enabled(Jvm jvm) { +- this.jvm = jvm; +- } +- +- /** +- * {@inheritDoc} +- */ +- public boolean isAvailable() { +- return true; +- } +- +- /** +- * {@inheritDoc} +- */ +- public Class defineClass(@MaybeNull ClassLoader classLoader, String name, byte[] binaryRepresentation, @MaybeNull ProtectionDomain protectionDomain) { +- return jvm.JVM_DefineClass(JNIEnv.CURRENT, +- name.replace('.', '/'), +- classLoader, +- binaryRepresentation, +- binaryRepresentation.length, +- protectionDomain); +- } +- } +- + /** + * An unavailable dispatcher for JNA-based class injection. + */ +@@ -2884,32 +2817,6 @@ public interface ClassInjector { + throw new UnsupportedOperationException("JNA is not available and JNA-based injection cannot be used: " + error); + } + } +- +- /** +- * A JNA dispatcher for the JVM's JVM_DefineClass method. +- */ +- interface Jvm extends Library { +- +- /** +- * Defines a new class into a given class loader. +- * +- * @param env The JNI environment. +- * @param name The internal name of the class. +- * @param classLoader The class loader to inject into or {@code null} if injecting into the bootstrap loader. +- * @param binaryRepresentation The class's binary representation. +- * @param length The length of the class's binary representation. +- * @param protectionDomain The protection domain or {@code null} if no explicit protection domain should be used. +- * @return The class that was defined. +- * @throws LastErrorException If an error occurs during injection. +- */ +- @SuppressWarnings("checkstyle:methodname") +- Class JVM_DefineClass(JNIEnv env, +- String name, +- @MaybeNull ClassLoader classLoader, +- byte[] binaryRepresentation, +- int length, +- @MaybeNull ProtectionDomain protectionDomain) throws LastErrorException; +- } } } } -- -2.21.0 +2.39.1 diff --git a/SOURCES/0003-Fix-broken-modular-jars.patch b/SOURCES/0003-Fix-broken-modular-jars.patch new file mode 100644 index 0000000..67af96c --- /dev/null +++ b/SOURCES/0003-Fix-broken-modular-jars.patch @@ -0,0 +1,36 @@ +From 5dc1f89e58e41069158e4e00e7772220a6493480 Mon Sep 17 00:00:00 2001 +From: Marian Koncek +Date: Sat, 24 Feb 2024 17:01:21 +0100 +Subject: [PATCH] Fix broken modular jars + +--- + byte-buddy/pom.xml | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/byte-buddy/pom.xml b/byte-buddy/pom.xml +index b954bb7..68c18b4 100644 +--- a/byte-buddy/pom.xml ++++ b/byte-buddy/pom.xml +@@ -162,9 +162,9 @@ + + + +- prepare-package ++ package + +- make-module ++ inject-module + + + ${modulemaker.skip} +@@ -181,6 +181,7 @@ + com.sun.jna, + com.sun.jna.platform + ++ net.bytebuddy.build.Plugin$Engine$Default + + + +-- +2.43.0 + diff --git a/SOURCES/avoid-bundling-asm.patch b/SOURCES/avoid-bundling-asm.patch deleted file mode 100644 index f642e01..0000000 --- a/SOURCES/avoid-bundling-asm.patch +++ /dev/null @@ -1,104 +0,0 @@ -diff --git a/byte-buddy/pom.xml b/byte-buddy/pom.xml -index 283da43..aca6bc5 100644 ---- a/byte-buddy/pom.xml -+++ b/byte-buddy/pom.xml -@@ -26,8 +26,6 @@ - --> - - -- org.objectweb.asm -- net.bytebuddy.jar.asm - - net.bytebuddy, - net.bytebuddy.agent.builder, -@@ -62,9 +60,6 @@ - net.bytebuddy.utility, - net.bytebuddy.utility.privilege, - net.bytebuddy.utility.visitor, -- ${shade.target}, -- ${shade.target}.signature, -- ${shade.target}.commons - - - -@@ -79,6 +74,16 @@ - byte-buddy-dep - ${project.version} - -+ -+ org.ow2.asm -+ asm -+ ${version.asm} -+ -+ -+ org.ow2.asm -+ asm-commons -+ ${version.asm} -+ - - - -@@ -105,36 +110,6 @@ - true - ${bytebuddy.extras} - true -- -- -- ${shade.source} -- ${shade.target} -- -- -- -- -- org.ow2.asm:* -- -- **/module-info.class -- **/LICENSE -- **/NOTICE -- -- -- -- org.ow2.asm:asm-commons -- -- org/objectweb/asm/commons/AnnotationRemapper.class -- org/objectweb/asm/commons/ClassRemapper.class -- org/objectweb/asm/commons/FieldRemapper.class -- org/objectweb/asm/commons/MethodRemapper.class -- org/objectweb/asm/commons/ModuleHashesAttribute.class -- org/objectweb/asm/commons/ModuleRemapper.class -- org/objectweb/asm/commons/Remapper.class -- org/objectweb/asm/commons/SignatureRemapper.class -- org/objectweb/asm/commons/SimpleRemapper.class -- -- -- - - - net.bytebuddy.build.Plugin$Engine$Default -@@ -143,21 +118,14 @@ - META-INF/LICENSE - - -+ -+ -+ org.ow2.asm:* -+ -+ - - - -- -- -- org.ow2.asm -- asm -- ${version.asm} -- -- -- org.ow2.asm -- asm-commons -- ${version.asm} -- -- - - - diff --git a/SPECS/byte-buddy.spec b/SPECS/byte-buddy.spec index 9177e8c..a40a61b 100644 --- a/SPECS/byte-buddy.spec +++ b/SPECS/byte-buddy.spec @@ -1,38 +1,47 @@ -Name: byte-buddy -Version: 1.10.1 -Release: 2%{?dist} -Summary: Runtime code generation for the Java virtual machine -License: ASL 2.0 -URL: http://bytebuddy.net/ -# ./generate-tarball.sh -Source0: %{name}-%{version}.tar.gz +%bcond_with bootstrap + +Name: byte-buddy +Version: 1.14.2 +Release: 21%{?dist} +Summary: Runtime code generation for the Java virtual machine +License: Apache-2.0 +URL: http://bytebuddy.net/ +BuildArch: noarch +ExclusiveArch: %{java_arches} noarch + +Source0: https://github.com/raphw/byte-buddy/archive/refs/tags/byte-buddy-%{version}.tar.gz # Patch the build to avoid bundling inside shaded jars -Patch1: avoid-bundling-asm.patch -Patch2: 0001-Remove-dependency-on-jna.patch +Patch: 0001-Avoid-bundling-asm.patch +Patch: 0002-Remove-dependencies.patch +Patch: 0003-Fix-broken-modular-jars.patch +BuildRequires: jurand +%if %{with bootstrap} +BuildRequires: javapackages-bootstrap +%else BuildRequires: maven-local +BuildRequires: mvn(codes.rafael.modulemaker:modulemaker-maven-plugin) BuildRequires: mvn(junit:junit) BuildRequires: mvn(net.bytebuddy:byte-buddy) BuildRequires: mvn(net.bytebuddy:byte-buddy-dep) -BuildRequires: 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) -BuildRequires: mvn(org.ow2.asm:asm-analysis) -BuildRequires: mvn(org.ow2.asm:asm-util) BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) +BuildRequires: mvn(org.apache.maven.plugin-testing:maven-plugin-testing-harness) +BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-annotations) +BuildRequires: mvn(org.apache.maven.plugins:maven-antrun-plugin) +BuildRequires: mvn(org.apache.maven.plugins:maven-plugin-plugin) +BuildRequires: mvn(org.apache.maven:maven-compat) 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.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.mockito:mockito-core) BuildRequires: mvn(org.ow2.asm:asm) +BuildRequires: mvn(org.ow2.asm:asm-analysis) BuildRequires: mvn(org.ow2.asm:asm-commons) - -BuildArch: noarch +BuildRequires: mvn(org.ow2.asm:asm-util) +%endif %description Byte Buddy is a code generation library for creating Java classes during the @@ -42,42 +51,33 @@ 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. %package maven-plugin -Summary: Byte Buddy Maven plugin +Summary: Byte Buddy Maven plugin %description maven-plugin A plugin for post-processing class files via Byte Buddy in a Maven build. -%package parent -Summary: Byte Buddy parent POM - -%description parent -The parent artifact contains configuration information that -concern all modules. - %package javadoc -Summary: Javadoc for %{name} +Summary: API documentation for %{name} %description javadoc -This package contains API documentation for %{name}. +API documentation for %{name}. %prep -%setup -q -n %{name}-%{name}-%{version} +%autosetup -p1 -n %{name}-%{name}-%{version} -%patch1 -p1 -%patch2 -p1 -# 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 -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/ +find -name '*.class' -delete + +rm byte-buddy-agent/src/test/java/net/bytebuddy/agent/VirtualMachineAttachmentTest.java\ + byte-buddy-agent/src/test/java/net/bytebuddy/agent/VirtualMachineForOpenJ9Test.java\ + byte-buddy-agent/src/test/java/net/bytebuddy/test/utility/JnaRule.java\ +; # Don't ship android or benchmark modules %pom_disable_module byte-buddy-android @@ -94,32 +94,36 @@ mv byte-buddy-dep/src/precompiled/java/net/bytebuddy/test/precompiled/*.java \ %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 +%pom_remove_plugin :nexus-staging-maven-plugin + +# Avoid circural dependency +%pom_remove_plugin :byte-buddy-maven-plugin byte-buddy-dep # Not interested in shading sources (causes NPE on old versions of shade plugin) %pom_xpath_set "pom:createSourcesJar" "false" byte-buddy # 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 +%pom_remove_dep -r :findbugs-annotations +%java_remove_annotations byte-buddy-agent byte-buddy-dep byte-buddy-maven-plugin -n SuppressFBWarnings %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_plugin -r :maven-shade-plugin +%pom_remove_dep -r net.java.dev.jna:jna +%pom_remove_dep -r net.java.dev.jna:jna-platform -%pom_remove_dep :jna byte-buddy-agent -%pom_remove_dep :jna-platform byte-buddy-agent +%mvn_package :byte-buddy-parent __noinstall %build # Ignore test failures, there seems to be something different about the # bytecode of our recompiled test resources, expect 6 test failures in # the byte-buddy-dep module -%mvn_build -s -- -P'java8,!checks' -Dsourcecode.test.version=1.8 -Dmaven.test.failure.ignore=true + +# NOTE you can obtain valid profiles for precompilation by: +# xmllint --xpath '//*[local-name()="profile"]/*[local-name()="id"]/text()' byte-buddy-dep/pom.xml | grep 'precompile$' | grep -v 'no-precompile$' | sed 's/\(.*\)/-P\1/' +profiles='-Pjava-8-precompile -Pjava-8-parameters-precompile -Pjava-11-precompile -Pjava-16-precompile -Pjava-17-precompile' +%mvn_build -s -- -P'java8,!checks' "${profiles}" -Dsourcecode.main.version=8 -Dsourcecode.test.version=8 -Dmaven.test.failure.ignore=true %install %mvn_install @@ -133,19 +137,106 @@ sed -i -e '/SuppressFBWarnings/d' $(grep -lr SuppressFBWarnings) %files maven-plugin -f .mfiles-%{name}-maven-plugin -%files parent -f .mfiles-%{name}-parent -%license LICENSE NOTICE - %files javadoc -f .mfiles-javadoc %license LICENSE NOTICE %changelog +* Fri Nov 29 2024 Mikolaj Izdebski - 1.14.2-17 +- Update javapackages test plan to f42 + +* Wed Jul 17 2024 Fedora Release Engineering - 1.14.2-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Tue Feb 27 2024 Jiri Vanek - 1.14.2-8 +- Rebuilt for java-21-openjdk as system jdk + +* Tue Feb 20 2024 Marian Koncek - 1.14.2-7 +- Update Java source/target to 8 + +* Tue Jan 23 2024 Fedora Release Engineering - 1.14.2-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Fri Jan 19 2024 Fedora Release Engineering - 1.14.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Fri Sep 01 2023 Mikolaj Izdebski - 1.14.2-4 +- Convert License tag to SPDX format + +* Wed Aug 30 2023 Mikolaj Izdebski - 1.14.2-3 +- Build with Jurand instead of deprecated javapackages-extra + +* Wed Jul 19 2023 Fedora Release Engineering - 1.14.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Thu Feb 23 2023 Marian Koncek - 1.14.2-1 +- Update to upstream version 1.14.2 + +* Tue Feb 21 2023 Marian Koncek - 1.12.10-4 +- Enable modulemaker-maven-plugin + +* Wed Jan 18 2023 Fedora Release Engineering - 1.12.10-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Wed Jul 20 2022 Fedora Release Engineering - 1.12.10-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Mon May 09 2022 Mikolaj Izdebski - 1.12.10-1 +- Update to upstream version 1.12.10 + +* Sat Feb 05 2022 Jiri Vanek - 1.12.0-3 +- Rebuilt for java-17-openjdk as system jdk + +* Wed Jan 19 2022 Fedora Release Engineering - 1.12.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Tue Nov 09 2021 Marian Koncek - 1.12.0-1 +- Update to upstream version 1.12.0 + +* Wed Jul 21 2021 Fedora Release Engineering - 1.10.20-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Mon May 17 2021 Mikolaj Izdebski - 1.10.20-2 +- Bootstrap build +- Non-bootstrap build + +* Thu Feb 04 2021 Marian Koncek - 1.10.20-1 +- Update to upstream version 1.10.20 + +* Tue Jan 26 2021 Fedora Release Engineering - 1.10.14-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Tue Sep 29 2020 Marian Koncek - 1.10.16-1 +- Update to upstram version 1.10.16 + +* Fri Aug 14 2020 Jerry James - 1.10.14-1 +- Version 1.10.14 +- Remove no longer needed no-unixsocket.patch +- Add workaround for compiling tests with JDK 11 + +* Mon Jul 27 2020 Fedora Release Engineering - 1.9.5-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Fri Jul 10 2020 Jiri Vanek - 1.9.5-8 +- Rebuilt for JDK-11, see https://fedoraproject.org/wiki/Changes/Java11 + +* Tue Jan 28 2020 Fedora Release Engineering - 1.9.5-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Tue Jan 21 2020 Marian Koncek - 1.10.7-1 +- Update to upstream version 1.10.7 + +* Thu Nov 21 2019 Marian Koncek - 1.10.3-1 +- Update to upstream version 1.10.3 + * Tue Nov 05 2019 Mikolaj Izdebski - 1.10.1-2 - Mass rebuild for javapackages-tools 201902 * Thu Sep 12 2019 Marian Koncek - 1.10.1-1 - Update to upstream version 1.10.1 +* Wed Jul 24 2019 Fedora Release Engineering - 1.9.5-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + * Wed Jul 10 2019 Marian Koncek - 1.9.13-2 - Remove the dependency on maven-shade-plugin @@ -155,6 +246,9 @@ sed -i -e '/SuppressFBWarnings/d' $(grep -lr SuppressFBWarnings) * Fri May 24 2019 Mikolaj Izdebski - 1.9.5-5 - Mass rebuild for javapackages-tools 201901 +* Thu Jan 31 2019 Fedora Release Engineering - 1.9.5-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + * Thu Dec 06 2018 Mat Booth - 1.9.5-4 - Prevent NPE in maven-shade-plugin