Issue Details (XML | Word | Printable)

Key: GROOVY-69
Type: Sub-task Sub-task
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jochen Theodorou
Reporter: james strachan
Votes: 10
Watchers: 6
Operations

If you were logged in you would be able to see more operations.
groovy
GROOVY-3080

support inner classes (or at least nested classes)

Created: 10/Dec/03 12:08 AM   Updated: 25/Nov/09 04:21 AM   Resolved: 25/Nov/09 04:21 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.7-rc-1

Time Tracking:
Not Specified

Issue Links:
dependent
 


 Description  « Hide

This causes OutOfMemoryException...

class A {
class B {}
}

we should fix it



Chris Poirier added a comment - 07/Mar/04 01:11 AM

The parser now does support inner classes, but ASTs (and classes) are not being generated from the CSTs....


Jochen Theodorou added a comment - 04/Mar/05 09:32 AM

support for inner classes


Daniel.Sun added a comment - 24/Dec/07 08:09 AM

If possible, please support the anonymous inner class too.

Thanks.


David Smiley added a comment - 24/Mar/08 12:03 AM

I'm really surprised inner classes (anonymous or not) are not supported in Groovy. I like to think of Groovy as doing what Java does and more but that definitely not true. Inner classes are there for convenience. If anything, Groovy is about convenience to quickly get the job done, often quite succinctly... so it's surprising to see that Groovy still doesn't do this yet. Several times I've wanted to create a quick anonymous class because I've got to override some method or another but instead I have to go create a top level class and throw it at the bottom of the current class. Pretty awkward. It's ironic that Java introduced this convenience back in version 1.1 and somehow Groovy doesn't have this yet.


Guillaume Laforge added a comment - 24/Mar/08 04:09 AM

It's already on the Groovy roadmap.


Jochen Theodorou added a comment - 24/Mar/08 08:26 AM

for David....

In Groovy it is a bit more difficult to realize inner classes in its full extend, because of the MOP. in most cases you can use closures instead, so it is not that awful. but that does not solve all cases. We are aware of that and inner classes are on the agenda... we just need to define it completely first and do not loose sight of other things we want to have too.


Olivier Mengué added a comment - 19/Jun/08 12:52 PM

See GROOVY-1328 which is also about multiple classes defined in one source file (but not inner). Since declaring multiple classes in one script gives an unusable script, one can not even create manually inner classes.
We're back to Java 1.1 days...


Jochen Theodorou added a comment - 26/Jun/08 08:41 AM

Olivier... first, the feature is targeted for 1.8, so just wait a little and it is done. Second, just putting multiple classes in one file doesn't make the file unusable. We are here to discuss the facts if possible.


Jochen Theodorou added a comment - 25/Nov/09 04:21 AM

fixed