You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "feng.huang (Jira)" <ji...@apache.org> on 2021/03/02 05:43:00 UTC

[jira] [Updated] (CALCITE-4518) org.codehaus.commons.compiler.CompileException

     [ https://issues.apache.org/jira/browse/CALCITE-4518?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

feng.huang updated CALCITE-4518:
--------------------------------
    Description: 
calcite call janino to compile javacode in some case such as ReduceExpressionsRule#reduceExpressions, but there is something wrong with janino handling "<" operator.

 
{code:java}
public static void main(String[] args) throws IOException, CompileException {

    String code = "public Object[] apply(Object root0) {\n" +
            "int a=1;int b=2 ; " +
            "return new Object[]{a < b,1,2};\n" +
            "}\n";
    final ClassBodyEvaluator cbe = new ClassBodyEvaluator();
    cbe.setClassName("Test");
    cbe.setExtendedClass(Utilities.class);
    cbe.setImplementedInterfaces(new Class[]{Function1.class, Serializable.class});
    cbe.setParentClassLoader(RexExecutable.class.getClassLoader());
    cbe.cook(new Scanner(null, new StringReader(code)));
}{code}
 

when janino read "a < b , " , it regard this as the instance of rule : ShiftExpression<TypeArgument,TypeArgument...>, and then throw "CompileException: Line 2, Column 45: IDENTIFIER expected instead of '1'.

  was:
calcite call janino to compile javacode in some case such as ReduceExpressionsRule#reduceExpressions, but there is something wrong with janino handling "<" operator.

 
{code:java}
public static void main(String[] args) throws IOException, CompileException {

    String code = "public Object[] apply(Object root0) {\n" +
            "int a=1;int b=2 ; " +
            "return new Object[]{a < b,1,2};\n" +
            "}\n";
    final ClassBodyEvaluator cbe = new ClassBodyEvaluator();
    cbe.setClassName("Test");
    cbe.setExtendedClass(Utilities.class);
    cbe.setImplementedInterfaces(new Class[]{Function1.class, Serializable.class});
    cbe.setParentClassLoader(RexExecutable.class.getClassLoader());
    cbe.cook(new Scanner(null, new StringReader(code)));
}{code}
 

 

when janino read "a < b , " , it regard this as the instance of rule : ShiftExpression<TypeArgument,TypeArgument...>.


> org.codehaus.commons.compiler.CompileException
> ----------------------------------------------
>
>                 Key: CALCITE-4518
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4518
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: feng.huang
>            Priority: Major
>
> calcite call janino to compile javacode in some case such as ReduceExpressionsRule#reduceExpressions, but there is something wrong with janino handling "<" operator.
>  
> {code:java}
> public static void main(String[] args) throws IOException, CompileException {
>     String code = "public Object[] apply(Object root0) {\n" +
>             "int a=1;int b=2 ; " +
>             "return new Object[]{a < b,1,2};\n" +
>             "}\n";
>     final ClassBodyEvaluator cbe = new ClassBodyEvaluator();
>     cbe.setClassName("Test");
>     cbe.setExtendedClass(Utilities.class);
>     cbe.setImplementedInterfaces(new Class[]{Function1.class, Serializable.class});
>     cbe.setParentClassLoader(RexExecutable.class.getClassLoader());
>     cbe.cook(new Scanner(null, new StringReader(code)));
> }{code}
>  
> when janino read "a < b , " , it regard this as the instance of rule : ShiftExpression<TypeArgument,TypeArgument...>, and then throw "CompileException: Line 2, Column 45: IDENTIFIER expected instead of '1'.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)