Works "out of the box"!
As an example, try a few test cases. Consult (using consult/1) the following from SWI-Prolog toplevel:
and run the
plunit test cases:
?- run_tests. % PL-Unit: jpl % Java Version: 14.0.1 ... % Obtained Java GregorianCalendar = <jref>(0x201c060) % Object is of Class <jref>(0x1ffa300) % Class <jref>(0x1ffa300) has name 'java.util.GregorianCalendar' % Class <jref>(0x201bfc8) has name 'java.util.Calendar' % Class <jref>(0x1fd4718) has name 'java.lang.Object' ... done % All 6 tests passed true.
A semi-complete diagram I made on
A diagram on
used in JPL, made while refreshing the JPL Prolog-side code showing:
- JPL types, which are Prolog terms describing a Java type ;
- Java Entity Names, which are strings (atoms in JPL) describing a Java type: a reference type (concrete or abstract class or interface), in which case this is the Java classname, an array type or a primitive ;
- Java Type Descriptors, which are strings (atoms in JPL) describing a Java type, but slightly differently than for Java Entity Names ;
- JNI Findclassname Descriptors, which are strings (atoms in JPL) given to the JNI function FindClass so that it may load/find the corresponding instance of
- Java Method Descriptors, which are strings (atoms in JPL) describing a Java Method signature. These are based on Java Type Descriptors.
The current distribution is not yet based on this (soon!).
For a description of the Entity Name, see
java.lang.Class.getName() which returns one of those:
For the **'binary' classname**, i.e. the classname as used in binary files, having package names with "." separators, see:
For a description of the descriptors as used by the JNI function FindClass, which takes package names with "/" separators, see:
- JavaDoc for Java 14
- Oracle Tutorial Java Glossary (does not contain Lambda yet ... which appeared in Java 8, i.e. 2014 🧐)
- Documentation for JNI in Java 14
- There are two old-ish books:
- "Essential JNI Java Native Interface" by Rob Gordon, Prentice-Hall, 1998
- "The Java Native Interface, Programmer's Guide and Specification" by Sheng Liang, Addison-Wesley, 1999
1998 is when JDK 1.1 was the current version, Michael Franz of UC Irvine wrote "The JVM: A Passing Fad?" in IEEE Software of Nov/Dec and Harold Lawson wrote "From Busyware to Stableware" in IEEE Software of Oct. But I digress.
Grouping the JPL predicates
Create a new instance
Call a class or instance method
Call a getter/setter or get/set a field member
JVM option handling
What syntax are we using Prolog side (when is this used?)
Version of JPL or the C part
(confusing, needs a little ASCII diagram or something)
What do we have here
(Maybe simpler as
- and jpl_ref_to_type/2