This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
The following commit(s) were added to refs/heads/master by this push:
new 451e80fb69 AXIS2-6095 Fix IDL parser fault on comments ending with **/
451e80fb69 is described below
commit 451e80fb69b8607e90c3d3d6230947f3400c9ae5
Author: Robert Lazarski <[email protected]>
AuthorDate: Sun Apr 19 21:12:43 2026 -1000
AXIS2-6095 Fix IDL parser fault on comments ending with **/
The ML_COMMENT lexer rule failed on Javadoc-style comments ending
with **/ (double asterisk before slash). The original rule's ('*')+
alternative consumed both asterisks, then the next char '/' didn't
match any inner alternative (which excluded both '*' and '/'),
causing a NoViableAltForCharException.
Fix: use a semantic predicate — consume '*' only when the next
character is not '/'. This ensures '*/' always terminates the
comment, regardless of how many asterisks precede it.
Both the ANTLR grammar (idl.g) and the generated lexer (IDLLexer.java)
are updated. The generated code is hand-edited to match since the
project uses ANTLR 2.7.6 which is no longer actively maintained.
Reported by Brănaci Șerban-Mihai.
---
.../apache/axis2/corba/idl/parser/IDLLexer.java | 46 +++++-----------------
.../src/org/apache/axis2/corba/idl/parser/idl.g | 7 +---
2 files changed, 12 insertions(+), 41 deletions(-)
diff --git a/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLLexer.java
b/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLLexer.java
index a09f3a57e8..323e3bc003 100644
--- a/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLLexer.java
+++ b/modules/corba/src/org/apache/axis2/corba/idl/parser/IDLLexer.java
@@ -829,61 +829,35 @@ tryAgain:
_returnToken = _token;
}
+ // AXIS2-6095: Fixed to handle comments ending with **/ (double
asterisk).
+ // The original grammar's ('*')+ alternative failed on **/ because after
+ // consuming both asterisks, the next char '/' didn't match any inner
+ // alternative. The fix uses a semantic predicate: consume '*' only when
+ // the next char is not '/', so '*/' always terminates the comment.
public final void mML_COMMENT(boolean _createToken) throws
RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ML_COMMENT;
int _saveIndex;
-
+
_saveIndex=text.length();
match("/*");
text.setLength(_saveIndex);
{
_loop333:
do {
- if ((LA(1)=='*') && (_tokenSet_2.member(LA(2)))) {
- {
- int _cnt329=0;
- _loop329:
- do {
- if ((LA(1)=='*')) {
- match('*');
- }
- else {
- if ( _cnt329>=1 ) { break
_loop329; } else {throw new NoViableAltForCharException((char)LA(1),
getFilename(), getLine(), getColumn());}
- }
-
- _cnt329++;
- } while (true);
- }
- {
- if ((LA(1)=='\n')) {
- match('\n');
- newline();
- }
- else if ((_tokenSet_3.member(LA(1)))) {
- {
- match(_tokenSet_3);
- }
- }
- else {
- throw new
NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
- }
-
- }
+ if ((LA(1)=='*') && (LA(2) != '/')) {
+ match('*');
}
else if ((LA(1)=='\n')) {
match('\n');
newline();
}
- else if ((_tokenSet_4.member(LA(1)))) {
- {
- match(_tokenSet_4);
- }
+ else if (LA(1) != '*' && LA(1) != '\n' && LA(1) !=
EOF_CHAR) {
+ matchNot(EOF_CHAR);
}
else {
break _loop333;
}
-
} while (true);
}
_saveIndex=text.length();
diff --git a/modules/corba/src/org/apache/axis2/corba/idl/parser/idl.g
b/modules/corba/src/org/apache/axis2/corba/idl/parser/idl.g
index 49e9946a3c..261413f26c 100644
--- a/modules/corba/src/org/apache/axis2/corba/idl/parser/idl.g
+++ b/modules/corba/src/org/apache/axis2/corba/idl/parser/idl.g
@@ -1225,11 +1225,8 @@ options {
:
"/*"!
(
- '\n' { newline(); }
- | ('*')+
- ( '\n' { newline(); }
- | ~('*' | '/' | '\n')
- )
+ { LA(2) != '/' }? '*'
+ | '\n' { newline(); }
| ~('*' | '\n')
)*
"*/"!