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

SqlCl CREATE JAVA quote mishandling #27

Open
vic-ita opened this issue Oct 3, 2019 · 1 comment
Open

SqlCl CREATE JAVA quote mishandling #27

vic-ita opened this issue Oct 3, 2019 · 1 comment
Assignees
Labels

Comments

@vic-ita
Copy link

vic-ita commented Oct 3, 2019

Hi there.

I'm reporting a bug on SqlCl. (Tested on SqlCl version 19.2.1.206.1649 ).

With the statement CREATE JAVA, SqlCl mishandles quotes symbols whenever they are contained in single-line java comments.

I.E.: consinder the following statements:

The following statement will work fine since the quotes appear in an even number

CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED MyTestClass AS
 public class MyTestClass {
	 public static String welcome() {
		// it's a comment
		return "Welcome World";
		// it's another comment
	 } 
}
/

On the other hand the following statement will fail since quotes appear in an odd number (just one)

CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED MyTestClass AS
 public class MyTestClass {
	 public static String welcome() {
		// it's a comment
		return "Welcome World";
	 } 
}
/

Here is the SqlCl output for the first snippet:

SQL> CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED MyTestClass AS
  2   public class MyTestClass {
  3   public static String welcome() {
  4  // it's a comment
  5  return "Welcome World";
  6  // it's another comment
  7   }
  8  }
  9  /

Java Source MYTESTCLASS creato

SQL>

Now look what happens with the same code but with an odd number of single quotes:

SQL> CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED MyTestClass AS
  2   public class MyTestClass {
  3   public static String welcome() {
  4  // it's a comment
  5  return "Welcome World";
  6   }
  7  }
  8  /
  9
 10
 11  /
 12
 13
 14  '
 15  /
Errore con inizio alla riga : 1 nel comando -
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED MyTestClass AS
 public class MyTestClass {
 public static String welcome() {
// it's a comment
return "Welcome World";
 }
}
/


/


'
Report error -
ORA-29536: origine di formato errato: Encountered "/" at line 7, column 1.
Was expecting one of:
    <EOF>
    "#sql" ...
    "static" ...
    "abstract" ...
    "final" ...
    "private" ...
    "protected" ...
    "public" ...
    "strictfp" ...
    "class" ...
    "enum" ...
    "interface" ...
    "native" ...
    "synchronized" ...
    "transient" ...
    "volatile" ...
    ";" ...
    "@" ...
    "\\u001a" ...

29536. 00000 -  "badly formed source: %s"
*Cause:    An attempt was made to create a Java source object with text
           that could not be parsed adequately to determine the class(es)
           defined by it.
*Action:   Correct errors in source.
SQL>

Note how the terminator character on line 8 is ignored. Then on line 11 it is ignored a second time (I could have hit it an arbitrary numner of times tho). On line 14 I added another quote "closing" the one opened in the java comment. Thus on line 15 SqlCl recognizes the last terminator character and creates a statement that is clearly invalid for the DB engine.

ALSO, note that the problem ONLY happens when dealing with single line java comments. Consider the following snippet as a proof of this behavior:

SQL> CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED MyTestClass AS
  2   public class MyTestClass {
  3   public static String welcome() {
  4   /*
  5  // it's a comment
  6   */
  7  return "Welcome World";
  8   }
  9  }
 10  /

Java Source MYTESTCLASS creato

SQL>

Vincenzo.

@bamcgill
Copy link
Member

bug logged

@bamcgill bamcgill self-assigned this Jan 21, 2022
@bamcgill bamcgill added the bug label Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants