|
|
|
[
Permlink
| « Hide
]
Paul King - 01/Dec/06 06:31 AM
transient and static are definitely bugs but private should be OK shouldn't it?
Looks like only 'final' and 'transient' are detected at compile time. 'abstract','static' and 'synchronized' are allowed but those modifiers are meaningless IMO. On top level interfaces there is no point in declaring an access modifier other than public but it does on inner interfaces (not yet supported) so using protected/private on them should at least give a warning for the time being?
bash-3.2$ groovyc AI.groovy bash-3.2$ groovyc FI.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, FI.groovy: 1: The interface 'FI' must not be final. It is by definition abstract . @ line 1, column 7. final interface FI {} ^ 1 error bash-3.2$ groovyc SI.groovy bash-3.2$ groovyc TI.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, TI.groovy: 1: The interface 'TI' has an incorrect modifier transient. @ line 1, column 11. transient interface TI {} ^ 1 error bash-3.2$ groovyc YI.groovy bash-3.2$ Added 'native' to the list of detected and ruled out modifiers. I attempted to add 'synchronized' but one of the tests fails. Soem of our intermediate generated classes may accidentally have this bit set. I think we can add this back in once we work out where this is occurring. For reference, the script below fails with the error message shown when trying to compile if I add the synchronized check in, so it is commented out at the moment:
Script: interface A { def foo = 1 } class B implements A { def foo() {foo} } assert new B().foo() == 1 Error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, C:\testScript.groovy: -1: The class 'A$1' has an incorrect modifier synchronized. @ line -1, column -1. 1 error OK, synchronized is added to. That just about wraps up the essential items for this issue. There are other unused modifiers at the moment but they are happily ignored and if we end up supporting inner classes, then they will all come into play.
I did notice however that you can have invalid modifiers in interface methods. So, I'll add that in and then I think we can close this issue. Here is what you can currently have: interface Foo { def strictfp /*native*/ volatile synchronized doit( String param, int o ) } If you use native Java complains. Groovy happily ignores the other values even though they never make sense here. I think there are now error messages for all the obvious candidates. There are some which we don't deal with at the moment but hope to over time, e.g. a private Interface may make sense inside a Script ... one day. And we may support inner/nested classes/interfaces one day too.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||