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

Fail to call Java non-latin named method from Groovy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-1
    • 1.0-JSR-2
    • parser-antlr2
    • None
    • Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)

    Description

      Groovy fails to invoke Java class method if methods name contains non-latin letters.

      Failing code
      package test.groovy;

      import org.codehaus.groovy.control.CompilationFailedException;

      import groovy.lang.Binding;
      import groovy.lang.GroovyShell;

      public class TestRussian {

      public static void main(String[] args) {
      User russianUser = new User();
      russianUser.setИмя("Руслан");// Java - OK

      Binding binding = new Binding();
      GroovyShell shell = new GroovyShell(binding);
      Object value= null;
      try

      { shell.evaluate( "test.groovy.User secondUser = new test.groovy.User();" + "secondUser.setИмя('Ратмир');" + //Groovy fails here: //Script2.groovy:1:68: unexpected char: 0x418 "println secondUser.имя"); }

      catch (CompilationFailedException e)

      { // TODO Auto-generated catch block e.printStackTrace(); }

      }
      public static class User {

      private String имя;

      public String getИмя()

      { return имя; }

      public void setИмя(String имя)

      { this.имя = имя; }

      }

      }

      Stack trace
      Script2.groovy:1:68: unexpected char: 0x418
      at org.codehaus.groovy.antlr.parser.GroovyLexer.nextToken(GroovyLexer.java:702)
      at org.codehaus.groovy.antlr.parser.GroovyLexer$1.nextToken(GroovyLexer.java:235)
      at antlr.TokenBuffer.fill(TokenBuffer.java:69)
      at antlr.TokenBuffer.LA(TokenBuffer.java:80)
      at antlr.LLkParser.LA(LLkParser.java:52)
      at org.codehaus.groovy.antlr.parser.GroovyRecognizer.qualifiedTypeName(GroovyRecognizer.java:2617)
      at org.codehaus.groovy.antlr.parser.GroovyRecognizer.declarationStart(GroovyRecognizer.java:2318)
      at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:961)
      at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:641)
      at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:76)
      at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:295)
      at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:474)
      at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:773)
      at org.codehaus.groovy.control.CompilationUnit.parse(CompilationUnit.java:461)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:418)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:235)
      at groovy.lang.GroovyShell.parseClass(GroovyShell.java:531)
      at groovy.lang.GroovyShell.parse(GroovyShell.java:543)
      at groovy.lang.GroovyShell.parse(GroovyShell.java:522)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:500)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:479)
      at test.groovy.TestRussian.main(TestRussian.java:28)

      at org.codehaus.groovy.control.ProcessingUnit.fail(ProcessingUnit.java:461)
      at org.codehaus.groovy.control.ProcessingUnit.addException(ProcessingUnit.java:355)
      at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:82)
      at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:295)
      at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:474)
      at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:773)
      at org.codehaus.groovy.control.CompilationUnit.parse(CompilationUnit.java:461)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:418)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:235)
      at groovy.lang.GroovyShell.parseClass(GroovyShell.java:531)
      at groovy.lang.GroovyShell.parse(GroovyShell.java:543)
      at groovy.lang.GroovyShell.parse(GroovyShell.java:522)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:500)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:479)
      at test.groovy.TestRussian.main(TestRussian.java:28)
      Caused by: Script2.groovy:1:68: unexpected char: 0x418
      at org.codehaus.groovy.antlr.parser.GroovyLexer.nextToken(GroovyLexer.java:702)
      at org.codehaus.groovy.antlr.parser.GroovyLexer$1.nextToken(GroovyLexer.java:235)
      at antlr.TokenBuffer.fill(TokenBuffer.java:69)
      at antlr.TokenBuffer.LA(TokenBuffer.java:80)
      at antlr.LLkParser.LA(LLkParser.java:52)
      at org.codehaus.groovy.antlr.parser.GroovyRecognizer.qualifiedTypeName(GroovyRecognizer.java:2617)
      at org.codehaus.groovy.antlr.parser.GroovyRecognizer.declarationStart(GroovyRecognizer.java:2318)
      at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:961)
      at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:641)
      at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:76)
      ... 12 more

      Attachments

        Activity

          People

            phkim Kim, Pilho
            hiron Rouslan Khafizov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: