Wednesday, July 30

peaberry 1.0 alpha

You may have noticed I recently uploaded an alpha build of peaberry 1.0

http://peaberry.googlecode.com/files/peaberry-1.0-alpha.zip

today I've also been working on updating the design and user guide pages:

http://code.google.com/p/peaberry/wiki/UserGuide
http://code.google.com/p/peaberry/wiki/DetailedDesign

including a small Eclipse/PDE example I put together in a matter of minutes.
(and which hopefully also works ok on other people's installations of Eclipse!)

http://peaberry.googlecode.com/files/PeaberryExample.zip

At this point I'm feeling good about the API and (unless I hear otherwise) will
concentrate on more "behind-the-scenes" work, and perhaps add a few more
utilities to help developers.

So... if you find any bugs please let me know via the issues tab :)

Tuesday, July 29

IdentityHashMap is broken in IBM JDK 5!

So there I was, happily running some tests with the latest copy of Guice when blam - I got a NullPointerException from inside the injector. Hmmm, I thought, perhaps the latest trunk code is unstable. So I pulled down a stable snapshot... and got the same exception.

Looked at location of the NPE and got even more confused:

   CreationTimeMemberInjector.java:87

where it iterates over the cached entry set of an identity hash-map. Added some debug code, and yes - the entry set is valid to begin with, but after stashing it in a list, the list elements are all null. Weird!

Why hadn't I seen this before, I've run the same test many times - then it struck me, today I happened to have JAVA_HOME set to the IBM JDK, while previously I've used the default Sun JDK.

Time to crack open the src.jar from the IBM JDK - lo and behold in IdentityHashMap.java:1142

public T[] toArray(T[] a) {
return (T[])toArray(); // !!!!
}

that is plain wrong - the specification for toArray(T[] a) clearly states that the provided array must be used if it's large enough:

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.

this behaviour is relied on in other classes from java.util, where they create a large enough array and use c.toArray(elements); to initialize the array contents. Hence the null array when creating a list based on the entry set.

I was going to report this on the "IBM Java Runtimes and SDKs" forum as the problem still exists in the latest service release, but it appears to be offline today! For those interested, here is a simple testcase to recreate the bug:

import java.util.*;

public class IdentityHashMapTest {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
Map map1 = new HashMap();
Map map2 = new IdentityHashMap();
map1.put("Hello", "World");
map2.put("Hello", "World");
System.out.println("MAP 1 : " + map1.entrySet());
System.out.println("MAP 2 : " + map2.entrySet());
System.out.println("LIST 1 : " + new ArrayList(map1.entrySet()));
System.out.println("LIST 2 : " + new ArrayList(map2.entrySet()));
}
}

BTW, that comment // !!!! is actually in the original source code, which suggests someone out there knows this is wrong but couldn't be bothered to fix it...

Friday, June 27

Guice 2.0 and OSGi

Some cool news: the Guice trunk (which will eventually become 2.0) now includes my patches to support OSGi-style classloading, and also adds OSGi metadata to its jars.

This means that you will be able to take the Guice 2.0 jar and drop it onto any OSGi framework, without having to worry about classloading issues wrt. the internal proxy code. The new code also allows generated proxy classes to be unloaded when they're no longer needed.

So when Guice 2.0 hits the internet, the peaberry project will become a neat little extension library that you can drop alongside the Guice jar to inject OSGi services.

Good stuff! ( no more patches :)

Friday, May 16

Bio-reboot

You may (or may not) have noticed that I haven't been as active as usual on various projects. I've been having stomach issues for the last few months, and after numerous tests the doc decided to "reboot" my stomach by clearing out all the bacteria with antibiotics. He's now started me on probiotics to replace the good bacteria/enzymes (like the ones that help digest milk) that got zapped.

It's going to take a while before things are fully back to normal, and I need to regain about 5kg, but I'm feeling more positive (which is a good sign). The doc did tell me to keep my stress levels down, but that may be difficult when there's so many cool ideas that need implementing ;)

Monday, April 7

peaberry 0.3 available for testing / review

I've uploaded a new peaberry bundle along with early design docs:

http://peaberry.googlecode.com/files/peaberry-0.3.jar
(this also contains the source code under OSGI-OPT)

http://code.google.com/p/peaberry/wiki/DetailedDesign

the new design is much less invasive: you can decide to explicitly
add bindings to services without using the @Service annotation if
you want, and you can even use peaberry to inject services from
other registry based systems (by implementing ServiceRegistry).

There's also a small demo to show it working in practice

http://peaberry.googlecode.com/files/peaberry-0.3-logdemo.zip

although this demo doesn't actually do anything useful ;)

I'll upload the user guide tomorrow and then start working on a
production quality implementation of the OSGiServiceRegistry
(the current one is basic proof-of-concept and non-optimal).

Other TODOs:

mandatory services (ie. bundle won't start without them)

service registration (need to find an intuitive approach)

Anyway, please take a look and let me know what you think.

Friday, March 7

A jolt of Guice

Fantastic news from this year's Jolt Awards: Guice won the award for "Libraries/Frameworks" beating several other worthy finalists, including the Spring Framework! Hopefully this news will provoke a fresh injection of interest in Guice :)

Certainly I'm feeling more of a buzz about the next release, and can't wait to find time to continue my work on extending Guice to support dynamic injection of services from registries, such as the one in OSGi (http://code.google.com/p/peaberry).

So congratulations to Bob, Kevin and everyone else involved with Guice!

Pax Construct 1.0 released

I've released version 1.0 of Pax Construct, just in time for EclipseCon! (phew) And now you can find the scripts and plugin on the central Maven repository, so it's even easier to use:

http://repo1.maven.org/maven2/org/ops4j/pax/construct/scripts/1.0/scripts-1.0.zip

Improvement

[PAXCONSTRUCT-66]
- Add all Maven compilation dependencies to the Eclipse classpath

[PAXCONSTRUCT-67]
- Add pax:provision option to select Pax-Runner profiles (-Ddeploy=...)

[PAXCONSTRUCT-68]
- Support use of Pax-Runner argument files (-Dargs=)

[PAXCONSTRUCT-69]
- Support pax:run as alias for pax:provision

[PAXCONSTRUCT-70]
- Provide a pax-provision script that works outside of a Maven project

[PAXCONSTRUCT-71]
- Support provisioning of bundles not marked as provided dependencies

New Feature

[PAXCONSTRUCT-72]
- Add new command "pax-create-module" to simplify creation of subdirectories

Task

[PAXCONSTRUCT-59]
- Look into using velocity instead of groovy to generate the various scripts

Plus several changes to the underlying internals to improve performance and usability.

Tuesday, January 22

maven-bundle-plugin 1.2.0 released

It's finally here, a new stable release of the bundleplugin:


<plugin>
<groupid>org.apache.felix</groupid>
<artifactid>maven-bundle-plugin</artifactid>
<version>1.2.0</version>
</plugin>

hopefully the next development cycle won't take so long :)