Author jeff.allen
Recipients jeff.allen
Date 2018-04-01.08:04:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I'm spinning this off from #2656 to cover the subset of those Java 9 problems with a common cause in PyReflectedFunction.

The codecs module provides an easy way to reproduce this (remote is just a batch file that runs jython withthe command line option for remote debugging):

PS jython-jvm9> .\remote -J--illegal-access=deny
Listening for transport dt_socket at address: 8000
Jython 2.7.2a1+ (default:d74f8c2cd56f, Mar 31 2018, 23:07:07)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java9.0.1
Type "help", "copyright", "credits" or "license" for more information.
>>> import codecs
>>> enc = codecs.getencoder('gbk')
>>> enc(u"hello")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Jeff\Documents\Eclipse-O\jython-jvm9\dist\Lib\encodings\", line 78, in encode
    encoder = Charset.forName(self.encoding).newEncoder()
        at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(
        at java.base/java.lang.reflect.AccessibleObject.checkAccess(
        at java.base/java.lang.reflect.Method.invoke(
java.lang.IllegalAccessException: java.lang.IllegalAccessException: class org.python.core.PyReflectedFunction cannot access class sun.nio.cs.GBK (in module java.base) because module java.base does not export sun.nio.cs to unnamed module @7ceb3185

For me the worrying thing is that newEncoder() is a *public* abstract method of CharSet, and yet we get this message on the grounds that the *implementation* sun.nio.cs.GBK is not exported. Obviously a factory that hands out instances of a private class that implements a public interface is a common pattern, and had better work in Jython.

My first idea is that we need to handle objects not according to their actual class, but according to some super class or interface that we are allowed to access.
Date User Action Args
2018-04-01 08:04:54jeff.allensetrecipients: + jeff.allen
2018-04-01 08:04:54jeff.allensetmessageid: <>
2018-04-01 08:04:53jeff.allenlinkissue2662 messages
2018-04-01 08:04:52jeff.allencreate