Uploaded image for project: 'Commons OGNL (Dormant)'
  1. Commons OGNL (Dormant)
  2. OGNL-57

The compilation of expressions with negate symbol (!) causes javassist exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.7
    • 2.7
    • ExpressionCompiler
    • None
    • latest SVN version at 27 April

    Description

      In some cases compilation of expressions with negate symbol causes javassist exceptions.

      For example,

      the testcase for org.ognl.test.ArrayElementsTest

      {null, "

      { true, !false }

      ", Arrays.asList(new Boolean[]

      { Boolean.TRUE, Boolean.TRUE }

      ) },

      causes

      javassist.CannotCompileException: [source error] syntax error near ", ($w) !false});}"

      at javassist.CtBehavior.setBody(CtBehavior.java:364)

      at javassist.CtBehavior.setBody(CtBehavior.java:333)

      at ognl.enhance.ExpressionCompiler.generateGetter(ExpressionCompiler.java:472)

      at ognl.enhance.ExpressionCompiler.compileExpression(ExpressionCompiler.java:343)

      at ognl.OgnlRuntime.compileExpression(OgnlRuntime.java:387)

      at ognl.Ognl.compileExpression(Ognl.java:123)

      at org.ognl.test.OgnlTestCase.getExpression(OgnlTestCase.java:145)

      at org.ognl.test.OgnlTestCase.runTest(OgnlTestCase.java:196)

      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

      Caused by: compile error: syntax error near ", ($w) !false});}"

      at javassist.compiler.Parser.parseArrayInitializer(Parser.java:676)

      and the testcase for org.ognl.test.MethodTest

      { "getValueIsTrue(!false) ? \"\" : \"here\" ", ""}

      ,

      causes

      javassist.CannotCompileException: [source error] ) is missing

      at javassist.CtBehavior.setBody(CtBehavior.java:364)

      at javassist.CtBehavior.setBody(CtBehavior.java:333)

      at ognl.enhance.ExpressionCompiler.generateGetter(ExpressionCompiler.java:472)

      at ognl.enhance.ExpressionCompiler.compileExpression(ExpressionCompiler.java:343)

      at ognl.OgnlRuntime.compileExpression(OgnlRuntime.java:387)

      at ognl.Ognl.compileExpression(Ognl.java:123)

      at org.ognl.test.OgnlTestCase.getExpression(OgnlTestCase.java:145)

      at org.ognl.test.OgnlTestCase.runTest(OgnlTestCase.java:196)

      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

      Caused by: compile error: ) is missing

      at javassist.compiler.Parser.parseArgumentList(Parser.java:1337)

      I believe i can find mutch more cases to fail. And i believe this issue is related with one reported before (OGNL-38). The fix proposed in OGNL-38 cold work for all places, where negate symbol directly follow the javassis macro ($w).

      Attachments

        Activity

          People

            jkuhnert Jesse Kuhnert
            lucker Alexander Gavrilov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: