Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-5086

Java 8 default methods cause IncompatibleClassChangeError in blueprint

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 4.0.7
    • Fix Version/s: 4.2.3
    • Component/s: None
    • Labels:
      None

      Description

      I have an interface with a default method and an implementation of that is exposed as an OSGi service via Aries Blueprint, and when the default method is called, it's causing this error:

      IncompatibleClassChangeError: Found interface org.opendaylight.infrautils.caches.CacheProvider, but class was expected. at Proxy*.newCache()

      The code looks something like this:

      public interface CacheProvider {
      
          <K,V> Cache<K,V> newCache(CacheConfig<K,V> cacheConfig, CachePolicy initialPolicy);
      
          default <K,V> Cache<K,V> newCache(CacheConfig<K,V> cacheConfig) {
              return newCache(cacheConfig, new CachePolicyBuilder().build());
          }
      

      And here's the full stack trace:

      opendaylight-user@root>diag
      caches-sample (57)
      ------------------
      Status: Failure
      Blueprint
      9/4/17 5:35 AM
      Exception: 
      org.osgi.service.blueprint.container.ComponentDefinitionException: Error when instantiating bean sampleServiceWithCachingImpl of class org.opendaylight.infrautils.caches.sample.SampleServiceWithCachingImpl
      org.osgi.service.blueprint.container.ComponentDefinitionException: org.osgi.service.blueprint.container.ComponentDefinitionException: Error when instantiating bean sampleServiceWithCachingImpl of class org.opendaylight.infrautils.caches.sample.SampleServiceWithCachingImpl
      	at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:310)
      	at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:252)
      	at org.apache.aries.blueprint.container.ServiceRecipe.internalCreate(ServiceRecipe.java:149)
      	at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
      	at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:255)
      	at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:186)
      	at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:724)
      	at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:411)
      	at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)
      	at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:300)
      	at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:269)
      	at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:265)
      	at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:255)
      	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
      	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
      	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
      	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
      	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
      	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher$2.call(EquinoxEventPublisher.java:189)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHookPrivileged(ServiceRegistry.java:1280)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHooksPrivileged(ServiceRegistry.java:1263)
      	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.notifyEventHooksPrivileged(EquinoxEventPublisher.java:186)
      	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:146)
      	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)
      	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)
      	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)
      	at org.eclipse.osgi.container.Module.publishEvent(Module.java:466)
      	at org.eclipse.osgi.container.Module.start(Module.java:457)
      	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:392)
      	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:411)
      	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1286)
      	at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:846)
      	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1176)
      	at org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:1074)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: org.osgi.service.blueprint.container.ComponentDefinitionException: Error when instantiating bean sampleServiceWithCachingImpl of class org.opendaylight.infrautils.caches.sample.SampleServiceWithCachingImpl
      	at org.apache.aries.blueprint.container.BeanRecipe.wrapAsCompDefEx(BeanRecipe.java:361)
      	at org.apache.aries.blueprint.container.BeanRecipe.getInstanceFromType(BeanRecipe.java:351)
      	at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:282)
      	at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:830)
      	at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:811)
      	at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
      	at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)
      	at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)
      	at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:285)
      	... 39 more
      Caused by: java.lang.IncompatibleClassChangeError: Found interface org.opendaylight.infrautils.caches.CacheProvider, but class was expected
      	at Proxye4b5f3d8_2a36_4067_b1b9_758c1f9fee27.newCache(Unknown Source)
      	at org.opendaylight.infrautils.caches.sample.SampleServiceWithCachingImpl.<init>(SampleServiceWithCachingImpl.java:35)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at org.apache.aries.blueprint.utils.ReflectionUtils.newInstance(ReflectionUtils.java:331)
      	at org.apache.aries.blueprint.container.BeanRecipe.newInstance(BeanRecipe.java:984)
      	at org.apache.aries.blueprint.container.BeanRecipe.getInstanceFromType(BeanRecipe.java:349)
      	... 48 more

        Attachments

        1. karaf.log
          1.01 MB
          Robert Varga

          Issue Links

            Activity

              People

              • Assignee:
                jbonofre Jean-Baptiste Onofré
                Reporter:
                vorburger Michael Vorburger
              • Votes:
                2 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: