I can think of one use case for local classes - creating a structure for an object that will be returned to a mechanism that uses reflection to access it. I don't know though if anyone uses it for this purpose...
For example, lets say you have an AJAX web framework. The server side has a routing mechanism that routes a requests to Java methods, and those methods should return objects that the mechanism will convert to some serialization format(XML/JSON/whatever) and send back to the client.
Now, you can't use anonymous classes for this because you won't be able to populate their properties(unless you use an ugly hack and create a single method that sets all the properties and return
Object...), but if you use a local class it can have a constructor and setter properties you can call more than once.
Like you said, you could also use separate class definitions for this, and I know the widely preached dogma says that class declarations should be placed in the most visible and accessible place possible, but I'm gonna risk being burned at the stake and claim that not every single piece of code needs to be widely reusable!
There are disadvantages to code reuse. One of them is that you can't change reusable code easily, because you don't know where else it's being used. A large portion of the design patterns that run around are dedicated to solve this disadvantage, but sometimes it's just not worth it, and it's better to simply limit the code to a be only usable in a single point so you could easily change it when you need to.
For example, let's say method
foo returns to our framework a
Result object that has 3 fields -
c. Another method,
bar, also needs to return those 3 fields, and since you don't want to copy 28 lines of code ((1 line of for declaration + 3 lines for setter + 3 lines for getter) * 3 fields + 2 lines for the class + 5 lines for constructor = 28 lines of code. Java is that freaking verbose...) you use
Now, what if you want to return from
foo another field -
d? You can't just add it to
Result as well and you can't just have it returning a
bar doesn't return
d, and there might be other methods that use
Result for other things. So, you apply the open-close principle and subclass
Result2 that adds the
Repeat 10 times, and you get a weird hierarchy of classes used solely to create data objects that will be handled by reflection...
Wouldn't it be better if each method had it's own
Result local class that you could alter freely because it's local and there is no risk other methods will use it?