Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of reflecting java.lang.System from docs doesnt work #484

Open
cmacdonald opened this issue Feb 9, 2020 · 1 comment
Open

Example of reflecting java.lang.System from docs doesnt work #484

cmacdonald opened this issue Feb 9, 2020 · 1 comment

Comments

@cmacdonald
Copy link
Contributor

I have tried to implement the example of https://pyjnius.readthedocs.io/en/stable/api.html#jnius.JavaField

class System(JavaClass):
    __javaclass__ = 'java/lang/System'
    out = JavaField('()Ljava/io/InputStream;', static=True)

If I then do System().out, I get:

test_export_class.py:31: 
E   AttributeError: 'System' object has no attribute '__cls_storage'

If I then do System.out, I get:

jnius/jnius_export_class.pxi:455: in jnius.JavaField.__get__
E   TypeError: expected bytes, NoneType found

Do you want a PR with a unit test?

@gunaNeelamegam
Copy link

gunaNeelamegam commented May 8, 2024

@cmacdonald
This would be the Signature for System Class.

 public static final java.io.PrintStream out;
    descriptor: Ljava/io/PrintStream;

Please try to use,

System = autoclass("java.lang.System")
class CustomSystem(System):
    __javaclass__ = "java/lang/System"

print(CustomSystem.out)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants