You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A.java's last byte is 0x1A, or the ASCII Substitute character. javac will parse this just fine.
$ javac A.java
But javac-parser crashes!
$ python lex.py A.java
Traceback (most recent call last):
File "lex.py", line 9, in<module>
tokens = Java().lex(source.read())
File "/Users/eddieantonio/Projects/javac-parser/javac_parser.py", line 147, in lex
return [convert(l) forlin self.lex_call(java_source)]
File "/Users/eddieantonio/Projects/javac-parser/javac_parser.py", line 108, in lex_call
binary = self.app.lexFlat(java_source)
File "/Users/eddieantonio/.pyenv/versions/javac-parser/lib/python3.6/site-packages/py4j/java_gateway.py", line 1160, in __call__
answer, self.gateway_client, self.target_id, self.name)
File "/Users/eddieantonio/.pyenv/versions/javac-parser/lib/python3.6/site-packages/py4j/protocol.py", line 320, in get_return_value
format(target_id, ".", name), value)
py4j.protocol.Py4JJavaError: An error occurred while calling o0.lexFlat.
: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1967)
at ca.ualberta.cs.ParserWrapper.lexIt(ParserWrapper.java:106)
at ca.ualberta.cs.App.lexFlat(App.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:282)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:214)
at java.lang.Thread.run(Thread.java:745)
Try lexing this file from apache/che:
The "raw" source has some totally funky characters!
What's worse, not properly handling The Java SE Specification Section §3.5 crashes the server!
A.java
's last byte is 0x1A, or the ASCII Substitute character.javac
will parse this just fine.But javac-parser crashes!
See these two files for reproduction:
A.java.txt
lex.py.txt
The text was updated successfully, but these errors were encountered: