Issue2582

classification
Title: No >>> prompt with JDK 9, seems to be caused by illegal access
Type: behaviour Severity: normal
Components: Any Versions: Jython 2.7
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: alanb, stefan.richthofer, teeohhem
Priority: Keywords:

Created on 2017-04-27.12:00:03 by alanb, last changed 2017-09-26.17:39:30 by teeohhem.

Messages
msg11327 (view) Author: Alan Bateman (alanb) Date: 2017-04-27.12:00:02
`java -jar jython-standalone-2.7.0.jar` does not does not prompt for input. Running with `--permit-illegal-access` (new option in JDK 9 to reveal code doing bad things) may help understand what is going on, it seems that Jython has code that is trying to access a few JDK internal classes and fields.

$ java --permit-illegal-access -jar jython-standalone-2.7.0.jar 
WARNING: --permit-illegal-access will be removed in the next major release
WARNING: Illegal access by jnr.posix.JavaLibCHelper (file:/jython/jython-standalone-2.7.0.jar) to method sun.nio.ch.SelChImpl.getFD() (permitted by --permit-illegal-access)
WARNING: Illegal access by jnr.posix.JavaLibCHelper (file:/jython/jython-standalone-2.7.0.jar) to field sun.nio.ch.FileChannelImpl.fd (permitted by --permit-illegal-access)
WARNING: Illegal access by jnr.posix.JavaLibCHelper (file:/jython/jython-standalone-2.7.0.jar) to field java.io.FileDescriptor.fd (permitted by --permit-illegal-access)
WARNING: Illegal access by org.python.core.PySystemState (file:/jython/jython-standalone-2.7.0.jar) to method java.io.Console.encoding() (permitted by --permit-illegal-access)
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java9-internal
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>>
msg11328 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-04-27.20:46:40
Apart from java.io.Console.encoding() this looks mainly like a jnr issue.
Maybe an update of jnr to a recent release can help...? (see https://github.com/jnr/jnr-posix/releases)

Any ideas for a workaround of the java.io.Console.encoding()-thing?
msg11330 (view) Author: Alan Bateman (alanb) Date: 2017-04-28.08:06:01
There isn't any supported API for getting the console encoding. It comes up periodically but there it's never clear whether it's the right thing to do or not. Here is a relatively recent thread on the topic:

http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-September/043617.html
msg11339 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-05-02.17:45:19
Regarding java.io.Console.encoding I'd suggest first immediate action would be to try/catch the illegal access.

Then we can fallback to some default value or maybe we can call:

https://github.com/jline/jline2/blob/master/src/main/java/jline/internal/Configuration.java#L225
(Jython bundles JLine already)

If that isn't sufficient, we can maybe implement something like

http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-September/043638.html

for the major platforms via JNI. (If possible add it to the launcher.)
I will also try if maybe a JNI-call to java.io.Console.encoding still permits the access (as JNI calls traditionally do) without  the exception.

Regarding jnr, we'll have to try most recent version and if that fails, raising a bug at their tracker (i.e. making it a SEP :-) https://en.wikipedia.org/wiki/Somebody_else's_problem) -- I suppose jnr also wants to be conveniently workable on Java 9.
msg11408 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-05-26.23:30:34
Updated jnr-posix as of https://hg.python.org/jython/rev/f6b3ddbc1df8.
If the jnr-posix aspects of this issue persist, we should bring this up on their issue tracker too.
msg11604 (view) Author: Tom Alexander (teeohhem) Date: 2017-09-26.17:39:30
This is no longer an issue. Java 9 decided to launch with --permit-illegal-access as the default, so no cmd arg is necessary. That being said, it won't be the default in Java 10 (and it may go away all together).
History
Date User Action Args
2017-09-26 17:39:30teeohhemsetnosy: + teeohhem
messages: + msg11604
2017-05-26 23:30:34stefan.richthofersetmessages: + msg11408
2017-05-02 17:45:20stefan.richthofersetmessages: + msg11339
2017-04-28 08:06:02alanbsetmessages: + msg11330
2017-04-27 20:46:41stefan.richthofersetnosy: + stefan.richthofer
messages: + msg11328
2017-04-27 12:00:03alanbcreate