Hello,
I try to use the Bundle.adapt method with Java 1.7.0_02 in the following
way:

   Framework framework;
   FrameworkStartLevel startLevelObject =
framework.adapt(FrameworkStartLevel.class);

This is ok for the Eclipse compiler (1.7) but when I try this with gradle
or with plain javac on command line I get the following compiler error:
    error: incompatible types
      FrameworkStartLevel startLevelObject =
framework.adapt(FrameworkStartLevel.class);
        required: FrameworkStartLevel
        found:    Object

This compiler error I get with 'org.apache.felix.framework-4.0.2' as well
as with 'org.osgi.core-4.3.0' fetched from Maven repository.

With JD-JavaDecompiler I found out that the class file contains the
generics code in the same way as the osgi spec says and the secondary
sources artifact contains.

But 'javac -Xlint:all' command presents a warning for the Bundle.class file:

   warning: [classfile] Signature attribute introduced in version 49.0
class files is ignored in version 48.0 class files

Decompiling the Bundle.class with 'javap' produces the following output:

    >javap org\osgi\framework\Bundle -classpath . -verbose
    Compiled from "Bundle.java"
    public interface org.osgi.framework.Bundle extends java.lang.Comparable
      Signature: length = 0x2
       00 50
      SourceFile: "Bundle.java"
      minor version: 0
      major version: 48
      ...

How can I use this with Java 7 or is this not possible? Why is the target
platform 48 (1.4) but the source is at least 1.5. Does this make any sense?
Thanks a lot in advance.
David

Reply via email to