-
Notifications
You must be signed in to change notification settings - Fork 256
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
expose the class's class attribute #523
Conversation
At first i though "hey, but in python it's |
|
@@ -38,6 +38,15 @@ def test_hierharchy_arraylist(self): | |||
self.assertEqual(d["java.lang.Object"], maxLevel) | |||
self.assertEqual(d["java.util.ArrayList"], 0) | |||
|
|||
def test_class(self): | |||
lstClz = autoclass("java.util.List") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a nothingbug but in python the standin for "class" is usually "cls" (and sometime "klass" but i'm less fond of that). but here it could even be the more idiomatic "list_class".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair. naming was not very pythonic.
Full Changelog: 1.2.1...1.3.0 Implemented enhancements: - (#483) allow passing a `signature` argument to constructors, to force selection of the desired one - (#497) support for more "dunder" methods/protocols on compatible interfaces than just `__len__`, and allow users to provide their own. - (#500) allow ignoring private methods and fields in autoclass (both default to False) - (#503) auto detect java_home on OSX, using `/usr/libexec/java_home` (if JAVA_HOME is not declared) - (#514) writing to static fields (and fix reading from them) - (#517) make signature exceptions more useful - (#502) provide a stacktrace for where JVM was started. - (#523) expose the class's class attribute - (#524) fix handling of Java chars > 256 in Python3 - (#519) Always show the exception name Fixed bugs: - (#481) wrong use of strip on JRE path - (#465) correct reflection to avoid missing any methods from parent classes or interfaces - (#508) don't had error details with a custom exception when java class is not found - (#510) add missing references to .pxi files in setup.py, speeding up recompilation - (#518) ensure autoclass prefers methods over properties - (#520) improved discovery of libjvm.so + provide a workaround if it doesn't work Documentation: - (#478) document automatic Thread detach feature - (#512) document the requirement to keep reference to object/functions passed to java, for as long as it might use them - (#521) fix inheritance in example Many thanks to the contributors that stepped up to help this release, it wouldn't have been possible without them. Craig Macdonald, Gabriel Pettier, Jim, André Miras, Young Ryul Bae, yyang, Pascal Chambon, Kevin Ollivier, Guillaume Gay, Christian M. Salamut, collaborated for this release.
In Java, I can use
String.class
to get the String class' Class object.In Jnius, its not exposed. This fixes this.
Note that as
class
is a reserved keyword in Python, the attribute is._class
, so the python equivalent isautoclass("java.lang.String")._class
.Includes a unit test.