Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package byte-buddy for openSUSE:Factory checked in at 2024-11-03 07:17:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/byte-buddy (Old) and /work/SRC/openSUSE:Factory/.byte-buddy.new.2020 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "byte-buddy" Sun Nov 3 07:17:45 2024 rev:10 rq:1220321 version:1.15.8 Changes: -------- --- /work/SRC/openSUSE:Factory/byte-buddy/byte-buddy.changes 2024-10-30 17:34:24.896203580 +0100 +++ /work/SRC/openSUSE:Factory/.byte-buddy.new.2020/byte-buddy.changes 2024-11-03 07:18:07.805247430 +0100 @@ -1,0 +2,12 @@ +Sat Nov 2 15:49:57 UTC 2024 - Anton Shvetz <shvetz.an...@gmail.com> + +- Update to v1.15.8 + * Changes of v1.15.8 + + Extend ClassInjector API to support lazy resolution of class + files. + + Extend DynamicType API to support lazy resolution of + auxiliary types. + + Extend AgentBuilder.Transformer.ForAdvice to support + injection of new classes by their name. + +------------------------------------------------------------------- Old: ---- byte-buddy-1.15.7.tar.gz New: ---- byte-buddy-1.15.8.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ byte-buddy.spec ++++++ --- /var/tmp/diff_new_pack.4t3WNN/_old 2024-11-03 07:18:08.461274549 +0100 +++ /var/tmp/diff_new_pack.4t3WNN/_new 2024-11-03 07:18:08.465274715 +0100 @@ -17,7 +17,7 @@ Name: byte-buddy -Version: 1.15.7 +Version: 1.15.8 Release: 0 Summary: Runtime code generation for the Java virtual machine License: Apache-2.0 ++++++ byte-buddy-1.15.7.tar.gz -> byte-buddy-1.15.8.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/.mvn/checksums.sha256 new/byte-buddy-byte-buddy-1.15.8/.mvn/checksums.sha256 --- old/byte-buddy-byte-buddy-1.15.7/.mvn/checksums.sha256 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/.mvn/checksums.sha256 2024-11-01 18:36:01.000000000 +0100 @@ -655,6 +655,7 @@ net.bytebuddy:byte-buddy-agent:jar:1.15.3 f228fd30294bba92e0409edf1318c487d0df0a48a276081bf6e47bb3fb1c14ab net.bytebuddy:byte-buddy-agent:jar:1.15.4 1d76defd159a564b9cb7a968d0dea27367b8b70ebde75a968e7ef1921bc75ee4 net.bytebuddy:byte-buddy-agent:jar:1.15.5 af7473d13f69b555558067b9c8d0d6ffc568b926d1b53b94b8bb419aec151a2c +net.bytebuddy:byte-buddy-agent:jar:1.15.7 be693d8450ef9a849003b56ab9c5e4030a701202adb398e1dec2fe22b86991f6 net.bytebuddy:byte-buddy-android:jar:1.12.19 bb73d3b9ace5a60a9a9aa1701761073b3df3baf79ff463aed6cd94b724fd3ba9 net.bytebuddy:byte-buddy-android:jar:1.12.20 f43b8b7eb840f6140135066224f0e6b565b9becb05345fdc572a66bfb92df0aa net.bytebuddy:byte-buddy-android:jar:1.12.21 bf4ad1405c2fcaa8b179929f9a64c8ee66d04f34b0e3fe8a90b28c738f883fe9 @@ -687,6 +688,7 @@ net.bytebuddy:byte-buddy-android:jar:1.15.3 ee0b719fd4c707bc3be4932257f2110d0732ae934a208973ad0f40c4dfc72419 net.bytebuddy:byte-buddy-android:jar:1.15.4 eeb6912d72c39585dd49b5eb315fcb87d2f901af46c3cb0879fc9c1956a15205 net.bytebuddy:byte-buddy-android:jar:1.15.5 e6c58086cd3d8ca97d6e0ad3b93fa162bbeec759d24749e3a0f90f418f3d9d45 +net.bytebuddy:byte-buddy-android:jar:1.15.7 176a082ad464b893eaab89226df25573b3ee24acaae53dced9db6257f615ebd4 net.bytebuddy:byte-buddy-dep:jar:1.12.19 a85bb853ec6ec156b10ea0b5b0e38ac0f89c6c2bc89dd0358772a0dff2eb85c9 net.bytebuddy:byte-buddy-dep:jar:1.12.20 d7e15d3ccc0508e78a146f1be420779eb3e2e9a537e3c8add3cd6d802c9a615e net.bytebuddy:byte-buddy-dep:jar:1.12.21 116b320c1f3f8539978ea67989d94e9bfed3e9422beb5a76749d967439ec8f9d @@ -719,6 +721,7 @@ net.bytebuddy:byte-buddy-dep:jar:1.15.3 6fb92a21fa28436bc794737fc01b45b16e1178b3f6aa1f1f3b93b197d3a6d0ac net.bytebuddy:byte-buddy-dep:jar:1.15.4 d20dea5ae80fed8ff173461c0d200fdfd4bd268a0dcd544753d3b74e7e7dfde6 net.bytebuddy:byte-buddy-dep:jar:1.15.5 972e5b204703ec2b9748f4f0f545614869b5ab20e5e242523f9eeb5fa34a5a6f +net.bytebuddy:byte-buddy-dep:jar:1.15.7 fe3ff87fa35c07ee7db5cf9b4e7b3cb373a37b69606a18899ccc4d0f5fb6ecea net.bytebuddy:byte-buddy-maven-plugin:jar:1.12.19 3419e2afbfac4f21ef709ee3f8f08fc1d71001e07ba2524a0bb2a3c28f3e1087 net.bytebuddy:byte-buddy-maven-plugin:jar:1.12.20 48a36e2e8c2dbe2b3673ef8bf6be22b021cfca35d6205a3d5e722f74db42d52b net.bytebuddy:byte-buddy-maven-plugin:jar:1.12.21 cb3332f89cc6502e3637dbe509c08c55cb5ad528c675131858dda89eabf7c9fc @@ -748,6 +751,7 @@ net.bytebuddy:byte-buddy-maven-plugin:jar:1.15.3 16610e701b07628b3ef47a9666748234217e53e6fb36c03b556ff8080558ce89 net.bytebuddy:byte-buddy-maven-plugin:jar:1.15.4 2274f3e5fb88248cd237f4b3e43b53a8befd09e71cc4f0f3fcfad09bd7cbd83d net.bytebuddy:byte-buddy-maven-plugin:jar:1.15.5 9dc9c2afc60aa5b02a0f29dfb8d0e9172f1f3aecd43bdd767fd83d7be6d482a6 +net.bytebuddy:byte-buddy-maven-plugin:jar:1.15.7 1c401c1e5fa6409bb722637348374d8e7c4a7f40d6d939fac56fcd9ede1f4c6d net.bytebuddy:byte-buddy-maven-plugin:pom:1.12.19 c2051f8cbdf328692f36077627be07168334ee9167b72e5bf608eae624163b4f net.bytebuddy:byte-buddy-maven-plugin:pom:1.12.20 2d112ff342e7db7da484d038807749c1a87c81419b789a86b950a37bdd65b207 net.bytebuddy:byte-buddy-maven-plugin:pom:1.12.21 13576ca6b9c44ab9789ada11ee400dcd3f4bcc22a7cab6f7052aeeb49a8c02e1 @@ -777,6 +781,7 @@ net.bytebuddy:byte-buddy-maven-plugin:pom:1.15.3 03e3efd289dad0b03dedfcb73d6fef643ff2eb883de698aa87a80fffcab8489c net.bytebuddy:byte-buddy-maven-plugin:pom:1.15.4 419d1b41d67718c954af8f3ba7d0dd6d52e8a7c8d4cd8a9a9ee73d3388a36ea2 net.bytebuddy:byte-buddy-maven-plugin:pom:1.15.5 1686ef4a2465af5d7ac46880b0d65f0bf2c25912aac9621e506452344f4392b8 +net.bytebuddy:byte-buddy-maven-plugin:pom:1.15.7 a71c8ace0f1b05c0e270c36fa450f0104b76e865ee15e71f058cb0d33af03fca net.bytebuddy:byte-buddy-parent:pom:1.12.19 72ab6fef409e812921f4728b3c4b6ef4fa53bc25fabb0488fc2cae367368b54d net.bytebuddy:byte-buddy-parent:pom:1.12.20 ac59dd7bc0316c51ab29e7c44ae7941ba8c7bf84789edb1dc8fbef2f16535b99 net.bytebuddy:byte-buddy-parent:pom:1.12.21 ff66d886607137e2095f20c90ee093f3c80329164eff091a0688bdce37e3e6b2 @@ -806,6 +811,7 @@ net.bytebuddy:byte-buddy-parent:pom:1.15.3 6e2f8cb09d5f363ddf1f9a1f479ebae5ca82fd93f5434c9c61d765393d6252e9 net.bytebuddy:byte-buddy-parent:pom:1.15.4 9702c2213e3fdb7087bfd334b6343cd05f44508a93eb8f94aa7da654ac1fb48f net.bytebuddy:byte-buddy-parent:pom:1.15.5 2a9971f032f3c726004a02695270a812378453e5395cf1b6ebb9082cd295e5c3 +net.bytebuddy:byte-buddy-parent:pom:1.15.7 2716875cac60730ca4f0888bfc31fdee38144a66fe1191ddef56b1a1a4e8a171 net.bytebuddy:byte-buddy:jar:1.12.19 030704139e46f32c38d27060edee9e0676b0a0fff8a8be53461515154ba8a7be net.bytebuddy:byte-buddy:jar:1.12.20 0a9b2795e0e2391117062f0fc7f6ae98fa3c2a7c927847ff1e01bb7cffcd9167 net.bytebuddy:byte-buddy:jar:1.12.21 f6f45c2237a7f132c16745ad2a52c4cdde58028b11ee80b09f0d422f4930d685 @@ -835,6 +841,7 @@ net.bytebuddy:byte-buddy:jar:1.15.3 50f3beedb2caa1f5cc6030eebe716cf409a476c03ec9bea08993cbbc4a32bf68 net.bytebuddy:byte-buddy:jar:1.15.4 4a683d83ff219f20d44f35ca302d821e0c6842e3fa8f9f1ee913eb16f49cec6c net.bytebuddy:byte-buddy:jar:1.15.5 7fb8dbd0da63bb4a5b12c75f020f6a5324120a3991c2291be54f6a96cf419570 +net.bytebuddy:byte-buddy:jar:1.15.7 7f77ee7ae0a6f420218546424a92fc6c964ed5788b21a2559d6be177c5e1a718 net.bytebuddy:byte-buddy:pom:1.12.19 435fb8664aa9b7e120c8dd6c707d4eafa642fa262dff6d5e3f71dc25c69e89eb net.bytebuddy:byte-buddy:pom:1.12.20 46353d5c52659c40f0f54d05c757665552e492be36087c19307598d1bf07bbfb net.bytebuddy:byte-buddy:pom:1.12.21 95eb42c89fd04f62187dd33b9cdf04d2df1b876b375c16ad32c0a5a1cc1a070b @@ -864,6 +871,7 @@ net.bytebuddy:byte-buddy:pom:1.15.3 b8a90d2dbb3d98d91344d69cf7b51e41b13c02151cada67cb6126ca3174054f5 net.bytebuddy:byte-buddy:pom:1.15.4 2fbb9eb7ed5b70285bf04397be78dc2a851d0dc2e74865d81497c61a898e21bd net.bytebuddy:byte-buddy:pom:1.15.5 278642c7ac504a30be5f063ca94789fc1ec701a4c69ec7bc2ab2195bea556903 +net.bytebuddy:byte-buddy:pom:1.15.7 a7dd564349be167ceb3442a08262425857a7532e1d7426e224fa9673e6830dc6 net.i2p.crypto:eddsa:jar:0.3.0 4dda1120db856640dbec04140ed23242215a075fe127bdefa0dcfa29fb31267d net.i2p.crypto:eddsa:pom:0.3.0 b6b13878e4bae8b768d7ea5732cb4d66ab2f5e9fe707c0a1a776cde9de52051b net.java.dev.jna:jna-platform:jar:5.12.1 8ce969116cac95bd61b07a8d5e07174b352e63301473caac72c395e3c08488d2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy/pom.xml new/byte-buddy-byte-buddy-1.15.8/byte-buddy/pom.xml --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy/pom.xml 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy/pom.xml 2024-11-01 18:36:01.000000000 +0100 @@ -5,7 +5,7 @@ <parent> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-parent</artifactId> - <version>1.15.7</version> + <version>1.15.8</version> </parent> <artifactId>byte-buddy</artifactId> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-agent/pom.xml new/byte-buddy-byte-buddy-1.15.8/byte-buddy-agent/pom.xml --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-agent/pom.xml 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-agent/pom.xml 2024-11-01 18:36:01.000000000 +0100 @@ -5,7 +5,7 @@ <parent> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-parent</artifactId> - <version>1.15.7</version> + <version>1.15.8</version> </parent> <artifactId>byte-buddy-agent</artifactId> @@ -69,7 +69,7 @@ <dependency> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> - <version>1.15.5</version> + <version>1.15.7</version> <scope>test</scope> </dependency> </dependencies> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-android/pom.xml new/byte-buddy-byte-buddy-1.15.8/byte-buddy-android/pom.xml --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-android/pom.xml 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-android/pom.xml 2024-11-01 18:36:01.000000000 +0100 @@ -5,7 +5,7 @@ <parent> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-parent</artifactId> - <version>1.15.7</version> + <version>1.15.8</version> </parent> <artifactId>byte-buddy-android</artifactId> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-android-test/pom.xml new/byte-buddy-byte-buddy-1.15.8/byte-buddy-android-test/pom.xml --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-android-test/pom.xml 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-android-test/pom.xml 2024-11-01 18:36:01.000000000 +0100 @@ -5,7 +5,7 @@ <parent> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-parent</artifactId> - <version>1.15.7</version> + <version>1.15.8</version> </parent> <artifactId>byte-buddy-android-test</artifactId> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-benchmark/pom.xml new/byte-buddy-byte-buddy-1.15.8/byte-buddy-benchmark/pom.xml --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-benchmark/pom.xml 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-benchmark/pom.xml 2024-11-01 18:36:01.000000000 +0100 @@ -5,7 +5,7 @@ <parent> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-parent</artifactId> - <version>1.15.7</version> + <version>1.15.8</version> </parent> <artifactId>byte-buddy-benchmark</artifactId> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/pom.xml new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/pom.xml --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/pom.xml 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/pom.xml 2024-11-01 18:36:01.000000000 +0100 @@ -5,7 +5,7 @@ <parent> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-parent</artifactId> - <version>1.15.7</version> + <version>1.15.8</version> </parent> <!-- @@ -127,7 +127,7 @@ <plugin> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-maven-plugin</artifactId> - <version>1.15.5</version> + <version>1.15.7</version> <executions> <execution> <phase>compile</phase> @@ -142,7 +142,7 @@ <transformation> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> - <version>1.15.5</version> + <version>1.15.7</version> <plugin>net.bytebuddy.build.HashCodeAndEqualsPlugin$WithNonNullableFields</plugin> <arguments> <argument> @@ -154,13 +154,13 @@ <transformation> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> - <version>1.15.5</version> + <version>1.15.7</version> <plugin>net.bytebuddy.build.CachedReturnPlugin</plugin> </transformation> <transformation> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> - <version>1.15.5</version> + <version>1.15.7</version> <plugin>net.bytebuddy.build.AccessControllerPlugin</plugin> <arguments> <argument> @@ -172,13 +172,13 @@ <transformation> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> - <version>1.15.5</version> + <version>1.15.7</version> <plugin>net.bytebuddy.build.DispatcherAnnotationPlugin</plugin> </transformation> <transformation> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> - <version>1.15.5</version> + <version>1.15.7</version> <plugin>net.bytebuddy.build.RepeatedAnnotationPlugin</plugin> </transformation> </transformations> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/main/java/net/bytebuddy/agent/builder/AgentBuilder.java new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/main/java/net/bytebuddy/agent/builder/AgentBuilder.java --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/main/java/net/bytebuddy/agent/builder/AgentBuilder.java 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/main/java/net/bytebuddy/agent/builder/AgentBuilder.java 2024-11-01 18:36:01.000000000 +0100 @@ -84,12 +84,7 @@ import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; -import java.io.File; -import java.io.NotSerializableException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.PrintStream; -import java.io.Serializable; +import java.io.*; import java.lang.instrument.ClassDefinition; import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.IllegalClassFormatException; @@ -3049,6 +3044,11 @@ private final List<Entry> entries; /** + * The names of auxiliary types to inject. + */ + private final List<String> auxiliaries; + + /** * Creates a new advice transformer with a default setup. */ public ForAdvice() { @@ -3067,7 +3067,8 @@ ClassFileLocator.NoOp.INSTANCE, PoolStrategy.Default.FAST, LocationStrategy.ForClassLoader.STRONG, - Collections.<Entry>emptyList()); + Collections.<Entry>emptyList(), + Collections.<String>emptyList()); } /** @@ -3080,6 +3081,7 @@ * @param poolStrategy The pool strategy to use for looking up an advice. * @param locationStrategy The location strategy to use for class loaders when resolving advice classes. * @param entries The advice entries to apply. + * @param auxiliaries The names of auxiliary types to inject. */ protected ForAdvice(Advice.WithCustomMapping advice, Advice.ExceptionHandler exceptionHandler, @@ -3087,7 +3089,8 @@ ClassFileLocator classFileLocator, PoolStrategy poolStrategy, LocationStrategy locationStrategy, - List<Entry> entries) { + List<Entry> entries, + List<String> auxiliaries) { this.advice = advice; this.exceptionHandler = exceptionHandler; this.assigner = assigner; @@ -3095,6 +3098,7 @@ this.poolStrategy = poolStrategy; this.locationStrategy = locationStrategy; this.entries = entries; + this.auxiliaries = auxiliaries; } /** @@ -3107,6 +3111,9 @@ @MaybeNull ProtectionDomain protectionDomain) { ClassFileLocator classFileLocator = new ClassFileLocator.Compound(this.classFileLocator, locationStrategy.classFileLocator(classLoader, module)); TypePool typePool = poolStrategy.typePool(classFileLocator, classLoader); + for (String auxiliary : auxiliaries) { + builder = builder.require(new LazyDynamicType(typePool.describe(auxiliary).resolve(), classFileLocator)); + } AsmVisitorWrapper.ForDeclaredMethods asmVisitorWrapper = new AsmVisitorWrapper.ForDeclaredMethods(); for (Entry entry : entries) { asmVisitorWrapper = asmVisitorWrapper.invokable(entry.getMatcher().resolve(typeDescription), wrap(typeDescription, @@ -3149,6 +3156,7 @@ * @param poolStrategy The pool strategy to use for looking up an advice. * @param locationStrategy The location strategy to use for class loaders when resolving advice classes. * @param entries The advice entries to apply. + * @param auxiliaries The names of auxiliary types to inject. * @return An appropriate advice transformer. */ protected ForAdvice make(Advice.WithCustomMapping advice, @@ -3157,8 +3165,9 @@ ClassFileLocator classFileLocator, PoolStrategy poolStrategy, LocationStrategy locationStrategy, - List<Entry> entries) { - return new ForAdvice(advice, exceptionHandler, assigner, classFileLocator, poolStrategy, locationStrategy, entries); + List<Entry> entries, + List<String> auxiliaries) { + return new ForAdvice(advice, exceptionHandler, assigner, classFileLocator, poolStrategy, locationStrategy, entries, auxiliaries); } /** @@ -3168,7 +3177,7 @@ * @return A new instance of this advice transformer that applies the supplied pool strategy. */ public ForAdvice with(PoolStrategy poolStrategy) { - return make(advice, exceptionHandler, assigner, classFileLocator, poolStrategy, locationStrategy, entries); + return make(advice, exceptionHandler, assigner, classFileLocator, poolStrategy, locationStrategy, entries, auxiliaries); } /** @@ -3179,7 +3188,7 @@ * @return A new instance of this advice transformer that applies the supplied location strategy. */ public ForAdvice with(LocationStrategy locationStrategy) { - return make(advice, exceptionHandler, assigner, classFileLocator, poolStrategy, locationStrategy, entries); + return make(advice, exceptionHandler, assigner, classFileLocator, poolStrategy, locationStrategy, entries, auxiliaries); } /** @@ -3190,7 +3199,7 @@ * @see Advice#withExceptionHandler(StackManipulation) */ public ForAdvice withExceptionHandler(Advice.ExceptionHandler exceptionHandler) { - return make(advice, exceptionHandler, assigner, classFileLocator, poolStrategy, locationStrategy, entries); + return make(advice, exceptionHandler, assigner, classFileLocator, poolStrategy, locationStrategy, entries, auxiliaries); } /** @@ -3201,7 +3210,7 @@ * @see Advice#withAssigner(Assigner) */ public ForAdvice with(Assigner assigner) { - return make(advice, exceptionHandler, assigner, classFileLocator, poolStrategy, locationStrategy, entries); + return make(advice, exceptionHandler, assigner, classFileLocator, poolStrategy, locationStrategy, entries, auxiliaries); } /** @@ -3244,7 +3253,8 @@ new ClassFileLocator.Compound(CompoundList.of(classFileLocator, classFileLocators)), poolStrategy, locationStrategy, - entries); + entries, + auxiliaries); } /** @@ -3272,7 +3282,8 @@ classFileLocator, poolStrategy, locationStrategy, - CompoundList.of(entries, new Entry.ForUnifiedAdvice(matcher, name))); + CompoundList.of(entries, new Entry.ForUnifiedAdvice(matcher, name)), + auxiliaries); } /** @@ -3302,7 +3313,35 @@ classFileLocator, poolStrategy, locationStrategy, - CompoundList.of(entries, new Entry.ForSplitAdvice(matcher, enter, exit))); + CompoundList.of(entries, new Entry.ForSplitAdvice(matcher, enter, exit)), + auxiliaries); + } + + /** + * Adds the given auxiliary types for injection. + * + * @param auxiliary The names of the auxiliary types to inject. + * @return A new instance of this advice transformer that resolves and adds the specified auxiliary types. + */ + public ForAdvice auxiliary(String... auxiliary) { + return auxiliary(Arrays.asList(auxiliary)); + } + + /** + * Adds the given auxiliary types for injection. + * + * @param auxiliaries The names of the auxiliary types to inject. + * @return A new instance of this advice transformer that resolves and adds the specified auxiliary types. + */ + public ForAdvice auxiliary(List<String> auxiliaries) { + return make(advice, + exceptionHandler, + assigner, + classFileLocator, + poolStrategy, + locationStrategy, + entries, + CompoundList.of(this.auxiliaries, auxiliaries)); } /** @@ -3407,6 +3446,66 @@ } } } + + /** + * A lazy dynamic type that only loads a class file representation on demand. + */ + @HashCodeAndEqualsPlugin.Enhance + protected static class LazyDynamicType extends DynamicType.AbstractBase { + + /** + * A description of the class to inject. + */ + private final TypeDescription typeDescription; + + /** + * The class file locator to use. + */ + private final ClassFileLocator classFileLocator; + + /** + * Creates a lazy dynamic type. + * + * @param typeDescription A description of the class to inject. + * @param classFileLocator The class file locator to use. + */ + protected LazyDynamicType(TypeDescription typeDescription, ClassFileLocator classFileLocator) { + this.typeDescription = typeDescription; + this.classFileLocator = classFileLocator; + } + + /** + * {@inheritDoc} + */ + public TypeDescription getTypeDescription() { + return typeDescription; + } + + /** + * {@inheritDoc} + */ + public byte[] getBytes() { + try { + return classFileLocator.locate(typeDescription.getName()).resolve(); + } catch (IOException exception) { + throw new IllegalStateException("Failed to resolve class file for " + typeDescription, exception); + } + } + + /** + * {@inheritDoc} + */ + public List<? extends DynamicType> getAuxiliaries() { + return Collections.<DynamicType>emptyList(); + } + + /** + * {@inheritDoc} + */ + public LoadedTypeInitializer getLoadedTypeInitializer() { + return LoadedTypeInitializer.NoOp.INSTANCE; + } + } } } @@ -3871,9 +3970,8 @@ @MaybeNull ClassLoader classLoader, @MaybeNull ProtectionDomain protectionDomain, InjectionStrategy injectionStrategy) { - Map<TypeDescription, byte[]> auxiliaryTypes = dynamicType.getAuxiliaryTypes(); - Map<TypeDescription, byte[]> independentTypes = new LinkedHashMap<TypeDescription, byte[]>(auxiliaryTypes); - for (TypeDescription auxiliaryType : auxiliaryTypes.keySet()) { + Set<TypeDescription> auxiliaryTypes = dynamicType.getAuxiliaryTypeDescriptions(), independentTypes = new LinkedHashSet<TypeDescription>(auxiliaryTypes); + for (TypeDescription auxiliaryType : auxiliaryTypes) { if (!auxiliaryType.getDeclaredAnnotations().isAnnotationPresent(AuxiliaryType.SignatureRelevant.class)) { independentTypes.remove(auxiliaryType); } @@ -3881,7 +3979,7 @@ if (!independentTypes.isEmpty()) { ClassInjector classInjector = injectionStrategy.resolve(classLoader, protectionDomain); Map<TypeDescription, LoadedTypeInitializer> loadedTypeInitializers = dynamicType.getLoadedTypeInitializers(); - for (Map.Entry<TypeDescription, Class<?>> entry : classInjector.inject(independentTypes).entrySet()) { + for (Map.Entry<TypeDescription, Class<?>> entry : classInjector.inject(independentTypes, dynamicType).entrySet()) { loadedTypeInitializers.get(entry.getKey()).onLoad(entry.getValue()); } } @@ -3971,9 +4069,14 @@ private final TypeDescription instrumentedType; /** - * The auxiliary types mapped to their class file representation. + * The auxiliary types to inject. + */ + private final Set<TypeDescription> auxiliaryTypes; + + /** + * The class file locator to use. */ - private final Map<TypeDescription, byte[]> rawAuxiliaryTypes; + private final ClassFileLocator classFileLocator; /** * The instrumented types and auxiliary types mapped to their loaded type initializers. @@ -3990,16 +4093,19 @@ * Creates a new injection initializer. * * @param instrumentedType The instrumented type. - * @param rawAuxiliaryTypes The auxiliary types mapped to their class file representation. + * @param auxiliaryTypes The auxiliary types to inject. + * @param classFileLocator The class file locator to use. * @param loadedTypeInitializers The instrumented types and auxiliary types mapped to their loaded type initializers. * @param classInjector The class injector to use. */ protected InjectingInitializer(TypeDescription instrumentedType, - Map<TypeDescription, byte[]> rawAuxiliaryTypes, + Set<TypeDescription> auxiliaryTypes, + ClassFileLocator classFileLocator, Map<TypeDescription, LoadedTypeInitializer> loadedTypeInitializers, ClassInjector classInjector) { this.instrumentedType = instrumentedType; - this.rawAuxiliaryTypes = rawAuxiliaryTypes; + this.auxiliaryTypes = auxiliaryTypes; + this.classFileLocator = classFileLocator; this.loadedTypeInitializers = loadedTypeInitializers; this.classInjector = classInjector; } @@ -4008,7 +4114,7 @@ * {@inheritDoc} */ public void onLoad(Class<?> type) { - for (Map.Entry<TypeDescription, Class<?>> auxiliary : classInjector.inject(rawAuxiliaryTypes).entrySet()) { + for (Map.Entry<TypeDescription, Class<?>> auxiliary : classInjector.inject(auxiliaryTypes, classFileLocator).entrySet()) { loadedTypeInitializers.get(auxiliary.getKey()).onLoad(auxiliary.getValue()); } loadedTypeInitializers.get(instrumentedType).onLoad(type); @@ -4073,28 +4179,28 @@ @MaybeNull ClassLoader classLoader, @MaybeNull ProtectionDomain protectionDomain, InjectionStrategy injectionStrategy) { - Map<TypeDescription, byte[]> auxiliaryTypes = dynamicType.getAuxiliaryTypes(); + Set<TypeDescription> auxiliaryTypes = dynamicType.getAuxiliaryTypeDescriptions(); LoadedTypeInitializer loadedTypeInitializer; if (!auxiliaryTypes.isEmpty()) { TypeDescription instrumentedType = dynamicType.getTypeDescription(); ClassInjector classInjector = injectionStrategy.resolve(classLoader, protectionDomain); - Map<TypeDescription, byte[]> independentTypes = new LinkedHashMap<TypeDescription, byte[]>(auxiliaryTypes); - Map<TypeDescription, byte[]> dependentTypes = new LinkedHashMap<TypeDescription, byte[]>(auxiliaryTypes); - for (TypeDescription auxiliaryType : auxiliaryTypes.keySet()) { + Set<TypeDescription> independentTypes = new LinkedHashSet<TypeDescription>(auxiliaryTypes); + Set<TypeDescription> dependentTypes = new LinkedHashSet<TypeDescription>(auxiliaryTypes); + for (TypeDescription auxiliaryType : auxiliaryTypes) { (auxiliaryType.getDeclaredAnnotations().isAnnotationPresent(AuxiliaryType.SignatureRelevant.class) ? dependentTypes : independentTypes).remove(auxiliaryType); } Map<TypeDescription, LoadedTypeInitializer> loadedTypeInitializers = dynamicType.getLoadedTypeInitializers(); if (!independentTypes.isEmpty()) { - for (Map.Entry<TypeDescription, Class<?>> entry : classInjector.inject(independentTypes).entrySet()) { + for (Map.Entry<TypeDescription, Class<?>> entry : classInjector.inject(independentTypes, dynamicType).entrySet()) { loadedTypeInitializers.get(entry.getKey()).onLoad(entry.getValue()); } } Map<TypeDescription, LoadedTypeInitializer> lazyInitializers = new HashMap<TypeDescription, LoadedTypeInitializer>(loadedTypeInitializers); - loadedTypeInitializers.keySet().removeAll(independentTypes.keySet()); + loadedTypeInitializers.keySet().removeAll(independentTypes); loadedTypeInitializer = lazyInitializers.size() > 1 // there exist auxiliary types that need lazy loading - ? new Dispatcher.InjectingInitializer(instrumentedType, dependentTypes, lazyInitializers, classInjector) + ? new Dispatcher.InjectingInitializer(instrumentedType, dependentTypes, dynamicType, lazyInitializers, classInjector) : lazyInitializers.get(instrumentedType); } else { loadedTypeInitializer = dynamicType.getLoadedTypeInitializers().get(dynamicType.getTypeDescription()); @@ -4152,10 +4258,10 @@ @MaybeNull ClassLoader classLoader, @MaybeNull ProtectionDomain protectionDomain, InjectionStrategy injectionStrategy) { - Map<TypeDescription, byte[]> auxiliaryTypes = dynamicType.getAuxiliaryTypes(); + Set<TypeDescription> auxiliaryTypes = dynamicType.getAuxiliaryTypeDescriptions(); LoadedTypeInitializer loadedTypeInitializer = auxiliaryTypes.isEmpty() ? dynamicType.getLoadedTypeInitializers().get(dynamicType.getTypeDescription()) - : new Dispatcher.InjectingInitializer(dynamicType.getTypeDescription(), auxiliaryTypes, dynamicType.getLoadedTypeInitializers(), injectionStrategy.resolve(classLoader, protectionDomain)); + : new Dispatcher.InjectingInitializer(dynamicType.getTypeDescription(), auxiliaryTypes, dynamicType, dynamicType.getLoadedTypeInitializers(), injectionStrategy.resolve(classLoader, protectionDomain)); nexusAccessor.register(dynamicType.getTypeDescription().getName(), classLoader, identification, loadedTypeInitializer); } } @@ -4209,10 +4315,10 @@ @MaybeNull ClassLoader classLoader, @MaybeNull ProtectionDomain protectionDomain, InjectionStrategy injectionStrategy) { - Map<TypeDescription, byte[]> auxiliaryTypes = dynamicType.getAuxiliaryTypes(); + Set<TypeDescription> auxiliaryTypes = dynamicType.getAuxiliaryTypeDescriptions(); Map<TypeDescription, LoadedTypeInitializer> loadedTypeInitializers = dynamicType.getLoadedTypeInitializers(); if (!auxiliaryTypes.isEmpty()) { - for (Map.Entry<TypeDescription, Class<?>> entry : injectionStrategy.resolve(classLoader, protectionDomain).inject(auxiliaryTypes).entrySet()) { + for (Map.Entry<TypeDescription, Class<?>> entry : injectionStrategy.resolve(classLoader, protectionDomain).inject(auxiliaryTypes, dynamicType).entrySet()) { loadedTypeInitializers.get(entry.getKey()).onLoad(entry.getValue()); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/DynamicType.java new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/DynamicType.java --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/DynamicType.java 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/DynamicType.java 2024-11-01 18:36:01.000000000 +0100 @@ -87,6 +87,34 @@ byte[] getBytes(); /** + * Returns the loaded type initializer of this dynamic type. + * + * @return The loaded type initializer of this dynamic type. + */ + LoadedTypeInitializer getLoadedTypeInitializer(); + + /** + * Returns all auxiliary types of this dynamic type. + * + * @return A list of all auxiliary types of this dynamic type. + */ + List<? extends DynamicType> getAuxiliaries(); + + /** + * Returns a set of all auxiliary types that are represented by this dynamic type. + * + * @return A set of all auxiliary types. + */ + Set<TypeDescription> getAuxiliaryTypeDescriptions(); + + /** + * Returns a set of all types that are represented by this dynamic type. + * + * @return A set of all represented types. + */ + Set<TypeDescription> getAllTypeDescriptions(); + + /** * <p> * Returns a map of all auxiliary types that are required for making use of the main type. * </p> @@ -6025,11 +6053,8 @@ Map<TypeDescription, Class<?>> getAllLoaded(); } - /** - * A default implementation of a dynamic type. - */ @HashCodeAndEqualsPlugin.Enhance - class Default implements DynamicType { + abstract class AbstractBase implements DynamicType { /** * The file name extension for Java class files. @@ -6042,72 +6067,18 @@ private static final String MANIFEST_VERSION = "1.0"; /** - * The size of a writing buffer. - */ - private static final int BUFFER_SIZE = 1024; - - /** - * A convenience index for the beginning of an array to improve the readability of the code. - */ - private static final int FROM_BEGINNING = 0; - - /** - * A convenience representative of an {@link java.io.InputStream}'s end to improve the readability of the code. - */ - private static final int END_OF_FILE = -1; - - /** * A suffix for temporary files. */ private static final String TEMP_SUFFIX = "tmp"; /** - * A type description of this dynamic type. - */ - protected final TypeDescription typeDescription; - - /** - * The byte array representing this dynamic type. - */ - protected final byte[] binaryRepresentation; - - /** - * The loaded type initializer for this dynamic type. - */ - protected final LoadedTypeInitializer loadedTypeInitializer; - - /** - * A list of auxiliary types for this dynamic type. - */ - protected final List<? extends DynamicType> auxiliaryTypes; - - /** - * Creates a new dynamic type. - * - * @param typeDescription A description of this dynamic type. - * @param binaryRepresentation A byte array containing the binary representation of this dynamic type. The array must not be modified. - * @param loadedTypeInitializer The loaded type initializer of this dynamic type. - * @param auxiliaryTypes The auxiliary type required for this dynamic type. - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "The array is not modified by class contract.") - public Default(TypeDescription typeDescription, - byte[] binaryRepresentation, - LoadedTypeInitializer loadedTypeInitializer, - List<? extends DynamicType> auxiliaryTypes) { - this.typeDescription = typeDescription; - this.binaryRepresentation = binaryRepresentation; - this.loadedTypeInitializer = loadedTypeInitializer; - this.auxiliaryTypes = auxiliaryTypes; - } - - /** * {@inheritDoc} */ public Resolution locate(String name) throws IOException { - if (typeDescription.getName().equals(name)) { - return new Resolution.Explicit(binaryRepresentation); + if (getTypeDescription().getName().equals(name)) { + return new Resolution.Explicit(getBytes()); } - for (DynamicType auxiliaryType : auxiliaryTypes) { + for (DynamicType auxiliaryType : getAuxiliaries()) { Resolution resolution = auxiliaryType.locate(name); if (resolution.isResolved()) { return resolution; @@ -6126,8 +6097,24 @@ /** * {@inheritDoc} */ - public TypeDescription getTypeDescription() { - return typeDescription; + public Set<TypeDescription> getAuxiliaryTypeDescriptions() { + Set<TypeDescription> types = new LinkedHashSet<TypeDescription>(); + for (DynamicType auxiliaryType : getAuxiliaries()) { + types.addAll(auxiliaryType.getAllTypeDescriptions()); + } + return types; + } + + /** + * {@inheritDoc} + */ + public Set<TypeDescription> getAllTypeDescriptions() { + Set<TypeDescription> types = new LinkedHashSet<TypeDescription>(); + types.add(getTypeDescription()); + for (DynamicType auxiliaryType : getAuxiliaries()) { + types.addAll(auxiliaryType.getAllTypeDescriptions()); + } + return types; } /** @@ -6135,8 +6122,8 @@ */ public Map<TypeDescription, byte[]> getAllTypes() { Map<TypeDescription, byte[]> allTypes = new LinkedHashMap<TypeDescription, byte[]>(); - allTypes.put(typeDescription, binaryRepresentation); - for (DynamicType auxiliaryType : auxiliaryTypes) { + allTypes.put(getTypeDescription(), getBytes()); + for (DynamicType auxiliaryType : getAuxiliaries()) { allTypes.putAll(auxiliaryType.getAllTypes()); } return allTypes; @@ -6147,10 +6134,10 @@ */ public Map<TypeDescription, LoadedTypeInitializer> getLoadedTypeInitializers() { Map<TypeDescription, LoadedTypeInitializer> classLoadingCallbacks = new HashMap<TypeDescription, LoadedTypeInitializer>(); - for (DynamicType auxiliaryType : auxiliaryTypes) { + for (DynamicType auxiliaryType : getAuxiliaries()) { classLoadingCallbacks.putAll(auxiliaryType.getLoadedTypeInitializers()); } - classLoadingCallbacks.put(typeDescription, loadedTypeInitializer); + classLoadingCallbacks.put(getTypeDescription(), getLoadedTypeInitializer()); return classLoadingCallbacks; } @@ -6158,8 +6145,11 @@ * {@inheritDoc} */ public boolean hasAliveLoadedTypeInitializers() { - for (LoadedTypeInitializer loadedTypeInitializer : getLoadedTypeInitializers().values()) { - if (loadedTypeInitializer.isAlive()) { + if (getLoadedTypeInitializer().isAlive()) { + return true; + } + for (DynamicType auxiliaryType : getAuxiliaries()) { + if (auxiliaryType.hasAliveLoadedTypeInitializers()) { return true; } } @@ -6169,17 +6159,9 @@ /** * {@inheritDoc} */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "The array is not modified by class contract.") - public byte[] getBytes() { - return binaryRepresentation; - } - - /** - * {@inheritDoc} - */ public Map<TypeDescription, byte[]> getAuxiliaryTypes() { Map<TypeDescription, byte[]> auxiliaryTypes = new HashMap<TypeDescription, byte[]>(); - for (DynamicType auxiliaryType : this.auxiliaryTypes) { + for (DynamicType auxiliaryType : getAuxiliaries()) { auxiliaryTypes.put(auxiliaryType.getTypeDescription(), auxiliaryType.getBytes()); auxiliaryTypes.putAll(auxiliaryType.getAuxiliaryTypes()); } @@ -6191,18 +6173,18 @@ */ public Map<TypeDescription, File> saveIn(File folder) throws IOException { Map<TypeDescription, File> files = new HashMap<TypeDescription, File>(); - File target = new File(folder, typeDescription.getName().replace('.', File.separatorChar) + CLASS_FILE_EXTENSION); + File target = new File(folder, getTypeDescription().getName().replace('.', File.separatorChar) + CLASS_FILE_EXTENSION); if (target.getParentFile() != null && !target.getParentFile().isDirectory() && !target.getParentFile().mkdirs()) { throw new IllegalArgumentException("Could not create directory: " + target.getParentFile()); } OutputStream outputStream = new FileOutputStream(target); try { - outputStream.write(binaryRepresentation); + outputStream.write(getBytes()); } finally { outputStream.close(); } - files.put(typeDescription, target); - for (DynamicType auxiliaryType : auxiliaryTypes) { + files.put(getTypeDescription(), target); + for (DynamicType auxiliaryType : getAuxiliaries()) { files.putAll(auxiliaryType.saveIn(folder)); } return files; @@ -6249,16 +6231,16 @@ for (Map.Entry<TypeDescription, byte[]> entry : rawAuxiliaryTypes.entrySet()) { files.put(entry.getKey().getInternalName() + CLASS_FILE_EXTENSION, entry.getValue()); } - files.put(typeDescription.getInternalName() + CLASS_FILE_EXTENSION, binaryRepresentation); + files.put(getTypeDescription().getInternalName() + CLASS_FILE_EXTENSION, getBytes()); JarEntry jarEntry; while ((jarEntry = inputStream.getNextJarEntry()) != null) { byte[] replacement = files.remove(jarEntry.getName()); if (replacement == null) { outputStream.putNextEntry(jarEntry); - byte[] buffer = new byte[BUFFER_SIZE]; + byte[] buffer = new byte[1024]; int index; - while ((index = inputStream.read(buffer)) != END_OF_FILE) { - outputStream.write(buffer, FROM_BEGINNING, index); + while ((index = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, index); } } else { outputStream.putNextEntry(new JarEntry(jarEntry.getName())); @@ -6304,14 +6286,89 @@ outputStream.write(entry.getValue()); outputStream.closeEntry(); } - outputStream.putNextEntry(new JarEntry(typeDescription.getInternalName() + CLASS_FILE_EXTENSION)); - outputStream.write(binaryRepresentation); + outputStream.putNextEntry(new JarEntry(getTypeDescription().getInternalName() + CLASS_FILE_EXTENSION)); + outputStream.write(getBytes()); outputStream.closeEntry(); } finally { outputStream.close(); } return file; } + } + + /** + * A default implementation of a dynamic type. + */ + @HashCodeAndEqualsPlugin.Enhance + class Default extends AbstractBase { + + /** + * A type description of this dynamic type. + */ + protected final TypeDescription typeDescription; + + /** + * The byte array representing this dynamic type. + */ + protected final byte[] binaryRepresentation; + + /** + * The loaded type initializer for this dynamic type. + */ + protected final LoadedTypeInitializer loadedTypeInitializer; + + /** + * A list of auxiliary types for this dynamic type. + */ + protected final List<? extends DynamicType> auxiliaryTypes; + + /** + * Creates a new dynamic type. + * + * @param typeDescription A description of this dynamic type. + * @param binaryRepresentation A byte array containing the binary representation of this dynamic type. The array must not be modified. + * @param loadedTypeInitializer The loaded type initializer of this dynamic type. + * @param auxiliaryTypes The auxiliary type required for this dynamic type. + */ + @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "The array is not modified by class contract.") + public Default(TypeDescription typeDescription, + byte[] binaryRepresentation, + LoadedTypeInitializer loadedTypeInitializer, + List<? extends DynamicType> auxiliaryTypes) { + this.typeDescription = typeDescription; + this.binaryRepresentation = binaryRepresentation; + this.loadedTypeInitializer = loadedTypeInitializer; + this.auxiliaryTypes = auxiliaryTypes; + } + + /** + * {@inheritDoc} + */ + public TypeDescription getTypeDescription() { + return typeDescription; + } + + /** + * {@inheritDoc} + */ + @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "The array is not modified by class contract.") + public byte[] getBytes() { + return binaryRepresentation; + } + + /** + * {@inheritDoc} + */ + public LoadedTypeInitializer getLoadedTypeInitializer() { + return loadedTypeInitializer; + } + + /** + * {@inheritDoc} + */ + public List<? extends DynamicType> getAuxiliaries() { + return auxiliaryTypes; + } /** * A default implementation of an unloaded dynamic type. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/loading/ClassInjector.java new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/loading/ClassInjector.java --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/loading/ClassInjector.java 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/loading/ClassInjector.java 2024-11-01 18:36:01.000000000 +0100 @@ -25,6 +25,7 @@ import net.bytebuddy.description.modifier.Visibility; import net.bytebuddy.description.type.PackageDescription; import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.dynamic.ClassFileLocator; import net.bytebuddy.dynamic.DynamicType; import net.bytebuddy.dynamic.scaffold.TypeValidation; import net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy; @@ -90,18 +91,36 @@ /** * Injects the given types into the represented class loader. * + * @param types The types to load via injection. + * @param classFileLocator The class file locator to use for resolving binary representations. + * @return The loaded types that were passed as arguments. + */ + Map<TypeDescription, Class<?>> inject(Set<? extends TypeDescription> types, ClassFileLocator classFileLocator); + + /** + * Injects the given types into the represented class loader. + * + * @param names The names of the types to load via injection. + * @param classFileLocator The class file locator to use for resolving binary representations. + * @return The loaded types that were passed as arguments. + */ + Map<String, Class<?>> injectRaw(Set<String> names, ClassFileLocator classFileLocator); + + /** + * Injects the given types into the represented class loader. + * * @param types The types to load via injection. * @return The loaded types that were passed as arguments. */ Map<TypeDescription, Class<?>> inject(Map<? extends TypeDescription, byte[]> types); /** - * Injects the given types into the represented class loader using a mapping from name to binary representation. + * Injects the given types into the represented class loader. * - * @param types The types to load via injection. + * @param types The names of the type to load via injection. * @return The loaded types that were passed as arguments. */ - Map<String, Class<?>> injectRaw(Map<? extends String, byte[]> types); + Map<String, Class<?>> injectRaw(Map<String, byte[]> types); /** * An abstract base implementation of a class injector. @@ -111,18 +130,41 @@ /** * {@inheritDoc} */ + public Map<TypeDescription, Class<?>> inject(Set<? extends TypeDescription> types, ClassFileLocator classFileLocator) { + Set<String> names = new LinkedHashSet<String>(); + for (TypeDescription type : types) { + names.add(type.getName()); + } + Map<String, Class<?>> loadedTypes = injectRaw(names, classFileLocator); + Map<TypeDescription, Class<?>> result = new HashMap<TypeDescription, Class<?>>(); + for (TypeDescription type : types) { + result.put(type, loadedTypes.get(type.getName())); + } + return result; + } + + /** + * {@inheritDoc} + */ public Map<TypeDescription, Class<?>> inject(Map<? extends TypeDescription, byte[]> types) { Map<String, byte[]> binaryRepresentations = new LinkedHashMap<String, byte[]>(); for (Map.Entry<? extends TypeDescription, byte[]> entry : types.entrySet()) { binaryRepresentations.put(entry.getKey().getName(), entry.getValue()); } Map<String, Class<?>> loadedTypes = injectRaw(binaryRepresentations); - Map<TypeDescription, Class<?>> result = new LinkedHashMap<TypeDescription, Class<?>>(); + Map<TypeDescription, Class<?>> result = new HashMap<TypeDescription, Class<?>>(); for (TypeDescription typeDescription : types.keySet()) { result.put(typeDescription, loadedTypes.get(typeDescription.getName())); } return result; } + + /** + * {@inheritDoc} + */ + public Map<String, Class<?>> injectRaw(Map<String, byte[]> types) { + return injectRaw(types.keySet(), new ClassFileLocator.Simple(types)); + } } /** @@ -237,17 +279,17 @@ /** * {@inheritDoc} */ - public Map<String, Class<?>> injectRaw(Map<? extends String, byte[]> types) { + public Map<String, Class<?>> injectRaw(Set<String> names, ClassFileLocator classFileLocator) { Dispatcher dispatcher = DISPATCHER.initialize(); Map<String, Class<?>> result = new HashMap<String, Class<?>>(); - for (Map.Entry<? extends String, byte[]> entry : types.entrySet()) { - synchronized (dispatcher.getClassLoadingLock(classLoader, entry.getKey())) { - Class<?> type = dispatcher.findClass(classLoader, entry.getKey()); + for (String name : names) { + synchronized (dispatcher.getClassLoadingLock(classLoader, name)) { + Class<?> type = dispatcher.findClass(classLoader, name); if (type == null) { - int packageIndex = entry.getKey().lastIndexOf('.'); + int packageIndex = name.lastIndexOf('.'); if (packageIndex != -1) { - String packageName = entry.getKey().substring(0, packageIndex); - PackageDefinitionStrategy.Definition definition = packageDefinitionStrategy.define(classLoader, packageName, entry.getKey()); + String packageName = name.substring(0, packageIndex); + PackageDefinitionStrategy.Definition definition = packageDefinitionStrategy.define(classLoader, packageName, name); if (definition.isDefined()) { Package definedPackage = dispatcher.getDefinedPackage(classLoader, packageName); if (definedPackage == null) { @@ -282,11 +324,15 @@ } } } - type = dispatcher.defineClass(classLoader, entry.getKey(), entry.getValue(), protectionDomain); + try { + type = dispatcher.defineClass(classLoader, name, classFileLocator.locate(name).resolve(), protectionDomain); + } catch (IOException exception) { + throw new IllegalStateException("Could not resolve type description for " + name, exception); + } } else if (forbidExisting) { throw new IllegalStateException("Cannot inject already loaded type: " + type); } - result.put(entry.getKey(), type); + result.put(name, type); } } return result; @@ -1624,19 +1670,19 @@ /** * {@inheritDoc} */ - public Map<String, Class<?>> injectRaw(Map<? extends String, byte[]> types) { + public Map<String, Class<?>> injectRaw(Set<String> names, ClassFileLocator classFileLocator) { PackageDescription target = TypeDescription.ForLoadedType.of(lookupType()).getPackage(); if (target == null) { throw new IllegalArgumentException("Cannot inject array or primitive type"); } Map<String, Class<?>> result = new HashMap<String, Class<?>>(); - for (Map.Entry<? extends String, byte[]> entry : types.entrySet()) { - int index = entry.getKey().lastIndexOf('.'); - if (!target.getName().equals(index == -1 ? "" : entry.getKey().substring(0, index))) { - throw new IllegalArgumentException(entry.getKey() + " must be defined in the same package as " + lookup); + for (String name : names) { + int index = name.lastIndexOf('.'); + if (!target.getName().equals(index == -1 ? "" : name.substring(0, index))) { + throw new IllegalArgumentException(name + " must be defined in the same package as " + lookup); } try { - result.put(entry.getKey(), METHOD_HANDLES_LOOKUP.defineClass(lookup, entry.getValue())); + result.put(name, METHOD_HANDLES_LOOKUP.defineClass(lookup, classFileLocator.locate(name).resolve())); } catch (Exception exception) { throw new IllegalStateException(exception); } @@ -1811,27 +1857,31 @@ /** * {@inheritDoc} */ - public Map<String, Class<?>> injectRaw(Map<? extends String, byte[]> types) { + public Map<String, Class<?>> injectRaw(Set<String> names, ClassFileLocator classFileLocator) { Dispatcher dispatcher = this.dispatcher.initialize(); Map<String, Class<?>> result = new HashMap<String, Class<?>>(); synchronized (classLoader == null ? BOOTSTRAP_LOADER_LOCK : classLoader) { - for (Map.Entry<? extends String, byte[]> entry : types.entrySet()) { + for (String name : names) { try { - result.put(entry.getKey(), Class.forName(entry.getKey(), false, classLoader)); + result.put(name, Class.forName(name, false, classLoader)); } catch (ClassNotFoundException ignored) { try { - result.put(entry.getKey(), dispatcher.defineClass(classLoader, entry.getKey(), entry.getValue(), protectionDomain)); - } catch (RuntimeException exception) { // The bootstrap loader lock might be replicated throughout multiple class loaders. + result.put(name, dispatcher.defineClass(classLoader, name, classFileLocator.locate(name).resolve(), protectionDomain)); + } catch ( + RuntimeException exception) { // The bootstrap loader lock might be replicated throughout multiple class loaders. try { - result.put(entry.getKey(), Class.forName(entry.getKey(), false, classLoader)); + result.put(name, Class.forName(name, false, classLoader)); } catch (ClassNotFoundException ignored2) { throw exception; } - } catch (Error error) { // The bootstrap loader lock might be replicated throughout multiple class loaders. + } catch (IOException exception) { + throw new IllegalStateException("Failed to resolve binary representation of " + name, exception); + } catch ( + Error error) { // The bootstrap loader lock might be replicated throughout multiple class loaders. try { - result.put(entry.getKey(), Class.forName(entry.getKey(), false, classLoader)); + result.put(name, Class.forName(name, false, classLoader)); } catch (ClassNotFoundException ignored2) { throw error; } @@ -2461,7 +2511,7 @@ /** * {@inheritDoc} */ - public Map<String, Class<?>> injectRaw(Map<? extends String, byte[]> types) { + public Map<String, Class<?>> injectRaw(Set<String> names, ClassFileLocator classFileLocator) { File file = new File(folder, JAR + randomString.nextString() + "." + JAR); try { if (!file.createNewFile()) { @@ -2470,9 +2520,9 @@ try { JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(file)); try { - for (Map.Entry<? extends String, byte[]> entry : types.entrySet()) { - jarOutputStream.putNextEntry(new JarEntry(entry.getKey().replace('.', '/') + CLASS_FILE_EXTENSION)); - jarOutputStream.write(entry.getValue()); + for (String name : names) { + jarOutputStream.putNextEntry(new JarEntry(name.replace('.', '/') + CLASS_FILE_EXTENSION)); + jarOutputStream.write(classFileLocator.locate(name).resolve()); } } finally { jarOutputStream.close(); @@ -2484,7 +2534,7 @@ jarFile.close(); } Map<String, Class<?>> result = new HashMap<String, Class<?>>(); - for (String name : types.keySet()) { + for (String name : names) { result.put(name, Class.forName(name, false, target.getClassLoader())); } return result; @@ -2731,16 +2781,20 @@ /** * {@inheritDoc} */ - public Map<String, Class<?>> injectRaw(Map<? extends String, byte[]> types) { + public Map<String, Class<?>> injectRaw(Set<String> names, ClassFileLocator classFileLocator) { Map<String, Class<?>> result = new HashMap<String, Class<?>>(); synchronized (classLoader == null ? BOOTSTRAP_LOADER_LOCK : classLoader) { - for (Map.Entry<? extends String, byte[]> entry : types.entrySet()) { + for (String name : names) { try { - result.put(entry.getKey(), Class.forName(entry.getKey(), false, classLoader)); + result.put(name, Class.forName(name, false, classLoader)); } catch (ClassNotFoundException ignored) { - result.put(entry.getKey(), DISPATCHER.defineClass(classLoader, entry.getKey(), entry.getValue(), protectionDomain)); + try { + result.put(name, DISPATCHER.defineClass(classLoader, name, classFileLocator.locate(name).resolve(), protectionDomain)); + } catch (IOException exception) { + throw new IllegalStateException("Failed to resolve binary representation of " + name, exception); + } } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderDefaultApplicationTest.java new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderDefaultApplicationTest.java --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderDefaultApplicationTest.java 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderDefaultApplicationTest.java 2024-11-01 18:36:01.000000000 +0100 @@ -7,6 +7,7 @@ import net.bytebuddy.dynamic.DynamicType; import net.bytebuddy.dynamic.TargetType; import net.bytebuddy.dynamic.loading.ByteArrayClassLoader; +import net.bytebuddy.dynamic.loading.ClassInjector; import net.bytebuddy.dynamic.loading.ClassLoadingStrategy; import net.bytebuddy.implementation.FixedValue; import net.bytebuddy.implementation.MethodDelegation; @@ -838,6 +839,33 @@ } } + @Test + @IntegrationRule.Enforce + public void testAdviceTransformerWithInjection() throws Exception { + Instrumentation instrumentation = ByteBuddyAgent.install(); + assertThat(instrumentation, instanceOf(Instrumentation.class)); + ClassFileTransformer classFileTransformer = new AgentBuilder.Default() + .with(poolStrategy) + .with(new AgentBuilder.InjectionStrategy.UsingUnsafe.OfFactory(ClassInjector.UsingUnsafe.Factory.resolve(instrumentation))) + .ignore(none()) + .with(AgentBuilder.InitializationStrategy.NoOp.INSTANCE) + .type(ElementMatchers.is(Foo.class), ElementMatchers.is(classLoader)).transform(new AgentBuilder.Transformer.ForAdvice() + .with(poolStrategy) + .with(AgentBuilder.LocationStrategy.ForClassLoader.STRONG) + .include(BazAdvice.class.getClassLoader()) + .with(Assigner.DEFAULT) + .withExceptionHandler(new Advice.ExceptionHandler.Simple(Removal.SINGLE)) + .advice(named(FOO), BazAdvice.class.getName()) + .auxiliary(BazAdviceAuxiliary.class.getName())) + .installOnByteBuddyAgent(); + try { + Class<?> type = classLoader.loadClass(Foo.class.getName()); + assertThat(type.getDeclaredMethod(FOO).invoke(type.getDeclaredConstructor().newInstance()), is((Object) (FOO + BAR))); + } finally { + assertThat(ByteBuddyAgent.getInstrumentation().removeTransformer(classFileTransformer), is(true)); + } + } + private static class FooTransformer implements AgentBuilder.Transformer { public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, @@ -1016,4 +1044,19 @@ value += QUX; } } + + private static class BazAdvice { + + @Advice.OnMethodExit + private static void exit(@Advice.Return(readOnly = false) String value) { + value += BazAdviceAuxiliary.value(); + } + } + + public static class BazAdviceAuxiliary { + + public static String value() { + return BAR; + } + } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderInitializationStrategySelfInjectionDispatcherTest.java new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderInitializationStrategySelfInjectionDispatcherTest.java --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderInitializationStrategySelfInjectionDispatcherTest.java 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderInitializationStrategySelfInjectionDispatcherTest.java 2024-11-01 18:36:01.000000000 +0100 @@ -2,6 +2,7 @@ import net.bytebuddy.description.annotation.AnnotationList; import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.dynamic.ClassFileLocator; import net.bytebuddy.dynamic.DynamicType; import net.bytebuddy.dynamic.Nexus; import net.bytebuddy.dynamic.NexusAccessor; @@ -19,9 +20,7 @@ import org.mockito.stubbing.Answer; import java.lang.annotation.Annotation; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import static net.bytebuddy.test.utility.FieldByFieldComparison.matchesPrototype; import static org.hamcrest.CoreMatchers.instanceOf; @@ -42,7 +41,7 @@ private DynamicType.Builder<?> builder, appendedBuilder; @Mock - private DynamicType dynamicType; + private DynamicType dynamicType, dependentAuxiliary, independentAuxiliary; @Mock private AgentBuilder.InjectionStrategy injectionStrategy; @@ -59,11 +58,15 @@ private NexusAccessor nexusAccessor = new NexusAccessor(); @Before - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public void setUp() throws Exception { when(builder.initializer((any(ByteCodeAppender.class)))).thenReturn((DynamicType.Builder) appendedBuilder); when(injectionStrategy.resolve(Qux.class.getClassLoader(), Qux.class.getProtectionDomain())).thenReturn(classInjector); when(dynamicType.getTypeDescription()).thenReturn(instrumented); + when(dynamicType.getAuxiliaries()).thenReturn((List) Arrays.asList(dependentAuxiliary, independentAuxiliary)); + when(dynamicType.getAuxiliaryTypeDescriptions()).thenReturn(new HashSet<TypeDescription>(Arrays.asList(dependent, independent))); + when(dependentAuxiliary.getAllTypeDescriptions()).thenReturn(Collections.singleton(dependent)); + when(independentAuxiliary.getAllTypeDescriptions()).thenReturn(Collections.singleton(independent)); Map<TypeDescription, byte[]> auxiliaryTypes = new HashMap<TypeDescription, byte[]>(); auxiliaryTypes.put(dependent, FOO); auxiliaryTypes.put(independent, BAR); @@ -74,10 +77,10 @@ loadedTypeInitializers.put(independent, independentInitializer); when(dynamicType.getLoadedTypeInitializers()).thenReturn(loadedTypeInitializers); when(instrumented.getName()).thenReturn(Qux.class.getName()); - when(classInjector.inject(any(Map.class))).then(new Answer<Map<TypeDescription, Class<?>>>() { + when(classInjector.inject(any(Set.class), any(ClassFileLocator.class))).then(new Answer<Map<TypeDescription, Class<?>>>() { public Map<TypeDescription, Class<?>> answer(InvocationOnMock invocationOnMock) throws Throwable { Map<TypeDescription, Class<?>> loaded = new HashMap<TypeDescription, Class<?>>(); - for (TypeDescription typeDescription : ((Map<TypeDescription, byte[]>) invocationOnMock.getArguments()[0]).keySet()) { + for (TypeDescription typeDescription : ((Set<TypeDescription>) invocationOnMock.getArguments()[0])) { if (typeDescription.equals(dependent)) { loaded.put(dependent, Foo.class); } else if (typeDescription.equals(independent)) { @@ -131,12 +134,12 @@ public void testSplit() throws Exception { AgentBuilder.InitializationStrategy.Dispatcher dispatcher = new AgentBuilder.InitializationStrategy.SelfInjection.Split.Dispatcher(nexusAccessor, IDENTIFIER); dispatcher.register(dynamicType, Qux.class.getClassLoader(), Qux.class.getProtectionDomain(), injectionStrategy); - verify(classInjector).inject(Collections.singletonMap(independent, BAR)); + verify(classInjector).inject(Collections.singleton(independent), dynamicType); verifyNoMoreInteractions(classInjector); verify(independentInitializer).onLoad(Bar.class); verifyNoMoreInteractions(independentInitializer); Nexus.initialize(Qux.class, IDENTIFIER); - verify(classInjector).inject(Collections.singletonMap(dependent, FOO)); + verify(classInjector).inject(Collections.singleton(dependent), dynamicType); verifyNoMoreInteractions(classInjector); verify(dependentInitializer).onLoad(Foo.class); verifyNoMoreInteractions(dependentInitializer); @@ -149,10 +152,10 @@ public void testEager() throws Exception { AgentBuilder.InitializationStrategy.Dispatcher dispatcher = new AgentBuilder.InitializationStrategy.SelfInjection.Eager.Dispatcher(nexusAccessor, IDENTIFIER); dispatcher.register(dynamicType, Qux.class.getClassLoader(), Qux.class.getProtectionDomain(), injectionStrategy); - Map<TypeDescription, byte[]> injected = new HashMap<TypeDescription, byte[]>(); - injected.put(independent, BAR); - injected.put(dependent, FOO); - verify(classInjector).inject(injected); + Set<TypeDescription> injected = new HashSet<TypeDescription>(); + injected.add(independent); + injected.add(dependent); + verify(classInjector).inject(injected, dynamicType); verifyNoMoreInteractions(classInjector); verify(independentInitializer).onLoad(Bar.class); verifyNoMoreInteractions(independentInitializer); @@ -171,10 +174,10 @@ dispatcher.register(dynamicType, Qux.class.getClassLoader(), Qux.class.getProtectionDomain(), injectionStrategy); verifyNoMoreInteractions(classInjector, dependentInitializer, independentInitializer); Nexus.initialize(Qux.class, IDENTIFIER); - Map<TypeDescription, byte[]> injected = new HashMap<TypeDescription, byte[]>(); - injected.put(independent, BAR); - injected.put(dependent, FOO); - verify(classInjector).inject(injected); + Set<TypeDescription> injected = new HashSet<TypeDescription>(); + injected.add(independent); + injected.add(dependent); + verify(classInjector).inject(injected, dynamicType); verifyNoMoreInteractions(classInjector); verify(independentInitializer).onLoad(Bar.class); verifyNoMoreInteractions(independentInitializer); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderInitializationStrategyTest.java new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderInitializationStrategyTest.java --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderInitializationStrategyTest.java 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/test/java/net/bytebuddy/agent/builder/AgentBuilderInitializationStrategyTest.java 2024-11-01 18:36:01.000000000 +0100 @@ -14,9 +14,7 @@ import java.lang.annotation.Annotation; import java.security.ProtectionDomain; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -75,25 +73,26 @@ } @Test - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public void testMinimalRegistrationIndependentType() throws Exception { Annotation eagerAnnotation = mock(AuxiliaryType.SignatureRelevant.class); when(eagerAnnotation.annotationType()).thenReturn((Class) AuxiliaryType.SignatureRelevant.class); TypeDescription independent = mock(TypeDescription.class), dependent = mock(TypeDescription.class); when(independent.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(eagerAnnotation)); when(dependent.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty()); - Map<TypeDescription, byte[]> map = new HashMap<TypeDescription, byte[]>(); - map.put(independent, QUX); - map.put(dependent, BAZ); - when(dynamicType.getAuxiliaryTypes()).thenReturn(map); + when(dynamicType.getAuxiliaryTypeDescriptions()).thenReturn(new HashSet<TypeDescription>(Arrays.asList(independent, dependent))); + Map<TypeDescription, byte[]> auxiliaryTypes = new HashMap<TypeDescription, byte[]>(); + auxiliaryTypes.put(independent, QUX); + auxiliaryTypes.put(dependent, BAZ); + when(dynamicType.getAuxiliaryTypes()).thenReturn(auxiliaryTypes); ClassInjector classInjector = mock(ClassInjector.class); when(injectionStrategy.resolve(classLoader, protectionDomain)).thenReturn(classInjector); - when(classInjector.inject(Collections.singletonMap(independent, QUX))) + when(classInjector.inject(Collections.singleton(independent), dynamicType)) .thenReturn(Collections.<TypeDescription, Class<?>>singletonMap(independent, Foo.class)); LoadedTypeInitializer loadedTypeInitializer = mock(LoadedTypeInitializer.class); when(dynamicType.getLoadedTypeInitializers()).thenReturn(Collections.singletonMap(independent, loadedTypeInitializer)); AgentBuilder.InitializationStrategy.Minimal.INSTANCE.register(dynamicType, classLoader, protectionDomain, injectionStrategy); - verify(classInjector).inject(Collections.singletonMap(independent, QUX)); + verify(classInjector).inject(Collections.singleton(independent), dynamicType); verifyNoMoreInteractions(classInjector); verify(loadedTypeInitializer).onLoad(Foo.class); verifyNoMoreInteractions(loadedTypeInitializer); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/DynamicTypeDefaultTest.java new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/DynamicTypeDefaultTest.java --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/DynamicTypeDefaultTest.java 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/DynamicTypeDefaultTest.java 2024-11-01 18:36:01.000000000 +0100 @@ -144,7 +144,7 @@ @Test public void testTypeInitializersAliveAuxiliary() throws Exception { - when(auxiliaryLoadedTypeInitializer.isAlive()).thenReturn(true); + when(auxiliaryType.hasAliveLoadedTypeInitializers()).thenReturn(true); assertThat(dynamicType.hasAliveLoadedTypeInitializers(), is(true)); } @@ -318,13 +318,41 @@ } @Test - public void testIterationOrder() throws Exception { + public void testIterationOrderAll() throws Exception { Iterator<TypeDescription> types = dynamicType.getAllTypes().keySet().iterator(); assertThat(types.hasNext(), is(true)); assertThat(types.next(), is(typeDescription)); assertThat(types.hasNext(), is(true)); assertThat(types.next(), is(auxiliaryTypeDescription)); assertThat(types.hasNext(), is(false)); + } + + @Test + public void testIterationOrderAuxiliary() throws Exception { + Iterator<TypeDescription> types = dynamicType.getAuxiliaryTypes().keySet().iterator(); + assertThat(types.hasNext(), is(true)); + assertThat(types.next(), is(auxiliaryTypeDescription)); + assertThat(types.hasNext(), is(false)); + } + + @Test + public void testIterationOrderAllDescriptions() throws Exception { + when(auxiliaryType.getAllTypeDescriptions()).thenReturn(Collections.singleton(auxiliaryTypeDescription)); + Iterator<TypeDescription> types = dynamicType.getAllTypeDescriptions().iterator(); + assertThat(types.hasNext(), is(true)); + assertThat(types.next(), is(typeDescription)); + assertThat(types.hasNext(), is(true)); + assertThat(types.next(), is(auxiliaryTypeDescription)); + assertThat(types.hasNext(), is(false)); + } + + @Test + public void testIterationOrderAuxiliaryDescriptions() throws Exception { + when(auxiliaryType.getAllTypeDescriptions()).thenReturn(Collections.singleton(auxiliaryTypeDescription)); + Iterator<TypeDescription> types = dynamicType.getAuxiliaryTypeDescriptions().iterator(); + assertThat(types.hasNext(), is(true)); + assertThat(types.next(), is(auxiliaryTypeDescription)); + assertThat(types.hasNext(), is(false)); } @Test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-gradle-plugin/pom.xml new/byte-buddy-byte-buddy-1.15.8/byte-buddy-gradle-plugin/pom.xml --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-gradle-plugin/pom.xml 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-gradle-plugin/pom.xml 2024-11-01 18:36:01.000000000 +0100 @@ -5,7 +5,7 @@ <parent> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-parent</artifactId> - <version>1.15.7</version> + <version>1.15.8</version> </parent> <artifactId>byte-buddy-gradle-plugin</artifactId> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/byte-buddy-maven-plugin/pom.xml new/byte-buddy-byte-buddy-1.15.8/byte-buddy-maven-plugin/pom.xml --- old/byte-buddy-byte-buddy-1.15.7/byte-buddy-maven-plugin/pom.xml 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/byte-buddy-maven-plugin/pom.xml 2024-11-01 18:36:01.000000000 +0100 @@ -5,7 +5,7 @@ <parent> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-parent</artifactId> - <version>1.15.7</version> + <version>1.15.8</version> </parent> <artifactId>byte-buddy-maven-plugin</artifactId> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/pom.xml new/byte-buddy-byte-buddy-1.15.8/pom.xml --- old/byte-buddy-byte-buddy-1.15.7/pom.xml 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/pom.xml 2024-11-01 18:36:01.000000000 +0100 @@ -4,7 +4,7 @@ <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy-parent</artifactId> - <version>1.15.7</version> + <version>1.15.8</version> <packaging>pom</packaging> <inceptionYear>2014</inceptionYear> @@ -61,7 +61,7 @@ <bytebuddy.integration>false</bytebuddy.integration> <bytebuddy.experimental>false</bytebuddy.experimental> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.build.outputTimestamp>1729668319</project.build.outputTimestamp> + <project.build.outputTimestamp>1730482461</project.build.outputTimestamp> <sourcecode.main.version>1.5</sourcecode.main.version> <sourcecode.test.version>1.6</sourcecode.test.version> <bytecode.main.version>1.5</bytecode.main.version> @@ -155,7 +155,7 @@ <connection>scm:git:${repository.url}</connection> <developerConnection>scm:git:${repository.url}</developerConnection> <url>${repository.url}</url> - <tag>byte-buddy-1.15.7</tag> + <tag>byte-buddy-1.15.8</tag> </scm> <dependencies> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/byte-buddy-byte-buddy-1.15.7/release-notes.md new/byte-buddy-byte-buddy-1.15.8/release-notes.md --- old/byte-buddy-byte-buddy-1.15.7/release-notes.md 2024-10-23 09:27:02.000000000 +0200 +++ new/byte-buddy-byte-buddy-1.15.8/release-notes.md 2024-11-01 18:36:01.000000000 +0100 @@ -1,6 +1,10 @@ Byte Buddy release notes ------------------------ +### 23. October 2024: version 1.15.7 + +- Additional release after time out during previous Gradle plugin release. + ### 21. October 2024: version 1.15.6 - Add ConstructorResolver to Super annotation for MethodDelegation to allow for dynamic constructor resolution.