[ 
https://issues.apache.org/jira/browse/OPENJPA-2946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18125079#comment-18125079
 ] 

ASF subversion and git services commented on OPENJPA-2946:
----------------------------------------------------------

Commit dcac971d4330d94958f14041ab13a8b1235408f3 in openjpa's branch 
refs/heads/master from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=dcac971d4 ]

[OPENJPA-2946] Address the JavaCC warnings in the JPQL grammar build (#204)

Two independent concerns:

(1) The javacc-maven-plugin execution passed -JDK_VERSION=17 (from
${java.class.version}, which holds the compiler release, not a class file
version) to both jjtree and javacc, and both answered 'Bad option value in
"-JDK_VERSION=17" will be ignored.'. JavaCC 5.0 types a command line option
value by the class of its default, so a value that parses as an integer is
rejected for the String option JDK_VERSION and discarded; the build has
therefore always generated with the default 1.5. Every JDK dependent switch
in JavaCC 5.0 is jdkVersionAtLeast(1.5), so no accepted value could change
the output - generating with and without the option yields byte identical
sources. The option is dropped rather than re-spelled.

(2) arithmetic_expression() and arithmetic_term() eliminated left recursion
by recursing on themselves inside a (...)* loop, which made the choice in the
loop ambiguous ('Choice conflict in (...)* construct ... common prefixes, one
of which is: "+"' / '"*"') and, because JavaCC resolves such a conflict
greedily in favour of the nested expansion, parsed a - b - c as a - (b - c)
and a / b / c as a / (b / c). Both productions now iterate over the operator
and recurse one level down, which removes the conflict and makes the
operators left associative as the specification requires. Additive and
multiplicative precedence is unchanged.

orderby_item() also had two 'Choice conflict involving two expansions'
warnings, for orderby_extension() and identification_variable() against the
later scalar_expression() alternative. JavaCC's default already picks the
earlier alternative, which is the intended parse, so both are annotated with
LOOKAHEAD(1) to state that the one token decision is intended. A syntactic
LOOKAHEAD would have made every alternative of the choice explicit, which stops
JavaCC from emitting the token set switch for it: the expected token set of a
malformed ORDER BY item would then be empty and the reported offset would move
to the start of the item, degrading the user visible jpql-parse-error message.

The grammar build now emits no warnings at all.

The associativity change alters the result of existing queries, so it is
documented in the 4.2.0 incompatibilities and the operator precedence section
of the manual gains an explicit note on evaluation order.

> Java Compiler Compiler Warnings need to be addressed
> ----------------------------------------------------
>
>                 Key: OPENJPA-2946
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2946
>             Project: OpenJPA
>          Issue Type: Sub-task
>          Components: jpa
>    Affects Versions: 4.1.1
>            Reporter: Maxim Solodovnik
>            Priority: Major
>             Fix For: 4.2.0
>
>
> Original analysis: 
> https://github.com/apache/openjpa/pull/144#issuecomment-5323990530
> Following warnings need to be sorted out:
> {code}
> Java Compiler Compiler Version 5.0 (Tree Builder)
> (type "jjtree" with no arguments for help)
> Warning: Bad option value in "-JDK_VERSION=17" will be ignored.
> Reading from file 
> /home/solomax/work/_oss/openjpa/openjpa-kernel/src/main/jjtree/org/apache/openjpa/kernel/jpql/JPQL.jjt
>  . . .
> File "Node.java" does not exist.  Will create one.
> File "JPQLTreeConstants.java" does not exist.  Will create one.
> File "JJTJPQLState.java" does not exist.  Will create one.
> Annotated grammar generated successfully in 
> /home/solomax/work/_oss/openjpa/openjpa-kernel/target/javacc-1779085259067/node/JPQL.jj
> Java Compiler Compiler Version 5.0 (Parser Generator)
> (type "javacc" with no arguments for help)
> Warning: Bad option value in "-JDK_VERSION=17" will be ignored.
> Reading from file 
> /home/solomax/work/_oss/openjpa/openjpa-kernel/target/javacc-1779085259067/node/JPQL.jj
>  . . .
> Warning: Choice conflict in (...)* construct at line 1053, column 17.
>          Expansion nested within construct and expansion following construct
>          have common prefixes, one of which is: "+"
>          Consider using a lookahead of 2 or more for nested expansion.
> Warning: Choice conflict in (...)* construct at line 1062, column 17.
>          Expansion nested within construct and expansion following construct
>          have common prefixes, one of which is: "*"
>          Consider using a lookahead of 2 or more for nested expansion.
> Warning: Choice conflict involving two expansions at
>          line 1533, column 12 and line 1534, column 12 respectively.
>          A common prefix is: "AVG" "("
>          Consider using a lookahead of 3 or more for earlier expansion.
> Warning: Choice conflict involving two expansions at
>          line 1533, column 34 and line 1534, column 12 respectively.
>          A common prefix is: <IDENTIFIER>
>          Consider using a lookahead of 2 for earlier expansion.
> File "TokenMgrError.java" does not exist.  Will create one.
> File "ParseException.java" does not exist.  Will create one.
> File "Token.java" does not exist.  Will create one.
> File "JavaCharStream.java" does not exist.  Will create one.
> Parser generated with 0 errors and 4 warnings.
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to