-
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
superclass methods not accessible in 1.2.1 #465
Comments
I can reproduce it locally, let's see if it also happens in CI, i'll look for a fix when i have some time. |
CI failed, but I can't see how we broke it in 1.2.1. I can see that getDeclaredMethods() doesn't include methods that are default implementations. (They arent declared in the class or its supertypes). There is some discussion in https://blog.jooq.org/2018/03/28/correct-reflective-access-to-interface-default-methods-in-java-8-9-10/ - I dont think this is relevant. Is the solution also to walk all interfaces and their parent interfaces adding default methods? (We could add the abstract methods, but this seems superfluous as they must by implemented by the concrete object). This is the most relevant stackoverflow thread I found: https://stackoverflow.com/questions/28400408/what-is-the-new-way-of-getting-all-methods-of-a-class-including-inherited-defau it does seems that there could be some differences in different JVM implementations... |
It does work if i cast to java.util.Collection first, but it shouldn't be necessary… :/ |
I also think it's because of using getDeclaredMethods instead of getMethods, i tried to walk all the interfaces but somehow it wasn't finding the Collection interface in getInterfaces()… |
hm, this seems to work… not completely sure why. edit: uh, save for a segfault… https://github.com/kivy/pyjnius/runs/348651345 |
https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=100815&view=logs&j=696704cc-6fef-57a3-ea36-f27779b8cd5e&t=06421391-4b55-523d-a804-5e1a5bfc1908 |
patch works for me on collab |
polite bump. Would be good to get this one merged. I added a comment to the diff suggesting a code comment. |
Sorry for letting this linger, i just really have no idea what prevents the CI from passing, and i don't really like disabling part of the targets just to silent an incomprehensible error, i agree letting this bitrot is not any better but i'm not sure how to go forward from this. |
I had wondered if this was a concurrency issue as per #480, but I don't think pytest is concurrent by default. I tried reproducing locally, but didn't succeed in reproducing #480. Here was my command - its a Debian-based image: docker run -i continuumio/anaconda3 /bin/bash <<EOF
cat /etc/os-release
apt-get update
mkdir /usr/share/man/man1
apt-get -y install openjdk-11-jdk-headless gcc ant
conda create -y -n pyjnius python=3.7.5
conda activate pyjnius
git clone https://github.com/kivy/pyjnius.git
cd pyjnius/
python -m pip install -U setuptools cython
python setup.py bdist_wheel
pip install --timeout=120 .[dev,ci]
ant all
cd tests/
CLASSPATH="../build/test-classes:../build/classes" PYTHONPATH=/opt/conda/envs/pyjnius/lib/python3.7/site-packages/ pytest -v
cd ../
git checkout -b issue_465 origin/issue_465
python setup.py bdist_wheel
pip install --timeout=120 .[dev,ci]
ant all
cd tests/
CLASSPATH="../build/test-classes:../build/classes" PYTHONPATH=/opt/conda/envs/pyjnius/lib/python3.7/site-packages/ pytest -v
EOF All tests passed on master and on the branch. |
I observe the same problem, superclass methods are not accessible in 1.2.1 but everything works in 1.2.0. This is quite nasty bug, don't you think it make sense to remove 1.2.1 release or somehow mark it as unusable ? |
This works around kivy/pyjnius#465.
Might I suggest re-running the CI tests? Can we try to narrows this down - is it a problem in this patch, or a problem with a previous version? |
To return to this: I dont think mixing My test cases for this are:
Various fail when we only use getDeclaredMethods(). My only issue with
|
Hi @tshirtman I see you committed getMethods(). I'd recommend the additional test cases above as well. |
hm, indeed adding this test shows that currently the object casted as a |
#501 passed all tests. Closing this issue. (Praise be). |
Protected fields still missing! Changing this line from |
There is a discussion on #500 as to whether private/protected methods/fields should be exposed at all. |
i think that's different, currently we are supposed to have everything, and with your fix, it seems to be true for methods, but apparently it's not (and possibly never was?) true for fields, so i think it's a bug to solve first, whether we then decide to allow filtering the methods/fields we want to see depending on their level of privacy. As this bug is closed, it makes sense to me to open a new one for that case. |
It worked for <1.2.1 so I would expect it to work in >1.2.1,<2.0 too even if it should not have worked for any version. |
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.
This works for 1.2.0 but not for 1.2.1.
Reproducible notebook at https://colab.research.google.com/drive/1F9u2jVQR5JFw_mk5Bq--VH1Ki91Xe5x3
stream() is defined in the super-interface as a default.
We also had problem accessing methods in interfaces that extended java.util.List.
The text was updated successfully, but these errors were encountered: