Hello.
I'm using pyjnius in a desktop application, but when I try to access Java classes of the java.security package,
the JVM returns an exception.
I just replicated the error in the following way.
Starting by building a virtual environment:
$ python3.8 -m venv env
$ source env/bin/activate
(env) $ pip install pyjnius
Collecting pyjnius
 Using cached pyjnius-1.3.0-cp38-cp38-manylinux2010_x86_64.whl (1.4 MB)
Collecting cython
 Using cached Cython-0.29.17-cp38-cp38-manylinux1_x86_64.whl (2.0 MB)
Collecting six>=1.7.0
 Using cached six-1.14.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: cython, six, pyjnius
Then I wrote a very simple Hellow World program:
from jnius import autoclass
Â
system = autoclass('java.lang.System')
system.out.println('Hello World')
system.out.println(system.getProperty('java.version'))
system.out.println(system.getProperty('java.vendor'))
Running it, everything goes exactly as expected:
(env) $ python hello_world.py
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Hello World
11.0.7-ea
Debian
As shown I'm running open-jdk-11 on a Debian system:
(env) $ java --version
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
openjdk 11.0.7-ea 2020-04-14
OpenJDK Runtime Environment (build 11.0.7-ea+9-post-Debian-1)
OpenJDK 64-Bit Server VM (build 11.0.7-ea+9-post-Debian-1, mixed mode, sharing)
When I add the "PasswordProtection' class to the flie, the error appear:
from jnius import autoclass
system = autoclass('java.lang.System')
system.out.println('Hello World')
system.out.println(system.getProperty('java.version'))
system.out.println(system.getProperty('java.vendor'))
PassProt = autoclass('java.security.KeyStore.PasswordProtection')
system.out.println('Imported')
Running:
(env) $ python hello_world.py
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Hello World
11.0.7-ea
Debian
Traceback (most recent call last):
 File "hello_world.py", line 9, in <module>
  PassProt = autoclass('java.security.KeyStore.PasswordProtection')
 File "/tmp/test_jnious/env/lib/python3.8/site-packages/jnius/reflect.py", line 229, in autoclass
  c = find_javaclass(clsname)
 File "jnius/jnius_export_func.pxi", line 26, in jnius.find_javaclass
 File "jnius/jnius_jvm_dlopen.pxi", line 91, in jnius.create_jnienv
jnius.JavaException: JVM exception occurred: java/security/KeyStore/PasswordProtection java.lang.NoClassDefFoundError
The error also happens when using Sun SDK 1.11. But if I write a HelloWorld in Java, there is no error:
import java.security.KeyStore.PasswordProtection;
Â
class HelloWorld {
 public static void main(String[ ] argv) {
  char[] pass = { 'a', 'b', 'c' };
  PasswordProtection prot = new PasswordProtection(pass);
  System.out.println("Hello World");
 }
}
Building and running it:
(env) $ javac HelloWorld.java
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
(env) $ java HelloWorld
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Hello World
No errors.
Of couse, in this way I'm not using reflection, but at least, it proves that the package is available.
I would appreciate some help on that.
Regards.
Paulo