Issue2362

classification
Title: Import * doesn't work on JDK9 for java.*, jdk.* namespaces
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Milestone: Jython 2.7.2
process
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: alanb, amak, darjus, fwierzbicki, mr, rpan, sfelts, zyasoft
Priority: urgent Keywords:

Created on 2015-05-28.17:56:24 by sfelts, last changed 2018-05-02.00:29:23 by zyasoft.

Messages
msg10089 (view) Author: Stephen Felts (sfelts) Date: 2015-05-28.17:56:23
I had "from java.io import *"
It no longer works.  I needed to replace it with the explicit imports needed.  For example,
import java.io.ByteArrayOutputStream
import java.io.FileInputStream
import java.io.PrintStream
msg10090 (view) Author: Jim Baker (zyasoft) Date: 2015-05-28.19:18:04
Java 9 has changed jar formats; I believe this is summarized by http://openjdk.java.net/jeps/220 This means that our package scanner also needs to change.

We should start testing against Java 9, in prep for its release date in just over 1 year; Sept 22, 2016 was recently announced.

Ideally we can start supporting by2.7.1, but certainly by 2.7.2.
msg10276 (view) Author: Jim Baker (zyasoft) Date: 2015-09-22.18:52:13
This will most likely slip to 2.7.2, to be released in May 2016. I will note that I'm posting this note on Sept 22, 2015, exactly one year in advance of the planned released date for Java 9 :)

For Java 9, one thing I like is that it seems feasible to remove package scanning altogether for Java SE components, given the possibility of module reflection (http://cr.openjdk.java.net/~mr/jigsaw/spec/api/java/lang/reflect/Module.html). This seems at first glance preferable to our current approach of scanning rt.jar and also seems in the spirit of Project Jigsaw as well. We may be able to extend this to arbitrary jars in general, TBD.

It will be easy enough to test out these assumptions in Python code before  attempting changes in import logic.
msg10634 (view) Author: Jim Baker (zyasoft) Date: 2016-01-12.00:42:47
Moving to 2.7.2 - we just don't have time to get such a major change in 2.7.1. In contrast, 2.7.2 lets us get this right.

But it will be a blocker for 2.7.2, so marking urgent as a consequence.
msg10649 (view) Author: Darjus Loktevic (darjus) Date: 2016-01-15.12:16:07
Looks like Java 9 release is slipping by 6mo which means the GA will be 2017/03/23 . In a way, lucky for us this gives us a bit more time work on Java 9 support as we ourselves are slipping with 2.7.1 release of Jython. But this does not change the priority of making sure Java 9 works with Jython 2.7.2

http://mail.openjdk.java.net/pipermail/jdk9-dev/2015-December/003237.html
msg10651 (view) Author: Jim Baker (zyasoft) Date: 2016-01-15.15:22:22
Darjus, good to see the alignment in our schedules. As I see it, we should triage this bug as the second most important bug after #2182 in 2.7.2. (Regardless, we would expect work on these two bugs to be done in parallel.)

Also we need to use the jrt filesystem (http://openjdk.java.net/jeps/220), which corresponds in any event with the existing package scanner. As far as I can tell, java.lang.reflect.Module and related introspection does not provide sufficient support to get at package hierarchies.
msg11331 (view) Author: Alan Bateman (alanb) Date: 2017-04-28.08:40:39
See also this issue in the OpenJDK JIRA where it initially looked like a startup performance issue in JDK 9:
https://bugs.openjdk.java.net/browse/JDK-8166236
msg11475 (view) Author: (rpan) Date: 2017-07-14.06:56:58
The OpenJDK bug https://bugs.openjdk.java.net/browse/JDK-8166236 was closed. Its corresponding Jython issue is: http://bugs.jython.org/issue2605
msg11930 (view) Author: Jim Baker (zyasoft) Date: 2018-05-01.02:07:28
We should look at the use of such tooling as Reflections, ClassIIndex, and Fast Class Scanner, possibly directly incorporating, depending on their licensing. Something like ClassIndex might work, we specifically need the JRT support introduced by Jigsaw: https://github.com/atteo/classindex/issues/42, I would assume the ahead-of-time aspects are not so relevant for Jython's model. ClassIndex's license is directly compatible with Jython (see similar inclusions like https://hg.python.org/jython/file/tip/ACKNOWLEDGMENTS)

Note this would be a big change for how we index!
msg11931 (view) Author: Jim Baker (zyasoft) Date: 2018-05-01.02:09:12
To clarify: a big change for our *index file format* if we go with ClassIndex. Otherwise I would expect package scanning to remain the same as something we cache on demand.
msg11932 (view) Author: Stephen Felts (sfelts) Date: 2018-05-01.02:18:29
The performance hit is visibly noticible to users.  That's why we even started doing the analysis.  It's important that this is fixed.
msg11933 (view) Author: Jim Baker (zyasoft) Date: 2018-05-02.00:29:21
We may not need a third party library. This works on Java 9 and Java 10 to list all classes in the java.base module:

from java.lang.module import ModuleFinder
from contextlib import closing

finder = ModuleFinder.ofSystem()
ref = finder.find('java.base')
with closing(ref.get().open()) as reader:
    resources = reader.list().toArray()
    print resources

Ignores such niceties as the Stream interface etc. Improve accordingly for real usage, such as writing in Java and putting into the Jython runtime.

Also it's important to know that import * works on any library that is not in a Jigsaw module. This presumably only applies for what used to be in the rt.jar, plus additions.

A third party library might result in a faster scanner however.
History
Date User Action Args
2018-05-02 00:29:23zyasoftsetmessages: + msg11933
title: Import * doesn't work on JDK9 -> Import * doesn't work on JDK9 for java.*, jdk.* namespaces
2018-05-01 02:18:29sfeltssetmessages: + msg11932
2018-05-01 02:09:12zyasoftsetmessages: + msg11931
2018-05-01 02:07:29zyasoftsetmessages: + msg11930
2017-07-14 06:56:58rpansetnosy: + rpan
messages: + msg11475
2017-04-28 08:40:40alanbsetnosy: + alanb
messages: + msg11331
2016-01-15 15:22:22zyasoftsetmessages: + msg10651
2016-01-15 12:16:08darjussetnosy: + darjus
messages: + msg10649
2016-01-12 00:42:47zyasoftsetpriority: high -> urgent
nosy: + fwierzbicki
messages: + msg10634
milestone: Jython 2.7.1 -> Jython 2.7.2
2015-12-30 00:03:53zyasoftsetpriority: normal -> high
2015-12-30 00:00:50zyasoftsetmilestone: Jython 2.7.1
2015-09-22 18:52:14zyasoftsetmessages: + msg10276
2015-09-17 15:38:34mrsetnosy: + mr
2015-06-05 10:11:21amaksetnosy: + amak
2015-05-28 19:18:05zyasoftsetpriority: normal
resolution: accepted
messages: + msg10090
nosy: + zyasoft
2015-05-28 17:56:24sfeltscreate