Profile cover photo
Profile photo
John Hawksley
77 followers -
* Mostly Harmless
* Mostly Harmless

77 followers
About
John's interests
View all
John's posts

An afternoon spent inside the OSGi wiring service, chasing a ClassCastException (from 'A' to 'A', naturally).

- When you uninstall a bundle, the uninstalled package exports (wire endpoints) are still available for wiring.
- A bundle which exports and imports its own packages will be wired to itself.

Imagine A exports foo (A1.foo) and imports it (A1.foo[A1]) and B imports it (B1.foo[A1])

Both A and B are uninstalled and reinstalled (stop, resolve, start).

A2 exports foo (A2.foo) and imports it (A2.foo[A2]) and B imports it, but gets the old one (B2.foo[A1]).

Now you pass 'foo.Class' from B2 to A2 - and you get ClassCastException because the classloaders are different.

To clear the wiring cache, one needs to call PackageAdmin#refresh() between the uninstall and install.

This will cause B2 to get B2.foo[A2] and stop the CCE.

Well-earned coffee time, I think!

[Framework: Felix. Equinox may behave differently.]

Post has attachment
Blogged. No idea why the tool doesn't do this automatically.

Post has attachment
Photo

Post has attachment
Day Off 
Photo

The fluorescent green alert bar which tells me things I don't care about (academic setting, partnership with the bloody-awful Evernote) is terrible.

Post has attachment
Sea lions basking in the evening sun.
Photo

Post has attachment
Breezy. 
Photo

Post has attachment
The Rock.
Photo

Post has attachment
Coffee by the bay: done. 
Photo

Post has shared content
Fanstastic use of an animated gif.
Great animation demonstration of the "alternating tripod" gait that ants and other insects use. From http://www.cals.ncsu.edu/course/ent425/library/tutorials/external_anatomy/locomotion.html
Animated Photo
Wait while more posts are being loaded