Skip to content

Commit bd132cf

Browse files
committed
update docs and changelog
1 parent 5e7c3e7 commit bd132cf

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
This changelog summarizes major changes between GraalVM versions of the Python
44
language runtime. The main focus is on user-observable behavior of the engine.
55

6+
## Version 1.0.0 RC7
7+
8+
* Enhance the `java` interop builtin module with introspection utility methods
9+
610
## Version 1.0.0 RC6
711

812
* Support regular expression patterns built from bytes by using CPython's sre module as a fallback engine to our own

doc/INTEROP.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,28 @@ byteArray = myBigInt.toByteArray()
6262
print(list(byteArray)) # Java arrays can act like Python lists
6363
```
6464

65+
In addition to the `type` builtin method, the `java` module, exposes the following
66+
methods as well:
67+
68+
Builtin | Specification
69+
--- | ---
70+
`instanceof(obj, class)` | returns `True` if `obj` is an instance of `class` (`class` must be a foreign object class)
71+
`is_function(obj)` | returns `True` if `obj` is a Java host language function wrapped using Truffle interop
72+
`is_object(obj)` | returns `True` if `obj` if the argument is Java host language object wrapped using Truffle interop
73+
`is_symbol(obj)` | returns `True` if `obj` if the argument is a Java host symbol, representing the constructor and static members of a Java class, as obtained by `java.type`
74+
75+
```python
76+
import java
77+
ArrayList = java.type('java.util.ArrayList')
78+
my_list = ArrayList()
79+
print(java.is_symbol(ArrayList)) # prints True
80+
print(java.is_symbol(my_list)) # prints False, my_list is not a Java host symbol
81+
print(java.is_object(ArrayList)) # prints True, symbols are also host objects
82+
print(java.is_function(my_list.add))# prints True, the add method of ArrayList
83+
print(java.instanceof(my_list, ArrayList)) # prints True
84+
```
85+
86+
6587
#### Python responses to Truffle interop messages
6688

6789
###### READ

0 commit comments

Comments
 (0)