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(); } }
Categories: java
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(); } }
Categories: java
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 [...]
Categories: java
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. [...]
Categories: java,open source,REST,RSS,web2.0
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 [...]
Categories: java
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 [...]
Categories: clustering,java,mysql
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 [...]
Categories: java
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 [...]
Categories: java
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 [...]
Categories: java
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 [...]
Categories: java,open source
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 [...]
Categories: java