8000 Add object introspection functions by ctrueden · Pull Request #78 · scijava/scyjava · GitHub
[go: up one dir, main page]

Skip to content

Add object introspection functions #78

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

Merged
merged 41 commits into from
Apr 29, 2025
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0a8141c
Add some functions for Java object introspection
ctrueden Mar 26, 2025
7b8a6c4
Update methods() functionality
ian-coccimiglio Mar 27, 2025
fe0bfe3
Make progress on introspection methods
ian-coccimiglio Mar 27, 2025
25d769e
Make linter happy
ian-coccimiglio Mar 27, 2025
1a0fd71
Add source code reporting to methods() function
ian-coccimiglio Mar 27, 2025
640d57d
Implement fields introspection function
ian-coccimiglio Mar 27, 2025
aa3996c
Add partials, refactor, add java_source function
ian-coccimiglio Mar 28, 2025
9352ff6
Refactor introspection code
ian-coccimiglio Mar 28, 2025
fe60217
Add test cases for introspection functions
ian-coccimiglio Mar 28, 2025
7293d23
Lint code
ian-coccimiglio Mar 28, 2025
4123078
Improve introspection function documentation
ian-coccimiglio Mar 31, 2025
3533446
Add docstring to test_introspection.py
ian-coccimiglio Mar 31, 2025
9516a72
Wrap long line
ctrueden Apr 2, 2025
6520223
Increment minor version digit
ctrueden Apr 2, 2025
363e7bc
Alphabetize introspection imports
ctrueden Apr 2, 2025
c8afba4
Shorten introspection to introspect
ctrueden Apr 2, 2025
6bfec82
Add toplevel docstrings to test files
ctrueden Apr 2, 2025
37bd92e
Fix naming of versions test file
ctrueden Apr 2, 2025
5f883f1
Fix type hints to work with Python 3.8
ctrueden Apr 2, 2025
6282d8c
CI: test Python 3.13 support
ctrueden Apr 2, 2025
bded14f
Rename find_java function to jreflect
ctrueden Apr 2, 2025
0778a89
Add missing is_j* type methods to README
ctrueden Apr 2, 2025
21ffae9
Use imperative tense for function docstrings
ctrueden Apr 2, 2025
bb06ed1
Wrap >88 lines, and make quoting more consistent
ctrueden Apr 2, 2025
553d552
Add introspection functions to the README
ctrueden Apr 2, 2025
bf2ee82
Improve get_version method
ctrueden Apr 24, 2025
2d44fed
Test a little further into the GitHub source paths
ctrueden Apr 24, 2025
8846ce5
Tweak management of multiple endpoints
ctrueden Apr 24, 2025
a31701b
Rename java_source method to jsource
ctrueden Apr 24, 2025
2713b6c
Make jreflect function more powerful
ctrueden Apr 24, 2025
92d7fb1
Split pretty-print functions to own subpackage
ctrueden Apr 25, 2025
30bd4d3
Hide non-public scijava.config attrs
ctrueden Apr 25, 2025
a537c00
Hide non-public scyjava.inspect attrs
ctrueden Apr 25, 2025
cea10cd
Use jimport naming convention for Java types
ctrueden Apr 25, 2025
3a46f1b
Make output writer configurable
ctrueden Apr 25, 2025
5fe1461
Replace print statements with logger calls
ctrueden Apr 25, 2025
2f11f0d
Add unit test for inspect.members function
ctrueden Apr 25, 2025
f4266c4
Ensure submodules are directly available
ctrueden Apr 25, 2025
1d9b507
Let jsource also find Java library source code
ctrueden Apr 25, 2025
5c06747
Be less aggressive with source code detection
ctrueden Apr 25, 2025
e5e9cab
Add test for jreflect constructors
ctrueden Apr 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add introspection functions to the README
  • Loading branch information
ctrueden committed Apr 2, 2025
commit 553d552a4316ac0229fa3ea1f01cf014f54ad477
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ FUNCTIONS
You can pass a single integer to make a 1-dimensional array of that length.
:return: The newly allocated array

java_source(data)
Try to find the source code using SciJava's SourceFinder.
:param data:
The object or class or fully qualified class name to check for source code.
:return: The URL of the java class

jclass(data)
Obtain a Java class object.

Expand Down Expand Up @@ -319,6 +325,14 @@ FUNCTIONS
:param jtype: The Java type, as either a jimported class or as a string.
:return: True iff the object is an instance of that Java type.

jreflect(data, aspect: str) -> List[Dict[str, Any]]
Use Java reflection to introspect the given Java object,
returning a table of its available methods or fields.

:param data: The object or class or fully qualified class name to inspect.
:param aspect: Either "methods" or "fields"
:return: List of dicts with keys: "name", "static", "arguments", and "returns".

jstacktrace(exc) -> str
Extract the Java-side stack trace from a Java exception.

Expand Down Expand Up @@ -427,6 +441,11 @@ FUNCTIONS

:raise RuntimeError: if this method is called while in Jep mode.

src(data)
Print the source code URL for a Java class, object, or class name.

:param data: The Java class, object, or fully qualified class name as string

start_jvm(options=None) -> None
Explicitly connect to the Java virtual machine (JVM). Only one JVM can
be active; does nothing if the JVM has already been started. Calling
Expand Down
Loading
0