History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-2725
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jochen Theodorou
Reporter: Guillaume Laforge
Votes: 0
Watchers: 0
Operations

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

Semicolon required for certain generics declarations

Created: 04/Apr/08 04:06 AM   Updated: 24/Apr/08 05:49 PM
Component/s: parser-antlr
Affects Version/s: 1.5.4
Fix Version/s: 1.6-beta-1, 1.5.7

Time Tracking:
Not Specified


 Description  « Hide
According to this thread:
http://markmail.org/message/us25dkia37qif75f

It seems that sometimes a semi-colon is required after a generics declaration with type coercion.
The semi shouldn't be needed.

import java.util.concurrent.atomic.AtomicInteger

 public class ThreadId
 {
  // Atomic integer containing the next thread ID to be assigned
  private static final AtomicInteger nextId = new AtomicInteger(0)

  // Thread local variable containing each thread's ID
  private static final ThreadLocal<Integer> threadId = [
                  initialValue: { return nextId.getAndIncrement() }
                  ] as ThreadLocal<Integer>;
 // The Semi-colon at the end of the prior line seems to be required.


  // Returns the current thread's unique ID, assigning it if necessary
  public static int get()
  {
      System.out.println( "Thread ID: " + threadId.get());
      return threadId.get();
  }


  public static void main( String[] args )
  {
      1.upto(3) {
          Thread.start { new ThreadId().get(); }


      }
  }

 }


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jochen Theodorou - 24/Apr/08 04:20 PM
this issue sure is puzzling.. I tried to fix it by adding several workarounds, but it seems the only thing that will be accepted after "] as ThreadLocal<Integer>" is the end of the class.

Jochen Theodorou - 24/Apr/08 05:13 PM
ok, looks like the grammar matches the nls after >, meaning it fails to recognize the command end.

Jochen Theodorou - 24/Apr/08 05:49 PM
found the right nls. fixed now