« Purim and Persistence | Main | Perma-what? »

I want my destructors!

There are many things I like about Java, but every so often I hit my head against a fundamental limitation that forces me to write lots of extra code that I wouldn't have to in C++.

Connection c = ds.getConnection();
try
{
	Statement s = c.createStatement();
	try
	{
		// ...
	}
	finally
	{
		s.close();
	}
}
finally
{
	c.close();
}

Fer crying out loud. I have to have a billion nested finally clauses to make up for the fact that Java doesn't have local objects and therefore no destructors. Urgh.

Post a comment