Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class reference is failed when include 'or' at a package name #103

Open
kazuki43zoo opened this issue May 21, 2020 · 1 comment
Open

Class reference is failed when include 'or' at a package name #103

kazuki43zoo opened this issue May 21, 2020 · 1 comment

Comments

@kazuki43zoo
Copy link
Contributor

If package name includes "or" (e.g. "jp.or.example"), the Ognl#parseExpression(String) is failed as follow:

  • Code
    public void test_class_reference()
        throws Throwable
    {
        OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null, new DefaultMemberAccess(false));
        {
            Node expr = (Node) Ognl.parseExpression("@java.util.UUID@randomUUID()"); // It's OK
            Object v = expr.getValue(context, null);
            System.out.println(v);
        }
        {
            Node expr = (Node) Ognl.parseExpression("@jp.or.example.IdUtils@generateId()"); // It's failed on parsing phase
            Object v = expr.getValue(context, null);
            System.out.println(v);
        }
    }
  • Stack Trace
ognl.ExpressionSyntaxException: Malformed OGNL expression: @jp.or.example.IdUtils@generateId()
 [ognl.ParseException: Encountered " "or" "or "" at line 1, column 5.
Was expecting:
    <IDENT> ...
    ]
	at ognl.Ognl.parseExpression(Ognl.java:179)
	at org.ognl.test.enhance.TestExpressionCompiler.test_class_reference(TestExpressionCompiler.java:55)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at junit.framework.TestCase.runTest(TestCase.java:176)
	at junit.framework.TestCase.runBare(TestCase.java:141)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:129)
	at junit.framework.TestSuite.runTest(TestSuite.java:252)
	at junit.framework.TestSuite.run(TestSuite.java:247)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: ognl.ParseException: Encountered " "or" "or "" at line 1, column 5.
Was expecting:
    <IDENT> ...
    
	at ognl.OgnlParser.generateParseException(OgnlParser.java:3232)
	at ognl.OgnlParser.jj_consume_token(OgnlParser.java:3098)
	at ognl.OgnlParser.className(OgnlParser.java:1822)
	at ognl.OgnlParser.classReference(OgnlParser.java:1795)
	at ognl.OgnlParser.staticReference(OgnlParser.java:1762)
@lukaszlenart
Copy link
Collaborator

I was struggling with this issue for a bit and I still have no idea how to fix that :(

JCgH4164838Gh792C124B5 added a commit to JCgH4164838Gh792C124B5/ognl that referenced this issue Apr 11, 2021
…lude package

names like "and" or "or"):
- Sub-optimal solution requires direct modification of OgnlParser, so if
the language specification (ognl.jj, ognl.jjt) ever changes and is rebuilt
using JavaCC/JJTree, the logic would have to be manually re-added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants