Category Archives: java

More cool JDK7 features. 0

Interesting review of some JDK 7 features: I think the main one I like is the try-with-resource hack: private String example() throws IOException { try(BufferedReader reader = new BufferedReader(…) { return reader.readLine(); } }

Unsafe considered Awesome! 0

I’ve been planning on playing with sun.misc.Unsafe for a while now but couldn’t find the time. Long story short… Unsafe is awesome. Check out the cool things you can do with it (that you normally couldn’t do with Java): [sourcecode language="java"] /** * Allocates a new block of native memory, of the given size in [...]

In Defense of REST 0

I’m not sure why REST needs defending but apparently it does… Dare steps in and provides a solid background and Tim follows up… What is really interesting about REST from my perspective (and not everyone will agree) is that since it’s REST you can actually solve real problems without getting permission from a standards board. [...]

Viewing Java Thread Lock Contention as a Graph Clustering Problem 2

A few years ago I wrote a little app named ‘exception log introspect’ (ELI) that sent a signal to a running java process to obtain the stack trace. I then analyzed the stack trace to find threads with the exact same fingerprint and group duplicates. Then I would score threads by number of duplicates and [...]

Using ZooKeeper to configure External Monitoring Systems 0

I’m going to be migrating to using ZooKeeper within Spinn3r for a myriad of reasons but this one is especially powerful. One could use ZooKeeper to configure external monitoring systems like Munin and Ganglia. ZooKeeper enables this with its support for ephemeral files. If you have an external process like a webserver, database, robot, etc [...]

java.util.TimeZone is Broken by Design 3

Look at this stupid code: /** * Gets the TimeZone for the given ID. * * @param ID the ID for a TimeZone, either an abbreviation * such as “PST”, a full name such as “America/Los_Angeles”, * or a custom * ID such as “GMT-8:00″. Note that the support of * abbreviations is * for [...]

First Implementation Pass of Java FlatMap Proposal 0

On the plane to Seattle I wrote the first pass of my Java flat file map proposal. I’m pretty happy with the code. The 1.0 sources just contain a read-only version of the Map. It turns out I need to write a version of java.util.Set because the entrySet() and valueSet() mechanism might actually be called [...]

On Hashtables and Java Storage Efficiency 4

I did some more work tonight on hash tables and Java storage efficiency. Turns out that an int actually does store entries in 4 bytes. I created an int[] array with 2M ints. This does in fact use 4 bytes per entry. Which is basically what you’d expect. Creating an array of 2M Integer objects [...]

Java and In-Memory Data Structures – A Flat File Map Proposal 31

In the past I’ve often used in-memory data structures (vs on disk) in situations where allocating say 5-10MB of data in the local VM is much better than continually hitting a database. This has only worked because I’m not using very large data structures. My language classification codes uses about 8MB of memory stored in [...]

Java and Javascript Configuration with Functions 0

For the last few years I’ve been playing with a simple configuration system which I call ‘runtime properties’. Runtime properties are similar to Java system properties in concept but differ in a few ways. They’re designed to replace variables during VM initialization with values in a given property file. When you reference a named Java [...]