Main

June 11, 2005

PMD: mostly good

Tor Norbye has done a writeup on PMD, a tool that looks for common coding errors in your Java source, for example switch statements without default labels or use of the broken double checked locking pattern. It looked interesting, so I installed the plugin into NetBeans and ran it against the source of my Mobile Bollocks MIDlet. As Tor points out, the default set of selected rules is a bit naff in areas, so I followed his recommendation and enabled them all, then started removing the ones I didn't agree with - about 30 in total. PMD is probably the best tool of its type that I have used, however that's not to say it doesn't have a few quirks:

  • It barfs on perfectly OK code. For example it reports the following error:
    com.bleaklow.bollocks.ui.About [1]: Error while processing com.bleaklow.bollocks.ui.About;
    net.sourceforge.pmd.ast.ASTAllocationExpression
    
    This is triggered by code of the form:
        public class Foo {
            public Foo() {
                new Runnable() { public void run() { Foo.this.back(); } };
            }
            public void back() {
            }
        }
    
    The trigger seems to be Foo.this.back(), I've logged the problem - see this SourceForge bug.

  • Some of the rules which claim to catch a particular error don't just catch the error that they claim to, they report errors against perfectly OK code. For example the SimplifyBooleanExpressions rule claims it is for problems like this:
    public class Bar {
        // can be simplified to
        // bar = isFoo();
        private boolean bar = (isFoo() == true);
        public isFoo() { return false;}
    }
    
    which I agree is a bad practice, the problem is that it also flags things like this as being errors:
        if (isFoo() == false) {
            doSomething();
        }
    
    which I actually think is clearer than the alternative:
        if (! isFoo()) {
            doSomething();
        }
    
    That ! is easy to miss, so I think the explicit comparison against false is actually clearer.

  • Some of the rules are just plain stupid - for example insisting that a method contains only a single return statement or prohibiting single-character variable names for things like array indexes.

  • Some of the rules are well-intentioned but the implementation is wrong. For example the AvoidInstansiatingObjectsInLoops rule is trying to warn you about the potential performance problems that can occur if you continually re-instansiate objects inside a loop, for example:
        for (i = 0; i < someArray.length; i++) {
            String s = "some string";
            doStuff(someArray[i], s);
        }
    
    the problem is that it complains about common idioms such as this, which are perfectly fine:
        for (int i = 0; i < someArray.length; i++) {
            if (matchesCondition(someArray[i]) {
                matchedThing = new SomeObject(someArray[i]);
                break;
        }
    
    I guess what it should really be looking for is the instantiation of an object inside a loop that isn't predicated by a conditional statement.

The other problems I have with PMD are more related to missing functionality, and the degree of integration of PMD into NetBeans:

  • Although the developer documentation implies the rules can have priorities, they don't appear to be used, at least not in NetBeans. This means that it's difficult to spot rules that have caught real coding errors in amongst a sea of stylistic warnings.

  • There is no way to suppress rules once you have manually checked that the code is actually OK. Ideally you would be able to disable rules on both a file and method basis, but you don't seem to be able to do this.

  • You also need to be able to have different rulesets for different projects. For example I got gazillions of errors related to the use of Vector instead of one of the Collection classes - this would be a fair warning under normal circumstances, but J2ME doesn't actually provide anything other than Vector, so it would be useful to disable those rules for J2ME projects.

However, even with these provisos it is a great tool and it did find a couple of genuine bugs in my code which my code reviewer cough Gary cough missed ;-)

May 06, 2005

Our new company website is up

As most people who read this site regularly will already know, I was made redundant by Sun back in Feburary, and my last official day was 16th April - the end of eight years working for Sun - my longest stay in my career at one place, and if I'd had my way I'd have been staying longer, but unfortunately that was not to be.

Along with my long-time friend and colleague Gary, I've decided to have a go at setting up a company, and it's been an interesting ride - figuring out what we wanted to do, finding an accountant, getting the company registered, setting up the website, getting in touch with potential clients and so on, which is why I have been so quiet on this blog lately. I have been surprised at the amount of time and effort it has taken. The hardest part of all was chosing a name - I'm sure that will strike a chord with anyone else who has been in the same situation. We went through dozens of potential names, all of which sufferered from one of three problems:

  • The company name was already taken - you can check this at Companies House
  • The domain name was already taken - any company that sells domains will have a service to let you check this.
  • The name had unfortunate connotations. For example we settled on "Predictix" until someone of the female persuasion pointed out to us that it sounded like a pregnancy test, sigh.

In the end we got desperate and I decided to start trawling the Dark Peak OS map for likely names, and the one we liked the best was Dowstone - not Dowstone Clough but Dowstone Rocks was the source of the name. On the day before our last official day as Sun employees Gary and I went on a walk and visited Dowstone rocks where I took this picture:

which after an amount of PaintShop Pro hackery became the basis of the Dowstone logo, in case you were wondering!

My top tip if you ever find yourself inclined to set up on your own - first find yourself a good accountant, preferably by personal recommendation, who specialises in working with small businesses. You'll get a wealth of information that will save you untold aggravation with the Inland Revenue, the VAT man etc. And oh, don't forget to make use of the services of your local Business Link office.

The other thing you should do is register the domain name corresponding to your chosen company name first before registering with Companies House - various unscrupulous individuals and companies watch the company registrations, hoover up the corresponding domain names and then stiff you to get them back - when we went to see Steve Mercer, our accountant, to sign the paperwork to set the company he had already received junk mail addressed to the MD of Dowstone Limited, offering to sell us the domain names we hadn't registered - this distasteful practice is called domain squatting, for those of you who haven't heard of it before.

So anyway, if any of you out there in blogland are looking for top-notch Solaris, Perl, Java, Database, Open Source, etc, etc, etc experts, wander over to dowstone.com, we are open for business ;-)

August 11, 2004

My other weblog is a Mondeo

I've started hiving all the work-related drivel off onto a seperate weblog, over on http://blogs.sun.com/alanbur, as I've joined the other Sun employees who have been encouraged to enhance (damage?) the company's reputation out there in webbyland with our boundless wit and insight.

For all you non-UK citizens, the Ford Mondeo is probably the most common (I wouldn't necessarily say popular) company car here in the UK, a common employee perk.

Sheesh, is it really a month since I last posted anything here? I better get busy!

July 01, 2004

Goodbye PlanetSun

This blog is currently picked up by the PlanetSun aggregator, but I've requested that it be removed - the three people who have read my blog via PlanetSun should therefore bookmark me now! :-)

Nearly all the stuff on PlanetSun is related to Sun Microsystems, however this blog definitely isn't, it's mainly concerned with the Peak District where I live and the minutiae of my life, so I feel it looks out of place on PlanetSun. I know some people who have split their posts into two blogs, one personal and one job-related, but for me that kind of defeats the purpose of a blog (plus I'm too lazy to bother). In my case there's also not much stuff that is work-related that I can post - for the first half of the Solaris 10 release I was on the release staff, and couldn't talk about work stuff for confidentiality reasons, and I'm currently working on the project to release Solaris as Open Source, and I can't talk about that either - so I'm a little thin on work-related content.

To all you Sun bloggers out there, keep up the good work, and remember the guiding principles!

June 12, 2004

Perl 5.8.4 lands in Solaris 10

*********  This mail is automatically generated  *******

Your putback for the following fix(es) is complete:

    5040539 Perl 5.8.4 should be integrated into S10
    4915255 perl tries to force -xc99=%none on embed clients
    5059815 Perl should have perlgcc out-of-the-box

These fixes will be in release:

        s10_62

The gatekeeper will mark these bugids "fixed" and "integrated" in bugtraq
as soon as the gate has been delivered to the WOS.  However, you can mark
them "fixed" (but not "integrated") now if you wish.

        Your Friendly Gatekeepers

-------------------------------------------------------------

As part of the day job I look after the version of perl which is included in Solaris, and as perl 5.8.4 came out fairly recently I thought I'd better do an update - the text above is from an email sent by the automated system that monitors integrations into the Solaris source repository or 'gate' . Several hundred people have checked in changes to Solaris 10 so far ('putback' in SolarisSpeak), so the Linux model where everthing funnels throught Linus just wouldn't work for us. Also, contrary to common misperceptions we don't 'port' Solaris to x86 after doing the sparc version, both are developed in parallel and there is one common source tree, so we have to develop, debug and test on both platforms before integration. In fact my workstation at home is a sparc box, and the one at work is an opteron, so like all Solaris developers I have a foot firmly in both camps.

Putting pack changes into Solaris can be quite a daunting experience, as everyone who works on Solaris receives a copy of the putback notification, and if your changes don't stick, a copy of the followup notification as they are backed out of the gate. The source repository or 'gate' machines (one sparc, one x86) run last night's build of the OS, so if you screw up and break the gate machines it means that all those people also know about it, and nobody can integrate until it is fixed - which concentrates the mind wonderfully when you come to integrate your stuff ;-) Every 2 weeks we glue together all the bits we ship - Solaris, X11, Gnome, CDE, Java and so on into the WOS ('Wad Of Stuff') and put it all through a series of test suites, then we do the whole thing over again two weeks later. It's one of these fortnightly builds that is periodically released as the Software Express for Solaris builds, or 'SX' for short, and we run them internally on lots of systems - for example Solaris developers run them on their desktops, and the main 2000+ user NFS server that holds the engineers home directories runs the numbered builds as well.

As far as the perl 5.8.4 integration goes, I'd like to thank Nick Clark and Rafael Garcia-Suarez for their help (they are the people currently coordinating the perl 5.8.x release series). We spent a morning on IRC discussing which additional patches to perl would be advisable over and above stock 5.8.4 - Rafael is the Mandrake perl maintainer to boot, so the Solaris and Mandrake patch lists are remarkably similar ;-) I found a couple of minor perl warts on the way through and they have made it back into the perl perforce repository for 5.8.5.

In addition, I've integrated a version of PerlGcc into Solaris 10. This allows you to use gcc to build modules from CPAN, the perl module archive. As perl is built as part of Solaris, it uses the same compilers as the OS, the Forte ones. Because perl stores the details of the compiler it was built with for use when building modules, you normally need to build any add-on modules with the same compiler as you used to build perl in the first place. PerlGcc provides a drop-in replacement for the appropriate config files, configured to used gcc instead of the Forte compilers. (You can grab a prebuilt copy of gcc from here). For those of you who still on Solaris 8 and 9, you can get a version of PerlGcc from here on CPAN. Unfortunately there is one slight wrinkle, if you've updated ExtUtils::MakeMaker it probably won't work. I had to make some changes to MakeMaker to get PerlGcc to work, and these are specific to the version of MakeMaker that was shipped in Solaris. I have come up with a generic way of doing this, and although the necessary changes have been submitted and will be in the next version of MakeMaker to be released, they aren't available yet. I'm hoping to release an update to the PerlGcc on CPAN over the next couple of weeks or so to work around this - check back here for announcements.

June 08, 2004

All aboard!!!

Well, blogs.sun.com has finally been officially launched, with great exhortations being made inside Sun for employees to jump on board and set up a blog. Last I heard there were about 100 new blogs created in the last day on the site. The process by which all this came about can be read on Tim Bray's blog (Tim is a Sun director) and the official policy on what we can and can't say is here - like any big organisation, we need a policy, even when tearing down walls and unleashing open communication with the outside world :-)

Some of us have already been blogging for a while and have blogs elsewhere than blogs.sun.com, but there's a good aggregator that links them together over at planetsun.org.

Now we are all holding our breath to see how long it is before we get slashdotted :-)

May 03, 2004

Blogging gets the Sun Seal of Approval

Sun has just published its new internal policy for blogging, encouraging a lot more openness, and as a fitting first step Tim Bray, who was one of the forces behind getting it defined, has published the new blogging policy in his blog . He's also descibed the process. behind it. Tim's new to Sun, and I quite like his last paragraph:

And by the way, I’m new here, but based on what I see so far, I’m impressed by this kind of fast-moving no-bullshit way of doing things. I’ve worked for startups - I’ve run startups - that aren’t as purposeful and nimble.

I think Tim's been fortunate and has seen the Schwartz Effect at work in this particular instance. Sun is changing dramatically and this is just one instance. However I'm sure there are plenty of the Old Guard left, it's going to be interesting to see how they react :-)

May 01, 2004

Open Source Solaris

Excerpt from http://www.infoworld.com/article/04/04/30/HNsolarisgpl_1.html:

Sun Microsystems Inc. may be selling servers running Linux, but that doesn't mean it is cutting back on the evolution of Solaris. Among its plans, the company is considering offering a free, open source version of its flagship operating system, said Jonathan Schwartz, the company's recently appointed president and chief operating officer.

Also see the associated slashdottery at http://slashdot.org/articles/04/05/01/1235209.shtml

Boy, am I interested to see how this plays out...

April 06, 2004

It seems The Register reads Planet Sun too...

It seems the staff of The Register read PlanetSun.org as well - they've quoted Geoff Arnold's blog entry on the momentous Sun/Microsoft rapprochement in this article. Odd, seeing as though Andrew Orlowski, the author of The Register article has previously expressed his disdain for all things blogish.


Update: Seems the above isn't true: Geoff tells me he often corresponds with Andrew Orlowski (see comments below). Shame :-)

According to the article, a Sun employee has mailed The Register saying that "this whole thing has my gut in knots" and "I used to follow Scott blindly". Sheesh, get a grip man, it's just a business decision. Although I really like Sun and consider it's the best company that I've worked for (and I've worked for a few), it is when all is said and done, just a business - not a goddam religion.

The other thing that's tickled me about the whole Sun/Microsoft deal is the 'You just can't win' aspect. For a long time Sun has had lawsuits pending against Microsoft, which was widely considered to be A Good Thing and About Time Someone Got Some Money from Them. Now Sun has trousered the money, it's seen as some kind of betrayal, some kind of humungous corporate sell-out. Well excuse me, but what exactly was the point of the legal action in the first place?

The same thing applies to the other part of the deal, the agreement to work more closely with Microsoft. Again, for a long time Scott McNealy has been criticised as being too focused on being anti-Microsoft, too intransigent in his dealings with them. He's obviously listened, and taken it to heart - which must have been personally difficult as he will have known the likely reaction - and gone and built some bridges. Now as a result he's weak, he doesn't know what he stands for, he's a Microsoft lickspittle, he can't possibly continue at Sun because it represents too much of a culture shock for him to cope with and so on.

Lastly I've been very amused by the way the way the Linux Klan are so self-absorbed (I think "up themselves" is the exact phrase I'm looking for) that they can't believe that there is anything in the IT world isn't centered entirely on them. As I've said before, they are convinced that "There is a global conspiracy which is striving to destroy Linux", and they seem only to be able to see the announcement as some sort of attack on Linux. One very prominent member of the Open Source world phoned up one of my colleagues after the announcement last friday and asked him "What does Microsoft's d**k taste like", which I think nicely demonstrates the mindset of the radical wing of the Linux movement.

I'm still desperately trying to convince myself that the vast majority of the Linux community don't subscribe to this extremist "Them or Us" manifesto, and that as with many things in life, moderate people are usually exactly that - moderate - and so they don't get a hearing. Unfortunately the Linux community seems to becoming dominated by these bigots - I'm not sure how many of them actually contribute anything except copious quantities of invective.

April 02, 2004

Sun weblog aggregator

I was looking through my web server stats for today (with http://awstats.sourceforge.net/, highly recommended) and I noticed that someone or something on a BT ADSL line had been accessing my site quite heavily. Being a nosey sod I went exploring to find out who it was - it turns out it is another Sun engineer down in Watford (Hi Dave!), and he's put together a web RSS aggregator for all the Sun folks he's been able to find who have external blogs. It's kinda neat - see http://planetsun.org/

February 04, 2004

Flag day

I've just completed the integration of perl 5.8.3 into Solaris 10. This probably doesn't mean very much to most people who read this site, but it sure means a lot to me :-)