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

NPE while processing PRAGMA compiler directive #7

Merged
merged 3 commits into from
Mar 24, 2020

Conversation

lananda
Copy link
Contributor

@lananda lananda commented Mar 24, 2020

Signed-off-by: Lalitha Ananda lalitha.ananda@oracle.com

Signed-off-by: Lalitha Ananda <lalitha.ananda@oracle.com>
@lananda
Copy link
Contributor Author

lananda commented Mar 24, 2020

If a PL/SQL procedure declaration has PRAGMA compiler tag, the DDL parser is failing to parser this & throws NPE

e.g.
create or replace package azlwbs.azlwbs_jos
is

PRAGMA SERIALLY_REUSABLE; --> NOT GETTING PARSED

procedure wsazl0( azl_request varchar2, response out varchar2 );

end azlwbs_jos;
/

DDLParser.jjt has the below logic: for packageDeclaration processing it's having switch case for cursorDeclaration,functionSpec,procedureSpec but the pragmaDeclaration case is inside the default case & it never reaches the else part of the if else block in default case. I've moved it above default case.

final public void packageDeclaration(PLSQLPackageType packageType) throws ParseException {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case R_SUBTYPE:
case R_TYPE:
case R_CURSOR:
case R_PROCEDURE:
case R_FUNCTION:
default:
if (jj_2_3(2)) {
variableDeclaration(packageType);
} else {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case K_PRAGMA:
pragmaDeclaration();
break;
default:
jj_consume_token(-1);
throw new ParseException();
}
}
}
}

Original:
void packageDeclaration(PLSQLPackageType packageType) :
{}
{
typeOrSubTypeDeclaration(packageType)
| cursorDeclaration(packageType)
| procedureSpec(packageType)
| functionSpec(packageType)
| LOOKAHEAD(2) variableDeclaration(packageType) -- FAILS HERE
| pragmaDeclaration()
}

Proposed FIX:
void packageDeclaration(PLSQLPackageType packageType) :
{}
{
typeOrSubTypeDeclaration(packageType)
| cursorDeclaration(packageType)
| procedureSpec(packageType)
| functionSpec(packageType)
| pragmaDeclaration()
<O_SEMICOLON>
| LOOKAHEAD(2) variableDeclaration(packageType)
}

@lananda
Copy link
Contributor Author

lananda commented Mar 24, 2020

ddlparser_bug30265782.zip

Reproducer

Copy link
Member

@lukasj lukasj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update copyright year

Signed-off-by: Lalitha Ananda <lalitha.ananda@oracle.com>
Signed-off-by: Lalitha Ananda <lalitha.ananda@oracle.com>
Copy link
Member

@lukasj lukasj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lukasj lukasj merged commit 126db68 into eclipse-ee4j:master Mar 24, 2020
@lananda
Copy link
Contributor Author

lananda commented Mar 24, 2020

LGTM

Thanks Lukas.

@lananda
Copy link
Contributor Author

lananda commented Mar 27, 2020

@lukasj Lukas, would you please let me know how to integrate the latest oracleddlparser.jar with eclipselink project?

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

Successfully merging this pull request may close these issues.

2 participants