You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue #120 requested OSGi headers. Unfortunately, the Export-Package headers lack uses directives, which can be very important to avoid ClassCastExceptions and other wiring-related issue. Here’s an issue I recently came across (see Eclipse Bug 481923 for the real scenario):
User installs bundle com.google.gson in version X.
User installs bundle org.example.one, which has an Import-Package on com.google.gson;version="[X,X+1)" and an Export-Package of org.example.one;uses="com.google.gson".
Bundle org.example.one is wired to bundle com.google.gson, version X.
User installs bundle com.google.gson in version Y > X. The wiring of bundle org.example.one remains unchanged due to the version constraint on org.example.one’s Import-Package.
User installs bundle org.example.two, which has an Import-Package on com.google.gson;version="[X,Y+1)", com.google.gson.annotations;version="[X,Y+1)", and on org.example.one.
Bundle org.example.two is wired to package com.google.gson in version X, as the uses constraints of org.example.one force org.example.two to use the same version, and to com.google.gson.annotations in version Y, as it is the newest available.
When org.example.two uses com.google.gson, version X, to deserialize JSON, its @SerializedName annotations won’t be honored, as they are loaded with the classloader of com.google.gson, version Y.
You should probably consider using the maven-bundle-plugin, as it can compute uses directives automatically; maintaining them manually is IMHO far to error-prone.
The text was updated successfully, but these errors were encountered:
means is “If you import com.google.gsonandcom.google.gson.annotations, you must do so from the same bundle (so that they will be loaded with the same classloader).”
Issue #120 requested OSGi headers. Unfortunately, the
Export-Package
headers lack uses directives, which can be very important to avoidClassCastExceptions
and other wiring-related issue. Here’s an issue I recently came across (see Eclipse Bug 481923 for the real scenario):com.google.gson
in version X.org.example.one
, which has anImport-Package
oncom.google.gson;version="[X,X+1)"
and anExport-Package
oforg.example.one;uses="com.google.gson"
.org.example.one
is wired to bundlecom.google.gson
, version X.com.google.gson
in version Y > X. The wiring of bundleorg.example.one
remains unchanged due to the version constraint onorg.example.one
’sImport-Package
.org.example.two
, which has anImport-Package
oncom.google.gson;version="[X,Y+1)"
,com.google.gson.annotations;version="[X,Y+1)"
, and onorg.example.one
.org.example.two
is wired to packagecom.google.gson
in version X, as the uses constraints oforg.example.one
forceorg.example.two
to use the same version, and tocom.google.gson.annotations
in version Y, as it is the newest available.org.example.two
usescom.google.gson
, version X, to deserialize JSON, its@SerializedName
annotations won’t be honored, as they are loaded with the classloader ofcom.google.gson
, version Y.You should probably consider using the maven-bundle-plugin, as it can compute uses directives automatically; maintaining them manually is IMHO far to error-prone.
The text was updated successfully, but these errors were encountered: