[jira] [Comment Edited] (GROOVY-8228) JSR308 grammar changes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Comment Edited] (GROOVY-8228) JSR308 grammar changes

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/GROOVY-8228?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16052928#comment-16052928 ]

Daniel Sun edited comment on GROOVY-8228 at 6/17/17 6:58 PM:
-------------------------------------------------------------

Refined the test: https://github.com/danielsun1106/groovy-parser/blob/jsr308/src/test/resources/bugs/GROOVY-8228.groovy

Note: the test is executable, not just parsable :-)


was (Author: daniel_sun):
Refined the test: https://github.com/danielsun1106/groovy-parser/blob/jsr308/src/test/resources/bugs/GROOVY-8228.groovy

> JSR308 grammar changes
> ----------------------
>
>                 Key: GROOVY-8228
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8228
>             Project: Groovy
>          Issue Type: Sub-task
>            Reporter: Paul King
>            Assignee: Daniel Sun
>             Fix For: 3.0.0-alpha-1
>
>
> Potential cases to consider.
> Known to pass with the current grammar:
> {code}
> // method receiver parameters (works with existing grammar)
> void tempCalc(@ReadOnly Weather this){ ... }
> // on arrays
> // Annotating the int type:
> @ReadOnly int [] nums;
> {code}
> Fail with `unexpected token: @ at line: xx, column: yy`:
> {code}
> // constructor usage
> Forecast currentForecast = new @Interned Forecast()
> // type casts
> Object myObject = (@NotNull Object) obj
> // exception in catch block
> catch (@Critical Exception e) { ... }
> // on arrays
> // Annotating the array type int[]:
> int @ReadOnly [] nums
> // Annotating the array type int[][]:
> int @ReadOnly [][] nums
> // Annotating the type int[], which is a component type of int[][]:
> int [] @ReadOnly [] nums
> {code}
> Fail with `unexpected token: < at line: xx, column: yy`:
> {code}
> // generics
> List<@NonNull Integer> nums = []
> List<? extends @NonNull File> fileList = null
> {code}
> Fail with 'expecting an identifier, found '@' at line: xx, column: yy':
> {code}
> // inheritance
> class MyForecast<T> implements @NonEmpty List<T>
> {code}
> Fails with 'unexpected token: throws at line: xx, column: yy':
> {code}
> // exception in method declaration
> def foo() throws @NonNull Exception { }
> {code}
> Adapted mostly from: http://www.oracle.com/technetwork/articles/java/ma14-architect-annotations-2177655.html



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)