FYI in case you missed it.

In short: The OSGi R 4.3 libraries have been recompiled with Java 5 target and 
republished as version 4.3.1 to maven. So to use OSGi R 4.3 libraries in a Java 
5 (and up) environment you should use the 4.3.1 version dependency.

Nothing to be done when using older (4.2.0 and before) dependencies because 
they are compiled for Java 1.4.

Regards
Felix

Anfang der weitergeleiteten E-Mail:

Von: BJ Hargrave <b...@bjhargrave.com<mailto:b...@bjhargrave.com>>
Betreff: [osgi-blog] [OSGi Alliance Blog] 4.3 Companion Code for Java 7
Datum: 26. Oktober 2012 21:06:11 MESZ
An: "osgi-b...@mail.osgi.org<mailto:osgi-b...@mail.osgi.org>" 
<osgi-b...@mail.osgi.org<mailto:osgi-b...@mail.osgi.org>>
Antwort an: Private list for OSGi blog discussion 
<osgi-b...@mail.osgi.org<mailto:osgi-b...@mail.osgi.org>>

Starting in version 4.3, OSGi started to use generics in some of the API 
including the Core specification. Generics were 
introduced<https://en.wikipedia.org/wiki/Generics_in_Java> to the Java language 
in Java 5. However, OSGi needed to continue to support embedded use cases which 
use the CDC/Foundation 1.1 runtime which is still based upon the Java 1.4 
language level and JVM. To address this issue, OSGi compiled the APIs with 
-target 
jsr14<http://www.ibm.com/developerworks/java/library/j-jtp02277/index.html>; an 
undocumented javac flag introduced before Java 5 was final. So we had the best 
of both worlds: we can use generics and still compile to run on Java 1.4 based 
runtimes.

This worked for Java 5 and Java 6. But when Java 7 shipped, two things changed: 
javac no longer understood the jsr14 option to -target and javac refused to 
recognize the attributes containing the generics information in class files 
already compiled with -target jsr14. The change to no longer support creating 
-target jsr14 class files was ok; we could continue to compile with Java 6 
javac. But the change to the javac to cease to recognize the class file 
attributes with the generics information in existing class files was a bigger 
problem. It meant that the 4.3 API jars published by OSGi were not useable by 
people who need to compile with Java 7 javac. By not useable, I mean javac 
treated the classes as if they did not contain any generics information: they 
were raw. A bug<http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7078419> was 
filed against Java to see if this was some mistake or oversight. The reply was 
that the change was intentional.

At the time this was first 
noticed<https://mail.osgi.org/pipermail/osgi-dev/2011-August/003223.html>, Java 
7 was new and not too widely used. OSGi also included the source code in the 
jars so you could recompile the code yourself if you needed. Later, when it 
came time to ship Core R5, we changed to compile the API classes with -target 
1.5 and so they work fine on Java 7. So problem solved; the new release's jars 
don't use -target jsr14! Except some of the current OSGi implementations (I'm 
looking at you Felix<https://felix.apache.org/> and 
Karaf<https://karaf.apache.org/>) are still based upon Core 4.3 and thus people 
using those implementations still need to use the Core 4.3 API. And if they 
also want to use Java 7, they need to recompile the OSGi API source. So after 
some prodding by a few folks, OSGi rebuilt the Core and Compendium API jars as 
Core 
4.3.1<http://www.osgi.org/Download/File?url=/download/r4v43/osgi.core-4.3.1.jar>
 and Compendium 
4.3.1<http://www.osgi.org/Download/File?url=/download/r4v43/osgi.cmpn-4.3.1.jar>.
 The new jars have the same packages at the same package versions having the 
same API signatures. They are just not compiled with -target jsr14 so they work 
fine with Java 7.

So if you need to use the 4.3 API with Java 7, pick up these new 4.3.1 jars. 
They should also be available on 
maven<http://mvnrepository.com/artifact/org.osgi> shortly.

--
Posted By BJ Hargrave to OSGi Alliance 
Blog<http://blog.osgi.org/2012/10/43-companion-code-for-java-7.html> at 
10/26/2012 07:06:00 PM _______________________________________________
osgi-blog mailing list
osgi-b...@mail.osgi.org<mailto:osgi-b...@mail.osgi.org>
https://mail.osgi.org/mailman/listinfo/osgi-blog

Reply via email to