git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jira] [Resolved] (ARIES-1801) SPI Fly does not work with a dynamic class object


     [ https://issues.apache.org/jira/browse/ARIES-1801?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Bosschaert resolved ARIES-1801.
-------------------------------------
    Resolution: Fixed

> SPI Fly does not work with a dynamic class object
> -------------------------------------------------
>
>                 Key: ARIES-1801
>                 URL: https://issues.apache.org/jira/browse/ARIES-1801
>             Project: Aries
>          Issue Type: Bug
>    Affects Versions: spifly-1.0.10
>            Reporter: Björn Kautler
>            Assignee: David Bosschaert
>            Priority: Major
>             Fix For: spifly-1.0.12
>
>
> SLF4J changes in version 1.8 how implementations are looked up to {{java.util.ServiceLoader}}.
> In our codebase we dynamically search for an SLF4J implementation and use a default logger if none is found.
> To adapt to the new mechanism but remain compatible with SLF4J 1.7 I added to our codebase
> {code:java}
> try {
>     // post-1.8 mechanism
>     Class<?> slf4jServiceProviderClass = Class.forName("org.slf4j.spi.SLF4JServiceProvider");
>     if (ServiceLoader.load(slf4jServiceProviderClass).iterator().hasNext()) {
>         noLogger.set(false);
>         return true;
>     }
> } catch (ClassNotFoundException e) {
>     // ignore
> }
> {code}
> If I now use the {{org.apache.aries.spifly.dynamic.bundle}} 1.0.10, I get an exception as SPI Fly seemingly only supports class constants. While traversing the ASM tree it remembers the last class constant seen and uses that to transform the {{load}} call.
> Here the exception I get:
> {code:java}
> java.lang.ClassFormatError: Weaving hook failed.
> 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.transformClass(BundleWiringImpl.java:2479)
> 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2152)
> 	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1607)
> 	at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
> 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> 	at org.javacord.core.util.logging.ExceptionLoggerDelegateImpl.<clinit>(ExceptionLoggerDelegateImpl.java:20)
> 	at org.javacord.core.util.DelegateFactoryDelegateImpl.createExceptionLoggerDelegate(DelegateFactoryDelegateImpl.java:180)
> 	at org.javacord.api.util.internal.DelegateFactory.<clinit>(DelegateFactory.java:74)
> 	at org.javacord.api.DiscordApiBuilder.<init>(DiscordApiBuilder.java:20)
> 	at net.kautler.test.osgi.OsgiTest.start(OsgiTest.java:17)
> 	at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
> 	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2240)
> 	at org.apache.felix.framework.Felix.startBundle(Felix.java:2146)
> 	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1373)
> 	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
> 	at java.lang.Thread.run(Thread.java:748)
> Caused by: java.lang.IllegalArgumentException: value null
> 	at org.objectweb.asm.ClassWriter.newConstItem(ClassWriter.java:1057)
> 	at org.objectweb.asm.MethodWriter.visitLdcInsn(MethodWriter.java:1126)
> 	at org.apache.aries.spifly.weaver.TCCLSetterVisitor$TCCLSetterMethodVisitor.visitMethodInsn(TCCLSetterVisitor.java:194)
> 	at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1416)
> 	at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1017)
> 	at org.objectweb.asm.ClassReader.accept(ClassReader.java:693)
> 	at org.objectweb.asm.ClassReader.accept(ClassReader.java:506)
> 	at org.apache.aries.spifly.dynamic.ClientWeavingHook.weave(ClientWeavingHook.java:61)
> 	at org.apache.felix.framework.util.SecureAction.invokeWeavingHook(SecureAction.java:1203)
> 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.transformClass(BundleWiringImpl.java:2465)
> 	... 16 more
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)