Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1560

'as' not allowed as namespace in embedding Groovy-code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-JSR-6
    • 1.5.2
    • parser
    • None
    • Java SDK 1.4.2

    Description

      I accidently stumbled over the problem that I could not use Java classes packaged in namespace 'as'.

      Example (Java-Code with embedded Groovy-script):

      import as.AsTest;
      public class TestAs
      {
      // different trials:
      private static String groovyCode1 =
      "import as.AsTest as a; " +
      "return new AsTest(); ";

      private static String groovyCode2 =
      "import as.*; " +
      "return new AsTest(); ";

      private static String groovyCode3 =
      "return new as.AsTest(); ";

      private static String groovyCode4 =
      "import as.AsTest; " +
      "return new AsTest(); ";

      public static void main(String[] args)

      { AsTest a = new AsTest(); // Ok GroovyShell shell = new GroovyShell(new Binding()); Object value = shell.evaluate(groovyCode3); // ..1-4 System.out.println(value); return; }

      }

      Error message is 'MultipleCompilationErrorsException'.

      'as' is a reserved word in Groovy. Nevertheless I think 'as' should be allowed as namespace-name (as it is allowed in Java).

      Attachments

        Activity

          People

            paulk Paul King
            pfuerholz Peter Fürholz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: