Hi,
I'm trying to fix our pax-exam based tests to run successfully under
Java 8. A couple of modules worked fine, but so far I found 2 which
are problematic ( event and scripting/core ).
The first attempt was to simply bump the versions for pax-exam ( 3.0.3
-> 3.5.0 ) , pax-link ( 1.5.2 -> 2.1.0 ) and felix.framework. ( 3.2.2
-> 4.4.1 ).
Unfortunately this causes the tests to fail with
Tests run: 6, Failures: 0, Errors: 6, Skipped: 0, Time elapsed: 0.637
sec <<< FAILURE! - in
org.apache.sling.scripting.core.impl.BindingsValuesProvidersByContextIT
testMapsAndBvps(org.apache.sling.scripting.core.impl.BindingsValuesProvidersByContextIT)
Time elapsed: 0.354 sec <<< ERROR!
java.lang.NoSuchMethodError:
org.osgi.framework.BundleEvent.<init>(ILorg/osgi/framework/Bundle;Lorg/osgi/framework/Bundle;)V
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4249)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2881)
at
org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:165)
at
org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:138)
at
org.ops4j.pax.exam.nat.internal.NativeTestContainer.installAndStartBundles(NativeTestContainer.java:301
The only way to make the tests pass is to bump the dependency of
org.osgi.core to 5.0.0. However, since this is a provided dependency,
it has an effect on the imports calculated by bnd. After making this
change, the following import ranges are changed:
- org.osgi.framework : [1.5,2) -> [1.7,2)
- org.osgi.util.tracker : [1.4,2) -> [1.5,2)
This is IMO incorrect, since we don't need these more restrictive
imports at runtime. I see a couple of ways out of this:
1. Update the depedencies and leave the imports as they are. It's the
simplest, but it can cause problems for consumers.
2. Update the dependencies and manually tweak the import ranges so
that they retain the old values. This causes no problems to consumers,
but it fragile and cumbersome to use
3. Split the ITs into separate modules . This might be the correct
thing to do, but sounds overkill just for the Java 8 migration. And
I'm not sure I like the idea of per-module IT profileration, since
this update has shown that it's cumbersome to maintain them.
4. Change the pax container from native to forked. This fixes the
classpath problems, but slows down the tests a bit.
Right now I'm inclined to use option 4, but if anyone else has an
opinion please let me know.
Thanks,
Robert