Buggy code:
public class ClientWeavingHookTest { @ Before public void setUp ( ) { } @ After public void tearDown ( ) { } @ Test public void testClientWeavingHookBasicServiveLoaderUsage ( ) throws Exception { } @ Test public void testClientWeavingHookAltServiceLoaderLoadUnprocessed ( ) throws Exception { } @ Test public void testClientWeavingHookMultipleProviders ( ) throws Exception { } @ Test public void testClientSpecifyingProvider ( ) throws Exception { } @ Test public void testClientSpecifyingProviderVersion ( ) throws Exception { } @ Test public void testClientSpecificProviderLoadArgument ( ) throws Exception { Dictionary < String , String > headers = new Hashtable < String , String > ( ) ; headers . put ( SPI_CONSUMER_HEADER , ( "java.util.ServiceLoader#load(java.lang.Class[org.apache.aries.mytest.MySPI])," + "java.util.ServiceLoader#load(java.lang.Class[org.apache.aries.mytest.AltSPI]);bundle=impl4" ) ) ; Bundle providerBundle1 = mockProviderBundle ( "impl1" , 1 , "META-INF//services//org.apache.aries.mytest.MySPI" ) ; Bundle providerBundle2 = mockProviderBundle ( "impl2" , 2 , "META-INF//services//org.apache.aries.mytest.MySPI" , "META-INF//services//org.apache.aries.mytest.AltSPI" ) ; Bundle providerBundle4 = mockProviderBundle ( "impl4" , 4 , "META-INF//services//org.apache.aries.mytest.MySPI" , "META-INF//services//org.apache.aries.mytest.AltSPI" ) ; activator . registerProviderBundle ( "org.apache.aries.mytest.MySPI" , providerBundle1 ) ; activator . registerProviderBundle ( "org.apache.aries.mytest.MySPI" , providerBundle2 ) ; activator . registerProviderBundle ( "org.apache.aries.mytest.AltSPI" , providerBundle2 ) ; activator . registerProviderBundle ( "org.apache.aries.mytest.MySPI" , providerBundle4 ) ; activator . registerProviderBundle ( "org.apache.aries.mytest.AltSPI" , providerBundle4 ) ; Bundle consumerBundle = mockConsumerBundle ( headers , providerBundle1 , providerBundle2 , providerBundle4 ) ; Bundle spiFlyBundle = mockSpiFlyBundle ( consumerBundle , providerBundle1 , providerBundle2 , providerBundle4 ) ; WeavingHook wh = new ClientWeavingHook ( spiFlyBundle . getBundleContext ( ) ) ; URL clsUrl = getClass ( ) . getResource ( "TestClient.class" ) ; WovenClass wc = new ClientWeavingHookTest . MyWovenClass ( clsUrl , "org.apache.aries.spifly.TestClient" , consumerBundle ) ; wh . weave ( wc ) ; Class < ? > cls = wc . getDefinedClass ( ) ; Method method = cls . getMethod ( "test" , new Class [ ] { String . class } ) ; Object result = method . invoke ( cls . newInstance ( ) , "hello" ) ; <START_BUG> Assert . assertEquals ( "Only<seq2seq4repair_space>the<seq2seq4repair_space>services<seq2seq4repair_space>from<seq2seq4repair_space>bundle<seq2seq4repair_space>impl2<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>selected" , "ollehHELLO5" , result ) ; <END_BUG> URL cls2Url = getClass ( ) . getResource ( "AltTestClient.class" ) ; WovenClass wc2 = new ClientWeavingHookTest . MyWovenClass ( cls2Url , "org.apache.aries.spifly.AltTestClient" , consumerBundle ) ; wh . weave ( wc2 ) ; Class < ? > cls2 = wc2 . getDefinedClass ( ) ; Method method2 = cls2 . getMethod ( "test" , new Class [ ] { long . class } ) ; Object result2 = method2 . invoke ( cls2 . newInstance ( ) , 4096 ) ; Assert . assertEquals ( "Only<seq2seq4repair_space>the<seq2seq4repair_space>services<seq2seq4repair_space>from<seq2seq4repair_space>bundle<seq2seq4repair_space>impl4<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>selected" , 8192 , result2 ) ; } @ Test public void testClientSpecifyingTwoDifferentMethodsLimitedToDifferentProviders ( ) { } @ Test public void testJAXPClientWantsJREImplementation1 ( ) throws Exception { } @ Test public void testJAXPClientWantsAltImplementation1 ( ) throws Exception { } @ Test public void testJAXPClientWantsJREImplementation2 ( ) throws Exception { } @ Test public void testJAXPClientWantsAltImplementation2 ( ) throws Exception { } private Bundle mockSpiFlyBundle ( Bundle ... bundles ) throws Exception { } private Bundle mockSpiFlyBundle ( String bsn , Version version , Bundle ... bundles ) throws Exception { } private Bundle mockProviderBundle ( String subdir , long id , String ... resources ) { } private Bundle mockProviderBundle ( String subdir , long id , Version version , String ... resources ) { } private Bundle mockConsumerBundle ( Dictionary < String , String > headers , Bundle ... otherBundles ) { } private Bundle mockSystemBundle ( ) { } public static class TestImplClassLoader extends URLClassLoader { private final List < String > resources ; private final String prefix ; public TestImplClassLoader ( String subdir , String ... resources ) { } @ Override public URL findResource ( String name ) { } @ Override public Enumeration < URL > findResources ( String name ) throws IOException { } } private static class MyWovenClass implements WovenClass { byte [ ] bytes ; final String className ; final Bundle bundleContainingOriginalClass ; List < String > dynamicImports = new ArrayList < String > ( ) ; boolean weavingComplete = false ; private MyWovenClass ( URL clazz , String name , Bundle bundle ) throws Exception { } @ Override public byte [ ] getBytes ( ) { } @ Override public void setBytes ( byte [ ] newBytes ) { } @ Override public List < String > getDynamicImports ( ) { } @ Override public boolean isWeavingComplete ( ) { } @ Override public String getClassName ( ) { } @ Override public ProtectionDomain getProtectionDomain ( ) { } @ Override public Class < ? > getDefinedClass ( ) { } @ Override public BundleWiring getBundleWiring ( ) { } } private static class MyWovenClassClassLoader extends ClassLoader implements BundleReference { private final String className ; private final Bundle bundle ; private final byte [ ] bytes ; public MyWovenClassClassLoader ( String className , byte [ ] bytes , ClassLoader parent , Bundle bundle ) { } @ Override protected synchronized Class < ? > loadClass ( String name , boolean resolve ) throws ClassNotFoundException { } @ Override public Class < ? > loadClass ( String name ) throws ClassNotFoundException { } @ Override public Bundle getBundle ( ) { } } }

Fix:
Assert . assertEquals ( "All<seq2seq4repair_space>providers<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>selected<seq2seq4repair_space>for<seq2seq4repair_space>this<seq2seq4repair_space>one" , "ollehHELLO5" , result ) ;