You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Björn Kautler (JIRA)" <ji...@apache.org> on 2018/05/24 15:17:00 UTC

[jira] [Comment Edited] (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:comment-tabpanel&focusedCommentId=16489193#comment-16489193 ] 

Björn Kautler edited comment on ARIES-1801 at 5/24/18 3:16 PM:
---------------------------------------------------------------

Maybe the

{code:java}
// Try to irritate TCCLSetterVisitor by forcing an (irrelevant) LDC.
@SuppressWarnings("unused")
Class<?> causeLDC = String.class;
{code}

is the difference?
In my case there is no last class constant, so the value is {{null}} and you get the {{IAE}}.
In that case the last class constant is there, it just has nothing to do with the loaded service.


was (Author: vampire):
Maybe the

{code:java}
        // Try to irritate TCCLSetterVisitor by forcing an (irrelevant) LDC.
        @SuppressWarnings("unused")
	Class<?> causeLDC = String.class;
{code}

is the difference?
In my case there is no last class constant, so the value is {{null}} and you get the {{IAE}}.
In that case the last class constant is there, it just has nothing to do with the loaded service.

> 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: 1.0
>            Reporter: Björn Kautler
>            Priority: Major
>
> 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)