Skip to content

Commit bded14f

Browse files
committed
Rename find_java function to jreflect
To me, the name `find_java` suggests we will be locating a JVM installation, rather than "finding" information about Java objects. The information doesn't need to be "found" or "located", but rather only introspected or interrogated. Technically, I suppose "introspection" implies read/access while "reflection" implies write/mutation, but `jintrospect` is rather clunky, whereas the term "reflection" is widely known in both Java and Python circles.
1 parent 6282d8c commit bded14f

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/scyjava/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
from ._introspect import (
9595
attrs,
9696
fields,
97-
find_java,
9897
java_source,
98+
jreflect,
9999
methods,
100100
src,
101101
)

src/scyjava/_introspect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
from scyjava._types import isjava, jinstance, jclass
1010

1111

12-
def find_java(data, aspect: str) -> List[Dict[str, Any]]:
12+
def jreflect(data, aspect: str) -> List[Dict[str, Any]]:
1313
"""
1414
Use Java reflection to introspect the given Java object,
15-
returning a table of its available methods.
15+
returning a table of its available methods or fields.
1616
1717
:param data: The object or class or fully qualified class name to inspect.
1818
:param aspect: Either 'methods' or 'fields'
@@ -152,7 +152,7 @@ def _print_data(data, aspect, static: Optional[bool] = None, source: bool = True
152152
:param static: Boolean filter on Static or Instance methods. Optional, default is None (prints all).
153153
:param source: Whether to print any available source code. Default True.
154154
"""
155-
table = find_java(data, aspect)
155+
table = jreflect(data, aspect)
156156
if len(table) == 0:
157157
print(f"No {aspect} found")
158158
return

tests/test_introspect.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ class TestIntrospection(object):
1717
Test introspection functionality.
1818
"""
1919

20-
def test_find_java_methods(self):
20+
def test_jreflect_methods(self):
2121
if mode == Mode.JEP:
2222
# JEP does not support the jclass function.
2323
return
2424
str_String = "java.lang.String"
2525
String = scyjava.jimport(str_String)
26-
str_Obj = scyjava.find_java(str_String, "methods")
27-
jimport_Obj = scyjava.find_java(String, "methods")
26+
str_Obj = scyjava.jreflect(str_String, "methods")
27+
jimport_Obj = scyjava.jreflect(String, "methods")
2828
assert len(str_Obj) > 0
2929
assert len(jimport_Obj) > 0
3030
assert jimport_Obj is not None
3131
assert jimport_Obj == str_Obj
3232

33-
def test_find_java_fields(self):
33+
def test_jreflect_fields(self):
3434
if mode == Mode.JEP:
3535
# JEP does not support the jclass function.
3636
return
3737
str_BitSet = "java.util.BitSet"
3838
BitSet = scyjava.jimport(str_BitSet)
39-
str_Obj = scyjava.find_java(str_BitSet, "fields")
40-
bitset_Obj = scyjava.find_java(BitSet, "fields")
39+
str_Obj = scyjava.jreflect(str_BitSet, "fields")
40+
bitset_Obj = scyjava.jreflect(BitSet, "fields")
4141
assert len(str_Obj) == 0
4242
assert len(bitset_Obj) == 0
4343
assert bitset_Obj is not None
@@ -61,7 +61,7 @@ def test_imagej_legacy(self):
6161
# JEP does not support the jclass function.
6262
return
6363
str_RE = "ij.plugin.RoiEnlarger"
64-
table = scyjava.find_java(str_RE, aspect="methods")
64+
table = scyjava.jreflect(str_RE, aspect="methods")
6565
assert len([entry for entry in table if entry["static"]]) == 3
6666
github_home = "https://github.com/"
6767
assert scyjava.java_source(str_RE).startsWith(github_home)

0 commit comments

Comments
 (0)