[Bug-14302]Bundled JRE (Azul Java) does not allow java packages to be imported in the same way

Due to this issue, we are currently in the unenviable position of having to support both the system-installed Java version and the bundled Azul Java.

The first issue I’ve encountered is that Azul Java doesn’t support importing java packages the way we have been doing:

> import java
> java.awt.Component
AttributeError: 'javapackage' object has no attribute 'awt'
> import java
> from java import awt
ImportError: cannot import name awt

Both of these methods have always worked with Oracle Java or OpenJDK, but they don’t with Azul Java.

The workaround is to do import java.awt, which seems to load the package correctly. The same issue appears to happen with all subpackages, for example javax.swing and java.util. It also happens if you import java.awt but then try to use java.awt.color, until you also import java.awt.color.

Is this a bug, or is this not really supported and only worked by accident?

Only worked by accident. Java doesn't expose a way to enumerate classes in packages, so the jython interpreter can only guarantee imports that specify names all the way down to the class name. Like so:

import java.lang.Exception
from java.util import Date
1 Like

That’s interesting because I don’t seem to have any issues with enumeration of classes, just subpackages.

This works fine:

import java.lang
print java.lang.Exception

We are seeing other issues internally that are similar in nature to this issue. We have an open ticket investigating this and I am adding this information to the ticket.

Thanks,
Garth