I hate Eclipse

I swear to God the Eclipse developers are deliberately sabotaging Subclipse to get people to switch to Subversive. It works, too. After twenty-four hours of trying to get a working Eclipse 3.5.1 + Subclipse + EPIC installation on my laptop, I’ve finally given up.

I suspect this also has something to do with Mylyn, but I can’t prove it.

The 21st century: ur doin it wrong

I know Oracle must be drilling way below the bottom of the barrel these days trying to find a way to monetize Larry Ellison’s vanity purchase get some return out of the Sun buyout, but hiding the JAX-RS specification under a bushel and charging US$50k to implement it commercially mostly strikes me as a great way to make sure no significant amount of RESTful web service development ever gets done in Java.

(Comments closed due to spam.)

Interesting Mockito / reflection feature & workaround

So, you have two interfaces:

interface SettingsProvider {
  Settings getSettings(String id);
}

and

interface InternalSettingsProvider extends SettingsProvider {
  @Override
  InternalSettings getSettings(String id);
}

You mock one of the second, and you stub the method:

InternalSettingsProvider mockProvider =
    mock(InternalSettingsProvider.class);
when(mockProvider.getSettings(“anId”)).thenReturn(someSettings);

You run some code that only knows about SettingsProvider, not InternalSettingsProvider. This code calls getSettings(“anId”). You’re expecting it to then make use of someSettings so…

…you get a NullPointerException.

It turns out that, with reflection, it actually makes a difference whether you call getSettings() on SettingsProvider or on InternalSettingsProvider. Each interface results in a separate Method object.

When the SettingsProvider#getSettings() call comes in, the matching code looks at the Methods it has registered for stubbing, and it finds one for InternalSettingsProvider#getSettings(), but none for SettingsProvider#getSettings(). So it returns the default value, which for an object is null.

Luckily, the first workaround you might think of does actually do the trick.

when(((SettingsProvider) mockProvider)
    .getSettings(“anId”)).thenReturn(someSettings);

I ran into this with Mockito, but I imagine it’ll come up in some other reflection-related contexts too.

No, I do not want fries with that

You would think that a development platform — a free, open-source development platform — that prides itself on its flexibility and modularity would give you a way to install only the pieces you want, or at least uninstall the pieces you don’t want. And up till recently, you would have been right. But now you’re not.

(Seriously, if I can’t get this crap uninstalled, I might actually break down and pay for that IDEA 8 upgrade I’d been planning to skip. If it would take bread out of the mouths of the children of the people who thought this distribution system was a good idea, I’d do it in a heartbeat.)