Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am not super familiar with all the details of Java inner classes, but why can't you get most of the way there by doing something like:

  DB.open(new Runnable() {
    public void run() {
      // ... do stuff here ...
    }
  });
You can even design your resource layers such that they can only be used this way (or are easiest to use this way).

Basically, I'm just stealing the JavaScript-y way of doing this that uses closures:

  DB.open(function() {
    ...
  });


Answer: the inner class can only access constant locals :(. So you have to put any mutable state in members.

Blech. This might work for some cases, but would be a huge pain in the ass in others.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: