remove duplicated jpl
This commit is contained in:
parent
6e2260471a
commit
a9f02dddca
@ -1,68 +0,0 @@
|
||||
#CHECK: JavaLibs
|
||||
|
||||
set (JPL_SOURCES
|
||||
src/c/jpl.c)
|
||||
|
||||
macro_optional_find_package(Java ON)
|
||||
find_package(Java COMPONENTS Development)
|
||||
#find_package(Java COMPONENTS Runtime)
|
||||
macro_log_feature (Java_Development_FOUND "Java"
|
||||
"Use Java System"
|
||||
"http://www.java.org" FALSE)
|
||||
|
||||
if (Java_Development_FOUND)
|
||||
# Java_JAVA_EXECUTABLE = the full path to the Java runtime
|
||||
# Java_JAVAC_EXECUTABLE = the full path to the Java compiler
|
||||
# Java_JAVAH_EXECUTABLE = the full path to the Java header generator
|
||||
# Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator
|
||||
# Java_JAR_EXECUTABLE = the full path to the Java archiver
|
||||
# Java_VERSION_STRING = Version of java found, eg. 1.6.0_12
|
||||
# Java_VERSION_MAJOR = The major version of the package found.
|
||||
# Java_VERSION_MINOR = The minor version of the package found.
|
||||
# Java_VERSION_PATCH = The patch version of the package found.
|
||||
# Java_VERSION_TWEAK = The tweak version of the package found (after '_')
|
||||
# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak)
|
||||
# JAVA_LIBRARIES - path to the java library
|
||||
# JAVA_INCLUDE_PATH - path to where Java.h is found (deprecated)
|
||||
# JAVA_INCLUDE_DIRS - path to where Java.h is found
|
||||
# JAVA_DEBUG_LIBRARIES - path to the debug library (deprecated)
|
||||
# JAVALIBS_VERSION_STRING - version of the Java libs found (since CMake 2.8.8)
|
||||
#
|
||||
#
|
||||
#
|
||||
# The Java_ADDITIONAL_VERSIONS variable can be used to specify a list
|
||||
# of version numbers that should be taken into account when searching
|
||||
# for Java. You need to set this variable before calling
|
||||
# find_package(JavaLibs).
|
||||
#
|
||||
macro_optional_find_package(JNI ON)
|
||||
# JNI_INCLUDE_DIRS = the include dirs to use
|
||||
# JNI_LIBRARIES = the libraries to use
|
||||
# JNI_FOUND = TRUE if JNI headers and libraries were found.
|
||||
# JAVA_AWT_LIBRARY = the path to the jawt library
|
||||
# JAVA_JVM_LIBRARY = the path to the jvm library
|
||||
# JAVA_INCLUDE_PATH = the include path to jni.h
|
||||
# JAVA_INCLUDE_PATH2 = the include path to jni_md.h
|
||||
# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
|
||||
|
||||
add_library (jplYap SHARED src/c/jpl.c)
|
||||
|
||||
add_subdirectory (src/java)
|
||||
|
||||
include_directories (${JAVA_INCLUDE_DIRS} ${JNI_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(jplYap libYap ${JAVA_LIBRARIES} ${JNI_LIBRARIES})
|
||||
|
||||
set_target_properties(jplYap PROPERTIES
|
||||
OUTPUT_NAME jpl )
|
||||
|
||||
install(TARGETS jplYap
|
||||
LIBRARY DESTINATION ${dlls}
|
||||
)
|
||||
|
||||
install(FILES jpl.pl
|
||||
DESTINATION ${libpl}
|
||||
)
|
||||
|
||||
|
||||
endif (Java_Development_FOUND)
|
@ -1,105 +0,0 @@
|
||||
[May 21 2008]
|
||||
|
||||
* Enhanced: Bug#247: build test only conditionally. Keri Harris.
|
||||
|
||||
Nov 28, 2006
|
||||
|
||||
* PORT: Bug#357: Updated config.{guess,sub}, needed for development
|
||||
version of FC. Mary Ellen Foster.
|
||||
|
||||
[Jan 30 2008]
|
||||
|
||||
* FIXED: Bug#347: JPL pointer conversion. Mary Ellen Foster.
|
||||
See remark with the bug-report for further info.
|
||||
|
||||
[Jan 23 2008]
|
||||
|
||||
* PORT: Bug#346: Allow overriding COFLAGS and CWFLAGS in package
|
||||
configuration. Keri Harris.
|
||||
Oct 23, 2007
|
||||
|
||||
* ADDED: On Windows, automatically find the JRE is the SDK is not present.
|
||||
Ilmars Poikans.
|
||||
|
||||
Aug 8, 2007
|
||||
|
||||
* FIXED: JRef handling on 64-bit non-Windows platforms.
|
||||
Fixed by Paul Singleton.
|
||||
|
||||
May 24, 2007
|
||||
|
||||
* FIXED: (JW) Exchange of codes 128..255. Lorenz Wallner.
|
||||
|
||||
Mar 16, 2007
|
||||
|
||||
* INSTALL: Really do not require plunit fro normal distribution.
|
||||
|
||||
Apr. 24, 2007
|
||||
|
||||
* FIXED: Bug#263. Crash in 64-bit version. Fixed by Paul Singleton.
|
||||
|
||||
Feb 28, 2007
|
||||
|
||||
* FIXED: Bug#260: errornous integer check. Keri Harris.
|
||||
|
||||
Nov 23, 2006
|
||||
|
||||
* NEW: Integrated Paul Singletons changes. Added test-cases, cleanup
|
||||
of installation, etc. Joint effort of Paul Singleton and Jan Wielemaker.
|
||||
|
||||
Nov 8, 2006
|
||||
|
||||
* PORT: Started work on support for 64-bit linux. Jan Wielemaker.
|
||||
|
||||
Jul 31, 2006
|
||||
|
||||
* CONFIG: Add support for IBM java and Linux/PPC. Keri Harris.
|
||||
|
||||
Jan 31, 2006
|
||||
|
||||
* CONFIG: Windows-XP configure problem on amd64. Keri Harris.
|
||||
|
||||
Oct 28, 2004
|
||||
|
||||
* CONFIG: Bug#197: Handle absolute path for JAVAC. Owen Cliffe.
|
||||
|
||||
Sep 28, 2004
|
||||
|
||||
* CONFIG: Force the use of javac (Sun Java) in configure if nothing is
|
||||
specified by the user.
|
||||
|
||||
May 27, 2004
|
||||
|
||||
* CLEANUP: Made Test2 example stand-alone rather than relying on things
|
||||
wired into jpl.jar and jpl.pl (removed support from there).
|
||||
|
||||
May 26, 2004
|
||||
|
||||
* ADDED: examples/java/SemWeb: Using the SWI-Prolog semantic web library
|
||||
(rdf_db.pl) from Java.
|
||||
|
||||
May 25, 2004
|
||||
|
||||
* ENHANCED: Also use the default engine. This means no engines are created
|
||||
if they are not needed.
|
||||
|
||||
* ENHANCED: Initially only make a single engine. Make upto 10 as they
|
||||
are needed. (JW)
|
||||
|
||||
May 24, 2004
|
||||
|
||||
* ADDED: Initial test suite (check.pl) (JW)
|
||||
|
||||
May 14, 2004
|
||||
|
||||
* JW: Added Makefile for jpl.jar
|
||||
* jpl.c: changed Sprintf() to DEBUG(level, Sdprintf())
|
||||
* exceptions: generate error(java_exception(Ex), ClassName). Provide
|
||||
hook for normal readable error messages.
|
||||
|
||||
May 12, 2004
|
||||
|
||||
* JW: Removed jpl_demo/0
|
||||
* JW: Included library(lists) and removed list predicates
|
||||
* JW: Cleanup of is_pairs/1 and is_pair/1.
|
||||
|
@ -1,58 +0,0 @@
|
||||
ELF systems and libpl.so
|
||||
========================
|
||||
|
||||
On Unix systems, SWI-Prolog is normally compiled as an application and
|
||||
static library (lib/$PLARCH/libpl.a). First of all this is easier ported
|
||||
on may Unix systems and second, shared object require position
|
||||
independent code (-fpic) and this is (depending on the processor)
|
||||
generally slower than application code running at a fixed address.
|
||||
|
||||
We link jpl.so using -lpl, so it is linked to the dynamic libpl.so if
|
||||
Prolog is configured using -enable-shared or to the static libpl.a
|
||||
otherwise. On ELF systems that can handle position-dependent (i.e.
|
||||
compiled _without_ -fpic) code in shared objects this works fine. If
|
||||
libjpl.so is loaded directly from Java it will use the Prolog kernel
|
||||
included in libjpl.so. If it is invoked through Prolog, the Prolog
|
||||
application is before libjpl.so in the ELF search path and therefore all
|
||||
Prolog symbols are resolved against the application.
|
||||
|
||||
There are two drawbacks to this approach. The libjpl.so file could have
|
||||
been a small and version independent library, while it is now bulky due
|
||||
to the embedded Prolog engine and version dependent.
|
||||
|
||||
Summarising, if your OS cannot load position dependent .so files you
|
||||
MUST configure SWI-Prolog using --enable-shared. If it can (Linux), the
|
||||
choice is yours and depends on the performance penalty paid on your
|
||||
processor (approx. 7% on an AMD Athon), how you wish to arrange
|
||||
versioning and how keen you are on memory sharing.
|
||||
|
||||
|
||||
Installed components (Unix)
|
||||
===========================
|
||||
|
||||
Make install installs the following components:
|
||||
|
||||
* $PLBASE/library/jpl.pl
|
||||
* $PLBASE/lib/jpl.jar
|
||||
* $PLBASE/lib/$PLARCH/libjpl.so
|
||||
|
||||
The disadvantage of this is that $PLBASE/lib/$PLARCH must be in
|
||||
$LD_LIBRARY_PATH to be able to call Prolog from Java (either when
|
||||
embedding Prolog in Java or using a Prolog -> Java -> Prolog callback).
|
||||
Unfortunately all the other Prolog .so files are loaded by explicitely
|
||||
searching for them.
|
||||
|
||||
|
||||
Finding Java on Windows
|
||||
=======================
|
||||
|
||||
It appears the following keys are relevant for SUN SDK:
|
||||
|
||||
?- win_registry_get_value('HKEY_LOCAL_MACHINE/Software/JavaSoft/Java Development Kit',
|
||||
'CurrentVersion', X).
|
||||
|
||||
X = 1.4
|
||||
|
||||
?- win_registry_get_value('HKEY_LOCAL_MACHINE/Software/JavaSoft/Java Development Kit/1.4', 'JavaHome', X).
|
||||
|
||||
X = 'C:\\j2sdk1.4.2_04'
|
@ -1,196 +0,0 @@
|
||||
################################################################
|
||||
# @configure_input@
|
||||
#
|
||||
# Build JPL. Building JPL for Unix currently relies on the following
|
||||
# assumptions:
|
||||
#
|
||||
# * $JAVA_HOME points to the JDK top directory
|
||||
# * $PATH includes $JAVA_HOME/bin
|
||||
# * ELF Dynamic Linker semantics
|
||||
#
|
||||
# Author: Jan Wielemaker, based on shell-scripts from Paul Singleton.
|
||||
################################################################
|
||||
|
||||
PACKAGE=jpl
|
||||
PKGCFLAGS=@JPLCFLAGS@
|
||||
PKGLDFLAGS=@JPLLDFLAGS@
|
||||
|
||||
include ../Makefile.defs
|
||||
|
||||
LIBS=@LIBS@
|
||||
|
||||
JAVA_HOME=@JAVA_HOME@
|
||||
JAVAC=@JAVAC@
|
||||
JAVACFLAGS=@JAVACFLAGS@
|
||||
JAVA=@JAVA@
|
||||
JUNIT=@JUNIT@
|
||||
JAVALIBS=@JAVALIBS@
|
||||
|
||||
LIBPL= $(srcdir)/jpl.pl
|
||||
LIBJPL= @LIBJPL@.@SO@
|
||||
TARGETS= $(LIBJPL)
|
||||
OBJ= src/c/jpl.o
|
||||
|
||||
# YAP has some extra hacks that need to be compiled in.
|
||||
ifeq (@PROLOG_SYSTEM@,yap)
|
||||
src/c/jpl.o: $(srcdir)/src/c/jpl.c $(srcdir)/src/c/hacks.c
|
||||
$(CC) -c $(CFLAGS) $(srcdir)/src/c/jpl.c -o src/c/jpl.o
|
||||
endif
|
||||
|
||||
all: $(TARGETS) jpl.jar exjava-compile jpl_doc
|
||||
|
||||
# linking order counts here: otherwise libjpl.so will not remember
|
||||
# it needs libYap.so
|
||||
@LIBJPL@.@SO@: $(OBJ)
|
||||
$(LD) $(LDSOFLAGS) -o $@ $(OBJ) $(LIBS) $(JAVALIBS) $(LIBPLEMBED)
|
||||
if [ -r @LIBJPL@.@SO@ ]; then \
|
||||
rm -f @LIBJPL@.jnilib && ln -s @LIBJPL@.@SO@ @LIBJPL@.jnilib ; \
|
||||
fi
|
||||
|
||||
jpl.jar::
|
||||
(cd src/java && $(MAKE) jpl_jar)
|
||||
jpl_doc::
|
||||
(cd src/java && $(MAKE) jpl_doc)
|
||||
|
||||
################################################################
|
||||
# Verify the package
|
||||
################################################################
|
||||
|
||||
check: check_pl check_java
|
||||
|
||||
check_pl: jpltest.jar
|
||||
$(PL) -q -f test_jpl.pl -g run_tests,halt -t 'halt(1)'
|
||||
check_java: jpltest.jar
|
||||
JUNIT=$(JUNIT) JAVA=$(JAVA) JAVA_PRELOAD=$(JAVA_PRELOAD) $(srcdir)/test-java.sh
|
||||
|
||||
jpltest.jar:
|
||||
(cd src/java && $(MAKE) test_jar)
|
||||
|
||||
################################################################
|
||||
# Installation
|
||||
################################################################
|
||||
|
||||
DOCDIRS= $(srcdir) $(srcdir)/java_api \
|
||||
$(srcdir)/java_api/javadoc $(srcdir)/java_api/javadoc/jpl \
|
||||
$(srcdir)/java_api/javadoc/jpl/class-use \
|
||||
$(srcdir)/java_api/javadoc/jpl/fli \
|
||||
$(srcdir)/java_api/javadoc/jpl/fli/class-use \
|
||||
$(srcdir)/java_api/javadoc/resources \
|
||||
$(srcdir)/prolog_api \
|
||||
$(srcdir)/prolog_api/overview
|
||||
DOCFILES= $(shell cd $(srcdir)/docs && find . -name '*.html' -o -name '*.gif' -o -name '*.jpg')
|
||||
|
||||
EXPL= $(PKGEXDIR)/jpl/prolog
|
||||
EXPLS= jpl_colour_choose_demo.pl \
|
||||
jpl_jlist_demo.pl \
|
||||
jpl_midi_demo.pl \
|
||||
jpl_table_demo.pl \
|
||||
jpl_text_entry_demo.pl \
|
||||
jpl_versions_demo.pl
|
||||
EXJAVA= $(PKGEXDIR)/jpl/java
|
||||
EXJAVAS= Exceptions Exceptions2 Family FamilyMT Test Test2 Time \
|
||||
Versions Zahed SemWeb
|
||||
|
||||
|
||||
install: all $(LIBPL)
|
||||
mkdir -p $(DESTDIR)$(SOLIBDIR)
|
||||
for f in $(TARGETS); do \
|
||||
$(INSTALL_PROGRAM) "$$f" "$(DESTDIR)$(SOLIBDIR)"; \
|
||||
done
|
||||
ifeq (@SO@,dylib)
|
||||
(cd $(DESTDIR)$(SOLIBDIR) && ln -sf @LIBJPL@.@SO@ @LIBJPL@.jnilib)
|
||||
endif
|
||||
mkdir -p $(DESTDIR)$(PLLIBDIR)
|
||||
mkdir -p $(DESTDIR)$(PLLIBDIR)/jpl
|
||||
for f in $(LIBPL); do \
|
||||
$(INSTALL_DATA) $$f $(DESTDIR)$(PLLIBDIR); \
|
||||
done
|
||||
$(INSTALL_DATA) jpl.jar $(DESTDIR)$(PLLIBDIR)/jpl
|
||||
$(PL) -f none -g make -t halt
|
||||
mkdir -p "$(DESTDIR)$(PLLIBDIR)"
|
||||
for f in $(LIBPL); do \
|
||||
$(INSTALL_DATA) $$f $(DESTDIR)$(PLLIBDIR); \
|
||||
done
|
||||
$(MKINDEX)
|
||||
|
||||
install-examples::
|
||||
expl-install exjava-install
|
||||
|
||||
ln-install::
|
||||
@$(MAKE) INSTALL_DATA='../ln-install' install
|
||||
|
||||
rpm-install: install html-install
|
||||
|
||||
html-install:: expl-install exjava-install
|
||||
mkdir -p $(DESTDIR)$(PKGDOCDIR)/jpl
|
||||
@printf "Creating directories "
|
||||
@for d in $(DOCDIRS); do \
|
||||
mkdir -p $(DESTDIR)$(PKGDOCDIR)/jpl/$$d; printf "."; \
|
||||
done
|
||||
@echo "ok"
|
||||
@printf "Copying documentation files "
|
||||
@for f in $(DOCFILES); do \
|
||||
$(INSTALL_DATA) docs/$$f $(DESTDIR)$(PKGDOCDIR)/jpl/$$f; printf "."; \
|
||||
done
|
||||
@echo "ok"
|
||||
|
||||
expl-install::
|
||||
echo "Installing Prolog examples"
|
||||
mkdir -p $(DESTDIR)$(EXPL)
|
||||
@for f in $(EXPLS) README; do \
|
||||
$(INSTALL_DATA) $(srcdir)/examples/prolog/$$f $(DESTDIR)$(EXPL)/$$f; \
|
||||
done
|
||||
|
||||
exjava-compile: jpl.jar
|
||||
echo "Compiling Java examples"
|
||||
for d in $(EXJAVAS); do \
|
||||
if [ ! -f examples/java/$$d/$$d.class ]; then \
|
||||
echo $$d; \
|
||||
mkdir -p examples/java/$$d; \
|
||||
(cd examples/java/$$d && "$(JAVAC)" $(JAVACFLAGS) -d . -classpath "../../../jpl.jar" $(srcdir)/examples/java/$$d/$$d.java); \
|
||||
fi; \
|
||||
done
|
||||
|
||||
exjava-install: exjava-compile
|
||||
echo "Installing Java examples"
|
||||
mkdir -p "$(DESTDIR)$(EXJAVA)"
|
||||
$(INSTALL_DATA) $(srcdir)/examples/java/README "$(DESTDIR)$(EXJAVA)"
|
||||
$(INSTALL_DATA) $(srcdir)/examples/java/env.@CMDEXT@ "$(DESTDIR)$(EXJAVA)"
|
||||
for d in $(EXJAVAS); do \
|
||||
mkdir -p $(DESTDIR)$(EXJAVA)/$$d; \
|
||||
$(INSTALL_SCRIPT) $(srcdir)/examples/java/$$d/run.@CMDEXT@ "$(DESTDIR)$(EXJAVA)/$$d" ;\
|
||||
$(INSTALL_DATA) $(srcdir)/examples/java/$$d/README "$(DESTDIR)$(EXJAVA)/$$d" ;\
|
||||
$(INSTALL_DATA) $(srcdir)/examples/java/$$d/$$d.java "$(DESTDIR)$(EXJAVA)/$$d" ;\
|
||||
for f in $(srcdir)/examples/java/$$d/*.pl; do \
|
||||
$(INSTALL_DATA) "$$f" "$(DESTDIR)$(EXJAVA)/$$d"; \
|
||||
done ;\
|
||||
$(INSTALL_DATA) examples/java/$$d/$$d*.class $(DESTDIR)$(EXJAVA)/$$d ;\
|
||||
done
|
||||
$(INSTALL_DATA) $(srcdir)/examples/java/SemWeb/test.rdf "$(DESTDIR)$(EXJAVA)/SemWeb"
|
||||
|
||||
pdf-install::
|
||||
mkdir -p $(DESTDIR)$(PKGDOCDIR)
|
||||
$(INSTALL) -m 644 $(DOC).pdf "$(DESTDIR)$(PKGDOCDIR)"
|
||||
|
||||
uninstall::
|
||||
(cd $(PLBASE)/lib/$(PLARCH) && rm -f $(TARGETS))
|
||||
(cd $(PLBASE)/library && rm -f $(LIBPL))
|
||||
$(PL) -f none -g make -t halt
|
||||
|
||||
################################################################
|
||||
# Clean
|
||||
################################################################
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) *~ *.o *% a.out core config.log
|
||||
rm -f TestJPL.class
|
||||
find examples/java -name '*.class' -delete
|
||||
(cd src/java && $(MAKE) clean)
|
||||
|
||||
distclean: clean
|
||||
rm -rf autom4te.cache
|
||||
rm -f $(TARGETS) config.cache config.h config.status Makefile
|
||||
rm -f $(DOC).aux $(DOC).log $(DOC).out $(DOC).toc
|
||||
rm -rf html
|
||||
(cd src/java && $(MAKE) distclean)
|
||||
|
@ -1,119 +0,0 @@
|
||||
################################################################
|
||||
# Build the SWI-Prolog tabling package for MS-Windows
|
||||
#
|
||||
# Author: Jan Wielemaker
|
||||
#
|
||||
# Use:
|
||||
# nmake /f Makefile.mak
|
||||
# nmake /f Makefile.mak install
|
||||
################################################################
|
||||
|
||||
PLHOME=..\..
|
||||
!include ..\..\src\rules.mk
|
||||
JAVA="$(JAVA_HOME)\bin\java"
|
||||
|
||||
PKGDLL=jpl
|
||||
|
||||
EXDIR= $(PKGDOC)\examples\jpl
|
||||
EXPL= $(EXDIR)\prolog
|
||||
EXPLS= jpl_colour_choose_demo.pl \
|
||||
jpl_jlist_demo.pl \
|
||||
jpl_midi_demo.pl \
|
||||
jpl_table_demo.pl \
|
||||
jpl_text_entry_demo.pl \
|
||||
jpl_versions_demo.pl
|
||||
EXJAVA= $(EXDIR)\java
|
||||
EXJAVAS= Exceptions Exceptions2 Family FamilyMT Test Test2 Time \
|
||||
Versions Zahed SemWeb
|
||||
|
||||
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-I"$(JAVA_HOME)\include" \
|
||||
-I"$(JAVA_HOME)\include\win32"
|
||||
LIBS = $(LIBS) "$(JAVA_HOME)\lib\jvm.lib"
|
||||
|
||||
OBJ= src\c\jpl.obj
|
||||
|
||||
all: checkenv $(PKGDLL).dll jar
|
||||
|
||||
jar::
|
||||
chdir src\java & $(MAKE)
|
||||
|
||||
checkenv::
|
||||
@if not exist "$(JAVA_HOME)\lib\jvm.lib" \
|
||||
echo FATAL ERROR: No JAVA_HOME defined? && exit 1
|
||||
|
||||
$(PKGDLL).dll: $(OBJ)
|
||||
$(LD) /dll /out:$@ $(LDFLAGS) $(OBJ) $(PLLIB) $(LIBS)
|
||||
|
||||
!IF "$(CFG)" == "rt"
|
||||
install: idll
|
||||
!ELSE
|
||||
install: idll ilib
|
||||
!ENDIF
|
||||
|
||||
idll::
|
||||
copy $(PKGDLL).dll "$(BINDIR)"
|
||||
ilib::
|
||||
copy jpl.pl "$(PLBASE)\library"
|
||||
copy jpl.jar "$(PLBASE)\lib"
|
||||
$(MAKEINDEX)
|
||||
|
||||
html-install:: expl-install exjava-install
|
||||
@echo CVS > nocopy
|
||||
xcopy /Q /S /I /Y /EXCLUDE:nocopy docs "$(PKGDOC)\jpl"
|
||||
del nocopy
|
||||
|
||||
xpce-install::
|
||||
|
||||
expl-install::
|
||||
if not exist "$(EXDIR)/$(NULL)" $(MKDIR) "$(EXDIR)"
|
||||
if not exist "$(EXPL)/$(NULL)" $(MKDIR) "$(EXPL)"
|
||||
cd examples\prolog & \
|
||||
@for %f in ($(EXPLS)) do @copy %f "$(EXPL)"
|
||||
copy examples\prolog\README "$(EXPL)\README.TXT"
|
||||
|
||||
exjava-install::
|
||||
if not exist "$(EXDIR)/$(NULL)" $(MKDIR) "$(EXDIR)"
|
||||
if not exist "$(EXJAVA)/$(NULL)" $(MKDIR) "$(EXJAVA)"
|
||||
copy examples\java\README "$(EXJAVA)"\README.TXT
|
||||
copy examples\java\env.bat "$(EXJAVA)"
|
||||
for %f in ($(EXJAVAS)) do if not exist "$(EXJAVA)\%f\$(NULL)" mkdir "$(EXJAVA)\%f"
|
||||
for %f in ($(EXJAVAS)) do copy examples\java\%f\run.bat "$(EXJAVA)\%f
|
||||
for %f in ($(EXJAVAS)) do copy examples\java\%f\README "$(EXJAVA)\%f\README.txt
|
||||
for %f in ($(EXJAVAS)) do copy examples\java\%f\%f.java "$(EXJAVA)\%f
|
||||
for %f in ($(EXJAVAS)) do if exist examples\java\%f\*.pl copy examples\java\%f\*.pl "$(EXJAVA)\%f"
|
||||
copy examples\java\SemWeb\test.rdf "$(EXJAVA)\SemWeb"
|
||||
|
||||
uninstall::
|
||||
del "$(PLBASE)\bin\$(PKGDLL).dll"
|
||||
del "$(PLBASE)\library\jpl.pl"
|
||||
del "$(PLBASE)\lib\jpl.jar"
|
||||
$(MAKEINDEX)
|
||||
|
||||
################################################################
|
||||
# Verify the package
|
||||
################################################################
|
||||
|
||||
check: check_pl check_java
|
||||
|
||||
check_pl::
|
||||
"$(PLCON)" -q -f test_jpl.pl -g run_tests,halt -t 'halt(1)'
|
||||
check_java::
|
||||
set CLASSPATH=$(JUNIT);jpl.jar;jpltest.jar
|
||||
$(JAVA) junit.textui.TestRunner jpl.test.TestJUnit
|
||||
|
||||
################################################################
|
||||
# Cleanup
|
||||
################################################################
|
||||
|
||||
clean::
|
||||
if exist $(OBJ) del $(OBJ)
|
||||
if exist *.obj del *.obj
|
||||
if exist *~ del *~
|
||||
chdir src\java & $(MAKE) clean
|
||||
|
||||
distclean: clean
|
||||
-DEL *.dll *.lib *.exp *.pdb *.ilk 2>nul
|
||||
chdir src\java & $(MAKE) distclean
|
||||
|
@ -1,23 +0,0 @@
|
||||
# Compiling JPL for MacOS
|
||||
|
||||
Updated: Nov 5, 2013 for MacOS 10.9
|
||||
|
||||
# Using Apple's Java distribution
|
||||
|
||||
Somehow MacOS did not install the Java SDK correctly, so I ended up without
|
||||
jni.h. I did not find a resolution for that.
|
||||
|
||||
# Using Oracle's SDK
|
||||
|
||||
Download from
|
||||
|
||||
- http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
|
||||
|
||||
which installs
|
||||
|
||||
- /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
|
||||
|
||||
Set $JAVAPREFIX to
|
||||
|
||||
- /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin
|
||||
|
@ -1,152 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="CONTENT-TYPE"
|
||||
content="text/html; charset=windows-1252">
|
||||
<title>JPL 3.0 documentation home page</title>
|
||||
<meta name="GENERATOR" content="StarOffice 7 (Win32)">
|
||||
<meta name="AUTHOR" content="Paul Singleton">
|
||||
<meta name="CREATED" content="20040216;23081326">
|
||||
<meta name="CHANGEDBY" content="Paul Singleton">
|
||||
<meta name="CHANGED" content="20040216;23141923">
|
||||
</head>
|
||||
<body lang="en-US" dir="ltr">
|
||||
<h1><span style="font-style: italic;">JPL 3.x</span> documentation home
|
||||
page</h1>
|
||||
<hr>
|
||||
<h2>Introduction</h2>
|
||||
<p><b style="font-style: italic;">JPL 3.x</b> is a dynamic,
|
||||
bidirectional interface
|
||||
between <i>SWI-Prolog 5.2.0</i> or later and <i>Java 2</i>
|
||||
runtimes (see <a href="docs/objectives.html"><span
|
||||
style="font-weight: bold;"><span style="font-style: italic;">JPL 3.x</span>
|
||||
Objectives</span></a>). It offers two APIs: </p>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><span style="font-weight: bold;">Java
|
||||
API</span><i> (Java-calls-Prolog)</i>: this
|
||||
interface comprises public Java classes which support: </p>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;">constructing Java
|
||||
representations of Prolog terms and queries </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;">calling queries within <i>SWI-Prolog</i>
|
||||
engines </p>
|
||||
</li>
|
||||
<li>
|
||||
<p>retrieving (as Java representations of Prolog terms) any
|
||||
bindings created by a call </p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><span style="font-weight: bold;">Prolog
|
||||
API</span><i> (Prolog-calls-Java)</i>: this
|
||||
interface comprises Prolog library predicates which support: </p>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;">creating instances (objects) of
|
||||
Java classes (built-in and user-defined) </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;">calling methods of Java objects
|
||||
(and static methods of classes), perhaps returning values or object
|
||||
references </p>
|
||||
</li>
|
||||
<li>
|
||||
<p>getting and setting the values of fields of Java objects and
|
||||
classes </p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p style="margin-bottom: 0cm;">Calls to the two APIs can be nested,
|
||||
e.g. Java code can call Prolog predicates which call Java methods
|
||||
which call Prolog predicates etc. </p>
|
||||
<hr>
|
||||
<h2>Prerequisites</h2>
|
||||
<p><b><i>JPL 3.x</i></b> currently requires <i>SWI-Prolog 5.2.0</i>
|
||||
or later (it uses multi-threading FLI calls not available in older
|
||||
versions). If you are using <i>SWI-Prolog 5.1.X</i>, then
|
||||
you should probably upgrade to the latest stable <i>5.2.X</i>
|
||||
release. Support for earlier versions may be added in the
|
||||
future. </p>
|
||||
<p><b><i>JPL 3.x</i></b> currently requires a <i>Java 2</i>
|
||||
runtime (or development kit), and has been tested with
|
||||
Sun's <font face="monospace">jdk1.3.1_01</font>. </p>
|
||||
<p><b><i>JPL 3.x</i></b> contains a native library (<font
|
||||
face="monospace">jpl.c</font>)
|
||||
written in <i>ANSI/ISO C</i> and designed to be portable to many
|
||||
operating system platforms for which suitable compilers are
|
||||
available. It has, however, only been tested with <i>Microsoft
|
||||
Visual C/C++ 5</i> under <i>Windows NT 4.0 (SP6a)</i>. I
|
||||
shall be grateful if anyone can (show me how to) tidily adapt the
|
||||
source and makefiles to build for other platforms. </p>
|
||||
<hr>
|
||||
<h2>Documentation</h2>
|
||||
<p>This alpha release of <b><i>JPL 3.x</i></b> contains a
|
||||
hotch-potch of documentation, some left over from Fred Dushin's
|
||||
(Java-calls-Prolog)<i> JPL 1.0.1</i> and now obsolete or misleading,
|
||||
some rewritten for <i>JPL 2.0.2</i> and still mostly applicable,
|
||||
and some written for the first release of my Prolog-calls-Java
|
||||
interface, now part of <b><i>JPL</i></b>, and also mostly still
|
||||
relevant.<br>
|
||||
</p>
|
||||
<p>In addition to this document (index.html in jpl's root folder) there
|
||||
are:<br>
|
||||
</p>
|
||||
<ul>
|
||||
<li><a href="docs/release_notes.html"><b>Release Notes</b></a><b>
|
||||
for 3.0.3, 3.0.2, 3.0.0 and 2.0.2</b></li>
|
||||
<li><a href="docs/installation.html"><b>Installation</b></a></li>
|
||||
<li><b>Java API:<br>
|
||||
</b></li>
|
||||
<ul>
|
||||
<li><a href="docs/java_api/javadoc/index.html"><b>Reference
|
||||
(Javadoc)</b></a></li>
|
||||
<li><a href="docs/java_api/high-level_interface.html"><span
|
||||
style="font-weight: bold;">Overview</span></a></li>
|
||||
<li><b><a href="docs/java_api/gotchas.html"><b>Gotchas</b></a></b></li>
|
||||
<li><b><a href="docs/java_api/getting_started.html"><b>Getting
|
||||
Started</b></a></b></li>
|
||||
</ul>
|
||||
<li><b><b>Prolog API:</b></b></li>
|
||||
<ul>
|
||||
<li><a href="docs/prolog_api/api.html"><span
|
||||
style="font-weight: bold;">Reference</span></a></li>
|
||||
<li><a href="docs/prolog_api/overview/index.html"><b>Overview</b></a></li>
|
||||
<li><a href="docs/prolog_api/gotchas.html"><b>Gotchas</b></a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<p> </p>
|
||||
<hr>
|
||||
<h2>Installation</h2>
|
||||
<p>Put the three library files (<var>jpl.dll</var>, <var>jpl.jar</var>
|
||||
and <var>jpl.pl</var>) where they can be found by your OS, by your
|
||||
Java apps and by SWI-Prolog respectively; for details, see <a
|
||||
href="docs/installation.html"><b><i>JPL
|
||||
3.x</i> Installation</b></a>.</p>
|
||||
<hr>
|
||||
<h2>Testing</h2>
|
||||
<p>Each of the folders within <font face="monospace">jpl\examples\java</font>
|
||||
contains a simple <i>Java </i>application which tests some
|
||||
aspect of <b><i>JPL</i></b>. These applications are
|
||||
already compiled, and each folder contains a (<i>DOS/Windows</i>)
|
||||
script <font face="monospace">run.bat</font> which announces and
|
||||
runs the demo.<br>
|
||||
<br>
|
||||
Each of the Prolog source files within <span
|
||||
style="font-family: monospace;">jpl/examples/prolog</span> contains a
|
||||
self-contained Prolog application which exercises JPL from within
|
||||
Prolog; start an interactive SWI-Prolog session as usual, and then
|
||||
consult and run these files.<br>
|
||||
</p>
|
||||
<hr>
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>February 2004</address>
|
||||
</body>
|
||||
</html>
|
@ -1,150 +0,0 @@
|
||||
dnl Modified by Peter Green <plugwash@p10link.net> to correct include paths
|
||||
dnl with OpenJDK on all architectures other than i386 and amd64
|
||||
|
||||
|
||||
dnl Original version is available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_jni_include_dirs.html
|
||||
dnl
|
||||
|
||||
|
||||
AC_DEFUN([AC_JNI_INCLUDE_DIR],[
|
||||
|
||||
JNI_INCLUDE_DIRS=""
|
||||
|
||||
if test "x$JAVAPREFIX" = x; then
|
||||
test "x$JAVAC" = x && AC_MSG_ERROR(['$JAVAC' undefined])
|
||||
|
||||
case "$JAVAC" in
|
||||
/*) _ACJNI_JAVAC="$JAVAC"
|
||||
;;
|
||||
*) AC_PATH_PROG(_ACJNI_JAVAC, $JAVAC, no)
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_PATH_PROG(_ACJNI_JAVAC, $JAVAC, no)
|
||||
test "x$_ACJNI_JAVAC" = xno && AC_MSG_ERROR([$JAVAC could not be found in path])
|
||||
|
||||
_ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC")
|
||||
_JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'`
|
||||
else
|
||||
_JTOPDIR="$(dirname "$JAVAPREFIX")"
|
||||
fi
|
||||
|
||||
found=no
|
||||
while test $found = no; do
|
||||
if test -f "$_JTOPDIR/include/jni.h"; then
|
||||
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include"
|
||||
_JINC="$_JTOPDIR/include"
|
||||
found=yes
|
||||
elif test -f "$_JTOPDIR/Headers/jni.h"; then
|
||||
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/Headers"
|
||||
_JINC="$_JTOPDIR/Headers"
|
||||
found=yes
|
||||
elif test -f "$_JTOPDIR/Contents/Home/include/jni.h"; then
|
||||
_JTOPDIR="$_JTOPDIR/Contents/Home"
|
||||
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include"
|
||||
_JINC="$_JTOPDIR/include"
|
||||
found=yes
|
||||
else
|
||||
_JTOPDIR2=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
|
||||
if test "$_JTOPDIR2" = "$_JTOPDIR"; then
|
||||
AC_MSG_ERROR([cannot find java include files])
|
||||
found=oops
|
||||
else
|
||||
_JTOPDIR="$_JTOPDIR2"
|
||||
_JINC="$_JTOPDIR2/include"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
AC_MSG_RESULT(_JTOPDIR="$_JTOPDIR")
|
||||
|
||||
# get the likely subdirectories for system specific java includes
|
||||
case "$host_os" in
|
||||
bsdi*) _JNI_INC_SUBDIRS="bsdos";;
|
||||
linux*) _JNI_INC_SUBDIRS="linux genunix";;
|
||||
mingw32*) _JNI_INC_SUBDIRS="win32";;
|
||||
osf*) _JNI_INC_SUBDIRS="alpha";;
|
||||
solaris*) _JNI_INC_SUBDIRS="solaris";;
|
||||
darwin*) _JNI_INC_SUBDIRS="darwin genunix";;
|
||||
*) _JNI_INC_SUBDIRS="genunix";;
|
||||
esac
|
||||
|
||||
# add any subdirectories that are present
|
||||
for JINCSUBDIR in $_JNI_INC_SUBDIRS
|
||||
do
|
||||
if test -d "$_JINC/$JINCSUBDIR"; then
|
||||
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC/$JINCSUBDIR"
|
||||
fi
|
||||
done
|
||||
|
||||
case "$host_os" in
|
||||
mingw32*) JNI_CLIENT_DIRS="$_JTOPDIR/lib $_JTOPDIR/jre/bin $_JTOPDIR/jre/bin/server"
|
||||
;;
|
||||
|
||||
*) case "$host_cpu" in
|
||||
i?86)
|
||||
_JNI_LIBDIRS="lib/i386 lib/amd64 lib"
|
||||
_JNI_LIBSUBDIRS="server client"
|
||||
;;
|
||||
x86_64)
|
||||
_JNI_LIBDIRS="lib/amd64"
|
||||
_JNI_LIBSUBDIRS="server"
|
||||
;;
|
||||
powerpc)
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
_JNI_LIBDIRS="lib/ppc bin"
|
||||
_JNI_LIBSUBDIRS="server classic"
|
||||
;;
|
||||
*)
|
||||
_JNI_LIBDIRS=""
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Fallback option should work on all architectures except
|
||||
# amd64 and powerpc which are special cased above.
|
||||
_JNI_LIBDIRS="lib/$host_cpu"
|
||||
_JNI_LIBSUBDIRS="server"
|
||||
esac
|
||||
|
||||
for d in $_JNI_LIBDIRS; do
|
||||
for subd in $_JNI_LIBSUBDIRS; do
|
||||
echo "Trying $_JTOPDIR/jre/$d/$subd"
|
||||
if test -d $_JTOPDIR/jre/$d/$subd; then
|
||||
JNI_CLIENT_DIRS="$JNI_CLIENT_DIRS $_JTOPDIR/jre/$d/$subd $_JTOPDIR/jre/$d"
|
||||
case "$target_os" in
|
||||
*linux*)
|
||||
JAVALIBS="$JAVALIBS -Wl,-R$_JTOPDIR/jre/$d/$subd -Wl,-R$_JTOPDIR/jre/$d"
|
||||
;;
|
||||
**)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
;;
|
||||
esac
|
||||
|
||||
])
|
||||
|
||||
# _ACJNI_FOLLOW_SYMLINKS <path>
|
||||
# Follows symbolic links on <path>,
|
||||
# finally setting variable _ACJNI_FOLLOWED
|
||||
# --------------------
|
||||
AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[
|
||||
# find the include directory relative to the javac executable
|
||||
_cur="$1"
|
||||
while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
|
||||
AC_MSG_CHECKING(symlink for $_cur)
|
||||
_slink=`ls -ld "$_cur" | sed 's/.* -> //'`
|
||||
case "$_slink" in
|
||||
/*) _cur="$_slink";;
|
||||
# 'X' avoids triggering unwanted echo options.
|
||||
*) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
|
||||
esac
|
||||
AC_MSG_RESULT($_cur)
|
||||
done
|
||||
_ACJNI_FOLLOWED="$_cur"
|
||||
])# _ACJNI
|
@ -1,15 +0,0 @@
|
||||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_jar.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAR],[
|
||||
AC_REQUIRE([AC_EXEEXT])dnl
|
||||
if test "x$JAR" = x; then
|
||||
if test "x$JAVAPREFIX" = x; then
|
||||
AC_CHECK_PROGS(JAR, jar$EXEEXT)
|
||||
else
|
||||
AC_PATH_PROGS(JAR, jar$EXEEXT, , $JAVAPREFIX)
|
||||
fi
|
||||
fi
|
||||
test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH])
|
||||
AC_PROVIDE([$0])dnl
|
||||
])
|
@ -1,16 +0,0 @@
|
||||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_java.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVA],[
|
||||
AC_REQUIRE([AC_EXEEXT])dnl
|
||||
if test "x$JAVA" = x; then
|
||||
if test "x$JAVAPREFIX" = x; then
|
||||
AC_CHECK_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT)
|
||||
else
|
||||
AC_PATH_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT, , $JAVAPREFIX)
|
||||
fi
|
||||
fi
|
||||
test "x$JAVA" = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH])
|
||||
AC_PROG_JAVA_WORKS
|
||||
AC_PROVIDE([$0])dnl
|
||||
])
|
@ -1,31 +0,0 @@
|
||||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_java_cc.html
|
||||
dnl
|
||||
# AC_PROG_JAVA_CC([COMPILER ...])
|
||||
# --------------------------
|
||||
# COMPILER ... is a space separated list of java compilers to search for.
|
||||
# This just gives the user an opportunity to specify an alternative
|
||||
# search list for the java compiler.
|
||||
AC_DEFUN([AC_PROG_JAVA_CC],
|
||||
[AC_ARG_VAR([JAVA_CC], [java compiler command])dnl
|
||||
AC_ARG_VAR([JAVA_CC_FLAGS], [java compiler flags])dnl
|
||||
m4_ifval([$1],
|
||||
[AC_CHECK_TOOLS(JAVA_CC, [$1])],
|
||||
[AC_CHECK_TOOL(JAVA_CC, gcj)
|
||||
if test -z "$JAVA_CC"; then
|
||||
AC_CHECK_TOOL(JAVA_CC, javac)
|
||||
fi
|
||||
if test -z "$JAVA_CC"; then
|
||||
AC_CHECK_TOOL(JAVA_CC, jikes)
|
||||
fi
|
||||
])
|
||||
|
||||
if test "$JAVA_CC" = "gcj"; then
|
||||
if test "$GCJ_OPTS" = ""; then
|
||||
AC_SUBST(GCJ_OPTS,-C)
|
||||
fi
|
||||
AC_SUBST(JAVA_CC_OPTS, @GCJ_OPTS@,
|
||||
[Define the compilation options for GCJ])
|
||||
fi
|
||||
test -z "$JAVA_CC" && AC_MSG_ERROR([no acceptable java compiler found in \$PATH])
|
||||
])# AC_PROG_JAVA_CC
|
@ -1,85 +0,0 @@
|
||||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_java_works.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVA_WORKS], [
|
||||
AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
|
||||
if test x$uudecode = xyes; then
|
||||
AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
|
||||
dnl /**
|
||||
dnl * Test.java: used to test if java compiler works.
|
||||
dnl */
|
||||
dnl public class Test
|
||||
dnl {
|
||||
dnl
|
||||
dnl public static void
|
||||
dnl main( String[] argv )
|
||||
dnl {
|
||||
dnl System.exit (0);
|
||||
dnl }
|
||||
dnl
|
||||
dnl }
|
||||
cat << \EOF > Test.uue
|
||||
begin-base64 644 Test.class
|
||||
yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
|
||||
bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
|
||||
bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
|
||||
YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
|
||||
aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
|
||||
AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
|
||||
AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
|
||||
====
|
||||
EOF
|
||||
if uudecode$EXEEXT Test.uue; then
|
||||
ac_cv_prog_uudecode_base64=yes
|
||||
else
|
||||
echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
|
||||
echo "configure: failed file was:" >&AC_FD_CC
|
||||
cat Test.uue >&AC_FD_CC
|
||||
ac_cv_prog_uudecode_base64=no
|
||||
fi
|
||||
rm -f Test.uue])
|
||||
fi
|
||||
if test x$ac_cv_prog_uudecode_base64 != xyes; then
|
||||
rm -f Test.class
|
||||
AC_MSG_WARN([I have to compile Test.class from scratch])
|
||||
if test x$ac_cv_prog_javac_works = xno; then
|
||||
AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
|
||||
fi
|
||||
if test x$ac_cv_prog_javac_works = x; then
|
||||
AC_PROG_JAVAC
|
||||
fi
|
||||
fi
|
||||
AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
|
||||
JAVA_TEST=Test.java
|
||||
CLASS_TEST=Test.class
|
||||
TEST=Test
|
||||
changequote(, )dnl
|
||||
cat << \EOF > $JAVA_TEST
|
||||
/* [#]line __oline__ "configure" */
|
||||
public class Test {
|
||||
public static void main (String args[]) {
|
||||
System.exit (0);
|
||||
} }
|
||||
EOF
|
||||
changequote([, ])dnl
|
||||
if test x$ac_cv_prog_uudecode_base64 != xyes; then
|
||||
if AC_TRY_COMMAND("$JAVAC" $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
|
||||
:
|
||||
else
|
||||
echo "configure: failed program was:" >&AC_FD_CC
|
||||
cat $JAVA_TEST >&AC_FD_CC
|
||||
AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
|
||||
fi
|
||||
fi
|
||||
if AC_TRY_COMMAND("$JAVA" $JAVAFLAGS $TEST) >/dev/null 2>&1; then
|
||||
ac_cv_prog_java_works=yes
|
||||
else
|
||||
echo "configure: failed program was:" >&AC_FD_CC
|
||||
cat $JAVA_TEST >&AC_FD_CC
|
||||
AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
|
||||
fi
|
||||
rm -fr $JAVA_TEST $CLASS_TEST Test.uue
|
||||
])
|
||||
AC_PROVIDE([$0])dnl
|
||||
]
|
||||
)
|
@ -1,25 +0,0 @@
|
||||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_javac.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVAC],[
|
||||
AC_REQUIRE([AC_EXEEXT])dnl
|
||||
if test "x$JAVAC" = x; then
|
||||
if test "x$JAVAPREFIX" = x; then
|
||||
AC_CHECK_PROGS(JAVAC, jikes$EXEEXT javac$EXEEXT gcj$EXEEXT guavac$EXEEXT)
|
||||
else
|
||||
AC_PATH_PROGS(JAVAC, jikes$EXEEXT javac$EXEEXT gcj$EXEEXT guavac$EXEEXT, , "$JAVAPREFIX")
|
||||
fi
|
||||
fi
|
||||
test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH])
|
||||
if test "$JAVAC" = "gcj$EXEEXT"; then
|
||||
case "$JAVACFLAGS" in
|
||||
*-C*)
|
||||
;;
|
||||
*)
|
||||
JAVACFLAGS="$JAVACFLAGS -C"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
AC_PROG_JAVAC_WORKS
|
||||
AC_PROVIDE([$0])dnl
|
||||
])
|
@ -1,23 +0,0 @@
|
||||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_javac_works.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVAC_WORKS],[
|
||||
AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [
|
||||
JAVA_TEST=Test.java
|
||||
CLASS_TEST=Test.class
|
||||
cat << \EOF > $JAVA_TEST
|
||||
/* [#]line __oline__ "configure" */
|
||||
public class Test {
|
||||
}
|
||||
EOF
|
||||
if AC_TRY_COMMAND("$JAVAC" $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then
|
||||
ac_cv_prog_javac_works=yes
|
||||
else
|
||||
AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
|
||||
echo "configure: failed program was:" >&AC_FD_CC
|
||||
cat $JAVA_TEST >&AC_FD_CC
|
||||
fi
|
||||
rm -f $JAVA_TEST $CLASS_TEST
|
||||
])
|
||||
AC_PROVIDE([$0])dnl
|
||||
])
|
@ -1,16 +0,0 @@
|
||||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_javadoc.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVADOC],[
|
||||
AC_REQUIRE([AC_EXEEXT])dnl
|
||||
if test "x$JAVADOC" = x; then
|
||||
if test "x$JAVAPREFIX" = x; then
|
||||
AC_CHECK_PROGS(JAVADOC, javadoc$EXEEXT)
|
||||
else
|
||||
AC_PATH_PROGS(JAVADOC, javadoc$EXEEXT, , "$JAVAPREFIX")
|
||||
fi
|
||||
fi
|
||||
test "x$JAVADOC" = x && AC_MSG_ERROR([no acceptable javadoc generator found in \$PATH])
|
||||
AC_PROVIDE([$0])dnl
|
||||
])
|
||||
|
@ -1,20 +0,0 @@
|
||||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_javah.html
|
||||
dnl
|
||||
AC_DEFUN([AC_PROG_JAVAH],[
|
||||
AC_REQUIRE([AC_CANONICAL_SYSTEM])dnl
|
||||
AC_REQUIRE([AC_PROG_CPP])dnl
|
||||
AC_PATH_PROG(JAVAH,javah)
|
||||
if test x"`eval 'echo $ac_cv_path_JAVAH'`" != x ; then
|
||||
AC_TRY_CPP([#include <jni.h>],,[
|
||||
ac_save_CPPFLAGS="$CPPFLAGS"
|
||||
changequote(, )dnl
|
||||
ac_dir=`echo $ac_cv_path_JAVAH | sed 's,\(.*\)/[^/]*/[^/]*$,\1/include,'`
|
||||
ac_machdep=`echo $build_os | sed 's,[-0-9].*,,' | sed 's,cygwin,win32,'`
|
||||
changequote([, ])dnl
|
||||
CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep"
|
||||
AC_TRY_CPP([#include <jni.h>],
|
||||
ac_save_CPPFLAGS="$CPPFLAGS",
|
||||
AC_MSG_WARN([unable to include <jni.h>]))
|
||||
CPPFLAGS="$ac_save_CPPFLAGS"])
|
||||
fi])
|
1
packages/jpl/jpl/aclocal.m4
vendored
1
packages/jpl/jpl/aclocal.m4
vendored
@ -1 +0,0 @@
|
||||
|
1537
packages/jpl/jpl/config.guess
vendored
1537
packages/jpl/jpl/config.guess
vendored
File diff suppressed because it is too large
Load Diff
1786
packages/jpl/jpl/config.sub
vendored
1786
packages/jpl/jpl/config.sub
vendored
File diff suppressed because it is too large
Load Diff
@ -1,158 +0,0 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
m4_ifdef([HAS_TOP],[m4_ignore],[ AC_INIT(install-sh)
|
||||
AC_PREREQ([2.50])
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
])
|
||||
|
||||
AC_SUBST(JAVA_HOME)
|
||||
AC_SUBST(JAVACFLAGS)
|
||||
AC_SUBST(JAVALIBS)
|
||||
AC_SUBST(JUNIT)
|
||||
AC_SUBST(JPLCFLAGS)
|
||||
AC_SUBST(JPLLDFLAGS)
|
||||
AC_SUBST(LIBJPL)
|
||||
AC_SUBST(JAVA_PRELOAD)
|
||||
AC_SUBST(CMDEXT)
|
||||
|
||||
m4_ifdef([HAS_TOP],[m4_ignore],[
|
||||
m4_include([../ac_swi_c.m4])
|
||||
])
|
||||
|
||||
CMDEXT=sh
|
||||
|
||||
if test "x$JAVALIBS" = "x"; then
|
||||
case "$PLARCH" in
|
||||
*darwin*)
|
||||
JAVALIBS="-Wl,-framework,JavaVM"
|
||||
;;
|
||||
*powerpc-linux*)
|
||||
JAVALIBS="-ljava -ljvm"
|
||||
;;
|
||||
*win32*|*win64*)
|
||||
JAVALIBS="-ljvm"
|
||||
CMDEXT=bat
|
||||
;;
|
||||
*)
|
||||
JAVALIBS="-ljava -lverify -ljvm"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$PLARCH" in
|
||||
*win32*)
|
||||
JPLLDFLAGS="$JPLLDFLAGS -Wl,--kill-at"
|
||||
LIBJPL=jpl
|
||||
;;
|
||||
*win64*)
|
||||
LIBJPL=jpl
|
||||
;;
|
||||
*)
|
||||
LIBJPL=libjpl
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl ================================================================
|
||||
dnl Java stuff
|
||||
dnl ================================================================
|
||||
|
||||
AC_CANONICAL_HOST dnl needed to get $host_os
|
||||
|
||||
dnl if test "x$JAVACFLAGS" = x; then
|
||||
dnl JAVACFLAGS="-source 1.4 -target 1.4"
|
||||
dnl fi
|
||||
|
||||
m4_include([ac/ac_prog_java.m4])
|
||||
m4_include([ac/ac_prog_java_works.m4])
|
||||
m4_include([ac/ac_prog_javac.m4])
|
||||
m4_include([ac/ac_prog_javac_works.m4])
|
||||
m4_include([ac/ac_prog_javadoc.m4])
|
||||
m4_include([ac/ac_jni_include_dirs.m4])
|
||||
m4_include([ac/ac_prog_jar.m4])
|
||||
|
||||
java_abs_paths=no
|
||||
AC_CHECKING(Java configuration)
|
||||
if test -r /etc/java/java2.conf; then
|
||||
AC_MSG_RESULT(Using /etc/java/java2.conf)
|
||||
eval `grep '\(JAVA\|JRE\|JDK\|SDK\).*=' /etc/java/java2.conf | sed 's/ *= */=/'`
|
||||
if test ! -z "$JAVA_BINDIR"; then
|
||||
PATH="$PATH:$JAVA_BINDIR"
|
||||
java_abs_paths=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PROG_JAVAC(javac)
|
||||
AC_PROG_JAVA(java)
|
||||
AC_PROG_JAR(jar)
|
||||
AC_PROG_JAVADOC(javadoc)
|
||||
|
||||
escape_space()
|
||||
{ sed -e "s/Program Files/Program-SPACE-Files/g" -e "s/ (x86)/SPACEX86/g"
|
||||
}
|
||||
|
||||
unescape_space()
|
||||
{ sed -e "s/-SPACE-/ /g" -e "s/SPACEX86/ (x86)/g"
|
||||
}
|
||||
|
||||
AC_JNI_INCLUDE_DIR
|
||||
for d in $(echo $JNI_INCLUDE_DIRS | escape_space); do
|
||||
JPLCFLAGS="$JPLCFLAGS -I'$d'"
|
||||
done
|
||||
JPLCFLAGS="$(echo $JPLCFLAGS | unescape_space)"
|
||||
|
||||
for d in $(echo $JNI_CLIENT_DIRS | escape_space); do
|
||||
JPLLDFLAGS="$JPLLDFLAGS -L'$d'"
|
||||
done
|
||||
JPLLDFLAGS="$(echo $JPLLDFLAGS | unescape_space)"
|
||||
|
||||
case "$PLARCH" in
|
||||
*darwin*)
|
||||
;;
|
||||
**)
|
||||
for d in $(echo $JNI_CLIENT_DIRS | escape_space); do
|
||||
if test -f "$d/libjsig.$SO"; then
|
||||
JAVALIBS="-ljsig $JAVALIBS"
|
||||
JAVA_PRELOAD=$d/libjsig.$SO
|
||||
break
|
||||
fi
|
||||
done
|
||||
esac
|
||||
JAVA_PRELOAD="$(echo $JAVA_PRELOAD | unescape_space)"
|
||||
|
||||
if test "$java_abs_paths" = yes; then
|
||||
JAVA_CC="$JAVA_BINDIR/$JAVA_CC"
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(junit, [ --with-junit=PATH Specify location of the junit JAR file],
|
||||
[case "$withval" in
|
||||
yes) JUNIT=/usr/share/java/junit.jar
|
||||
;;
|
||||
no) JUNIT=""
|
||||
;;
|
||||
*) JUNIT="$withval"
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[ if test "x$JUNIT" = "x" -a -r /usr/share/java/junit.jar; then
|
||||
JUNIT=/usr/share/java/junit.jar
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
AC_CHECK_HEADERS(wchar.h)
|
||||
AC_CHECK_SIZEOF(wchar_t, 4)
|
||||
AC_CHECK_SIZEOF(void*, 4)
|
||||
AC_CHECK_SIZEOF(long, 4)
|
||||
AC_CHECK_SIZEOF(long long, 8)
|
||||
|
||||
if test $i_am_cross_compiling = yes
|
||||
then
|
||||
#mingw: we know where things are
|
||||
JPLCFLAGS="-I \"$yap_cv_java\"/include -I \"$yap_cv_java\"/include/win32"
|
||||
JAVALIBS="-L \"$yap_cv_java\"/jre/bin/server -L \"$yap_cv_java\"/jre/bin/client -ljvm"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
m4_ifdef([HAS_TOP],[m4_ignore], [AC_OUTPUT(Makefile src/java/Makefile)])
|
||||
|
@ -1,28 +0,0 @@
|
||||
:- asserta(file_search_path(foreign, '.')).
|
||||
:- asserta(file_search_path(jpl_examples, 'examples/prolog')).
|
||||
:- asserta(file_search_path(jar, '.')).
|
||||
:- asserta(file_search_path(library, '.')).
|
||||
|
||||
:- use_module(library(jpl)).
|
||||
|
||||
/*******************************
|
||||
* DEMOS *
|
||||
*******************************/
|
||||
|
||||
jpl_demo :-
|
||||
absolute_file_name(jpl_examples(.),
|
||||
[ file_type(directory),
|
||||
access(read)
|
||||
],
|
||||
ExampleDir),
|
||||
atom_concat(ExampleDir, '/*.pl', Pattern),
|
||||
expand_file_name(Pattern, Examples),
|
||||
tag_basename(Examples, Entries),
|
||||
menu('Select JPL example', Entries, Example),
|
||||
consult(Example).
|
||||
|
||||
tag_basename([], []).
|
||||
tag_basename([H|T0], [H:B|T]) :-
|
||||
file_base_name(H, B),
|
||||
tag_basename(T0, T).
|
||||
|
@ -1,45 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>JPL: A bidirectional Prolog/Java interface</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 align=center>JPL: A bidirectional Prolog/Java interface</h1>
|
||||
|
||||
<blockquote>
|
||||
<hr>
|
||||
This version of the documentation is a quick and dirty collection of
|
||||
the available documentation. It contains error, references to obsolete
|
||||
constructs, limitations that have been removed, etc. We hope this situation
|
||||
will improve soon.
|
||||
<hr>
|
||||
</blockquote>
|
||||
|
||||
<p>
|
||||
JPL is a library using the SWI-Prolog foreign interface and the Java jni
|
||||
interface providing a bidirectional interface between Java and Prolog
|
||||
that can be used to embed Prolog in Java as well as for embedding Java
|
||||
in Prolog. In both setups it provides a reentrant bidirectional interface.
|
||||
|
||||
<ul>
|
||||
<li><a href="objectives.html">Objectives</a>
|
||||
<li><a href="java_api/index.html">Using Prolog from Java</a>
|
||||
<li>Using Java from Prolog
|
||||
<ul>
|
||||
<li><a href="prolog_api/overview.html">User guide</a>
|
||||
<li><a href="prolog_api/api.html">API reference</a>
|
||||
<li><a href="prolog_api/gotchas.html">Gotchas</a>
|
||||
</ul>
|
||||
<li><a href="installation.html">Installation</a>
|
||||
<li><a href="release_notes.html">Release notes</a>
|
||||
</ul>
|
||||
|
||||
<address>
|
||||
<a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a><br>
|
||||
Fred Dushin<br>
|
||||
Jan Wielemaker
|
||||
</address>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,181 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Paul Singleton">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<title>JPL 3.x installation</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;">
|
||||
JPL 3.x</span> installation</h1>
|
||||
<hr width="100%">
|
||||
First check that the prerequisites (see the home page) are satisfied
|
||||
(you have SWI-Prolog 5.2.0 or later, a Java 2 SDK, and a compatible
|
||||
operating
|
||||
system).
|
||||
<p>Unzip <span style="font-family: monospace;">jpl.zip</span>
|
||||
somewhere
|
||||
safe (maybe into the <span style="font-family: monospace;">\pl</span>
|
||||
folder of your <span style="font-style: italic;">SWI-Prolog</span>
|
||||
installation): it creates a folder <span
|
||||
style="font-family: monospace;">\jpl</span>
|
||||
which you should retain.
|
||||
</p>
|
||||
<p>Inspect your new <span style="font-family: monospace;">\jpl</span>
|
||||
folder: it should contain
|
||||
</p>
|
||||
<pre style="margin-left: 40px;">jpl<br> +--- examples<br> | +--- Exceptions<br> | +--- Exceptions2<br> | +--- Family<br> | +--- Test<br> | +--- Test2<br> | +--- Time<br> | +--- Zahed<br> | +--- <i>(and maybe more...)<br> |<br></i> +--- docs <span
|
||||
style="font-style: italic;"> (HTML files in here are accessible via links from the home page)</span><br> |<br> +--- src<br> | +--- c<br> | | +--- build.bat <span
|
||||
style="font-style: italic;">(Windows script to recompile jpl.c to jpl.dll)</span><br> | | +--- build.sh <span
|
||||
style="font-style: italic;">(Linux script to recompile jpl.c to libjpl.so)</span><br> | +--- java<br> |<br> +--- jpl.dll <span
|
||||
style="font-style: italic;">(a native library - for Windows in this case)</span>
|
||||
|
|
||||
+--- jpl.jar <span
|
||||
style="font-style: italic;"> (a Java library)</span>
|
||||
|
|
||||
+--- jpl.pl <span
|
||||
style="font-style: italic;">(a Prolog library)</span>
|
||||
|
|
||||
+--- README.html <span
|
||||
style="font-style: italic;">(<span style="font-weight: bold; font-style: italic;">JPL</span>'s documentation "home page")</span>
|
||||
|
||||
</pre>
|
||||
Put the three library files (<span style="font-family: monospace;">jpl.dll</span>,<span
|
||||
style="font-family: monospace;"> jpl.jar</span>
|
||||
and <span style="font-family: monospace;">jpl.pl</span>) where
|
||||
each
|
||||
can be found:
|
||||
<ul>
|
||||
<li> <span style="font-family: monospace;">jpl.dll</span> must be
|
||||
found
|
||||
by the <span style="font-style: italic;">Windows </span>kernel,
|
||||
and can go in any folder on your <span
|
||||
style="font-family: monospace;">PATH</span>;
|
||||
perhaps <span style="font-family: monospace;">%SWI_HOME_DIR%\bin</span>
|
||||
or your Windows system folder<span style="font-family: monospace;"></span></li>
|
||||
<li> <span style="font-family: monospace;">jpl.jar</span> must be
|
||||
found
|
||||
by any <span style="font-style: italic;">Java </span>VMs
|
||||
(and compilers) used with <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>;
|
||||
one possibility is to put it on your global <span
|
||||
style="font-family: monospace;">CLASSPATH</span></li>
|
||||
<li> <span style="font-family: monospace;">jpl.pl</span> is a Prolog
|
||||
source
|
||||
module, and must be found by any <span style="font-style: italic;">SWI-Prolog</span>
|
||||
engines used with <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>:
|
||||
I suggest putting it in <span style="font-family: monospace;">%SWI_HOME_DIR%\library</span>
|
||||
and then invoking <span
|
||||
style="font-family: helvetica,arial,sans-serif;">make_library_index/1</span>
|
||||
on that folder (see a<span style="font-style: italic;"> SWI-Prolog</span>
|
||||
manual for details) so that the autoloader can find it.</li>
|
||||
</ul>
|
||||
For <span style="font-style: italic;">SWI-Prolog</span> to
|
||||
initialise
|
||||
(or make the first call) to <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>,
|
||||
it is necessary that a folder containing the <span
|
||||
style="font-style: italic;">JVM</span>library
|
||||
(<span style="font-family: monospace;">jvm.dll</span>) is on your PATH;
|
||||
if you are using a recent <span style="font-style: italic;">Sun </span>JRE,
|
||||
look for a PATH entry of the form <span
|
||||
style="font-family: monospace;">C:\jdk1.3.1_01\jre\bin\hotspot;</span>
|
||||
or <span style="font-family: monospace;">C:\jdk1.3.1_01\jre\bin\client;
|
||||
<br>
|
||||
</span><br>
|
||||
If your applications start in Java, and then call <span
|
||||
style="font-style: italic;">SWI-Prolog</span>,
|
||||
it is necessary that the <span style="font-style: italic;">SWI-Prolog</span>
|
||||
library <span style="font-family: courier new,courier,monospace;"><font
|
||||
size="-1">libpl.dll</font></span>
|
||||
is in a folder on the PATH<br>
|
||||
<br>
|
||||
Try the Java example in
|
||||
<pre style="margin-left: 40px;">examples/java/Versions</pre>
|
||||
or the Prolog example in
|
||||
<pre style="margin-left: 40px;">examples/prolog/jpl_versions_demo.pl<br></pre>
|
||||
to confirm that all three libraries are installed and compatible.<br>
|
||||
<h3>Installation troubleshooting</h3>
|
||||
If the example programs don't run successfully, look carefully at any
|
||||
error
|
||||
messages; they typically indicate where the problem lies. Then
|
||||
check
|
||||
the installation instruction s and prerequisites carefully.
|
||||
<br>
|
||||
|
||||
<ul>
|
||||
<li>If you get a message about</li>
|
||||
</ul>
|
||||
<pre style="margin-left: 80px; font-weight: bold; font-style: italic;">... jpl.dll ... Access is denied ...</pre>
|
||||
<div style="margin-left: 40px;">then you may have lost execute
|
||||
permission
|
||||
on <span style="font-family: courier new,courier,monospace;"><font
|
||||
size="-1">jpl.dll</font></span>
|
||||
(please consult local <span style="font-style: italic;">Windows </span>expertise
|
||||
if you don't know how to correct this).</div>
|
||||
<ul>
|
||||
<li>If <span style="font-family: courier new,courier,monospace;"><font
|
||||
size="-1">jpl_examples/0</font></span>
|
||||
complains that</li>
|
||||
</ul>
|
||||
<div style="margin-left: 80px;"><span
|
||||
style="font-weight: bold; font-style: italic;">The
|
||||
dynamic link library jvm.dll could not be found in the specified path</span>
|
||||
<br>
|
||||
</div>
|
||||
<div style="margin-left: 40px;">then you should locate jvm.dll within
|
||||
the
|
||||
Java runtime which you intend to use, and ensure that its directory is
|
||||
within the PATH.</div>
|
||||
<ul>
|
||||
<li>if the Java examples (e.g. <span
|
||||
style="font-family: courier new,courier,monospace;"><font size="-1">jpl\examples\Exception\run.bat</font></span>)
|
||||
complain that</li>
|
||||
</ul>
|
||||
<div style="margin-left: 80px;"><span style="font-weight: bold;"><span
|
||||
style="font-style: italic;">The
|
||||
name specified is not recognized as an internal or external command,
|
||||
operable
|
||||
program or batch file.</span>
|
||||
<br>
|
||||
</span></div>
|
||||
<div style="margin-left: 40px;">
|
||||
<br>
|
||||
then there is no Java executable <span
|
||||
style="font-family: courier new,courier,monospace;"><font size="-1">java.exe</font></span>
|
||||
in any folder on your PATH: you should have a PATH entry such as <span
|
||||
style="font-family: courier new,courier,monospace;"><font size="-1">C:\jdk1.3.1_01\bin;</font></span></div>
|
||||
<ul>
|
||||
<li>if the Java examples complain that</li>
|
||||
</ul>
|
||||
<div style="margin-left: 80px;"><span
|
||||
style="font-weight: bold; font-style: italic;">The
|
||||
dynamic link library libpl.dll could not be found in the specified path</span></div>
|
||||
<div style="margin-left: 40px;">or</div>
|
||||
<div style="margin-left: 80px;"><span
|
||||
style="font-weight: bold; font-style: italic;">Exception
|
||||
in thread "main" java.lang.UnsatisfiedLinkError: C:\paul\bin\jpl.dll:
|
||||
Can't
|
||||
find dependent libraries
|
||||
<br>
|
||||
</span></div>
|
||||
<div style="margin-left: 40px;">then there is no SWI-Prolog
|
||||
library <span style="font-family: courier new,courier,monospace;"><font
|
||||
size="-1">libpl.dll</font></span>
|
||||
in any folder on your PATH: you should have a PATH entry such as <span
|
||||
style="font-family: courier new,courier,monospace;">C:\Program
|
||||
Files\pl\bin</span><br>
|
||||
</div>
|
||||
<br>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>
|
||||
February 2004</address>
|
||||
<br>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,289 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<meta name="Author" content="Fred Dushin">
|
||||
<meta name="Keywords" content="JPL,java,prolog">
|
||||
<title>Getting Started</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#ffffff" link="#00009c" vlink="#ce31ce"
|
||||
alink="#ff0000">
|
||||
<center>
|
||||
<h1 style="text-align: left;"><span style="font-style: italic;">JPL 2.x</span>
|
||||
Getting Started</h1>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<div style="text-align: left;">This section provides a tutorial
|
||||
introduction to <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
through its <a href="high-level_interface.html"><b><span
|
||||
style="font-style: italic;">JPL 2.x</span> Java API overview</b></a>,
|
||||
the
|
||||
interface most programmers are likely to use.
|
||||
The source code described here can be found in the <span
|
||||
style="font-family: courier new,courier,monospace;">examples</span>
|
||||
directory of
|
||||
the
|
||||
JPL distribution. Feel free to consult the source files and run
|
||||
the
|
||||
demonstration program as you read this section.
|
||||
</div>
|
||||
</center>
|
||||
<h3>Verifying the installation</h3>
|
||||
To confirm that <b><i>JPL</i></b> and SWI-Prolog are basically able to
|
||||
work together, open a console window and go into this directory:
|
||||
<blockquote>
|
||||
<pre>jpl/examples/</pre>
|
||||
</blockquote>
|
||||
read the README.txt file, and run the various examples which it
|
||||
describes.<br>
|
||||
<br>
|
||||
Each Java example will run as an application (i.e. each has a <tt>main()</tt>
|
||||
method), exercises SWI-Prolog, and writes something to <b>System.out</b>
|
||||
or <b>System.err</b>.
|
||||
<p>If you see some plausible output, with no serious error messages,
|
||||
then
|
||||
all may be well.
|
||||
</p>
|
||||
<h3>Creating a Prolog database in a text file</h3>
|
||||
To experiment with <b><i>JPL</i></b>, we'll first create a Prolog
|
||||
database
|
||||
in a text file. We will eventually load this database into the
|
||||
Prolog
|
||||
engine through the <a
|
||||
href="file:///D:/jpl/docs/java_api/high-level_interface.html"><b><span
|
||||
style="font-style: italic;">JPL 2.x</span> Java API overview</b></a>.
|
||||
<p>Type the following in a text editor and save the result in a file
|
||||
called
|
||||
<i>test.pl</i>
|
||||
</p>
|
||||
<blockquote><tt><font size="+1">child_of(joe, ralf).</font></tt> <br>
|
||||
<tt><font size="+1">child_of(mary, joe).</font></tt> <br>
|
||||
<tt><font size="+1">child_of(steve, joe).</font></tt>
|
||||
<p><tt><font size="+1">descendent_of(X, Y) :-</font></tt> <br>
|
||||
<tt><font size="+1"> child_of(X, Y).</font></tt> <br>
|
||||
<tt><font size="+1">descendent_of(X, Y) :-</font></tt> <br>
|
||||
<tt><font size="+1"> child_of(Z, Y),</font></tt> <br>
|
||||
<tt><font size="+1"> descendent_of(X, Z).</font></tt></p>
|
||||
</blockquote>
|
||||
You may wish to load this database into an interactive Prolog session
|
||||
to
|
||||
experiment with the predicates in this database before experimenting
|
||||
with
|
||||
<b><i>JPL</i></b>.
|
||||
<h3>Initializing The Prolog engine</h3>
|
||||
Although the <b>jpl.JPL</b> class provides a number of methods for
|
||||
initializing
|
||||
the Prolog engine from within Java, their use is not usually necessary:
|
||||
Prolog will be automatically initialised with default parameters
|
||||
at the first attempt to use it.
|
||||
<h3>Consulting the Prolog database from its text file</h3>
|
||||
In an ordinary interactive Prolog session, we'd load the above Prolog
|
||||
database
|
||||
using the Prolog <tt><font size="+1">consult/1</font></tt> predicate,
|
||||
a built-in
|
||||
predicate in standard Prolog. Note, however, that as a Prolog
|
||||
predicate,
|
||||
"calling" <tt><font size="+1">consult/1</font></tt> is just an example
|
||||
of making
|
||||
a Prolog query, and this is how we perform it with <b><i>JPL</i></b>.
|
||||
<p>First we construct an instance of <b>jpl.Query</b>, whose name is <b><tt><font
|
||||
size="+1">consult</font></tt></b>
|
||||
and whose arguments (just one) comprise the atom <b><tt><font size="+1">'test.pl'</font></tt></b>:
|
||||
</p>
|
||||
<blockquote><tt><font size="+1">Query q1 =</font></tt> <br>
|
||||
<tt><font size="+1"> new Query(</font></tt> <br>
|
||||
<tt><font size="+1">
|
||||
"consult",</font></tt> <br>
|
||||
<tt><font size="+1"> new
|
||||
Term[]
|
||||
{new Atom("test.pl")}</font></tt> <br>
|
||||
<tt><font size="+1"> );</font></tt></blockquote>
|
||||
Then we call the <b>query()</b> method of this <b>Query</b> object,
|
||||
which
|
||||
returns a Boolean value indicating its success:
|
||||
<blockquote><tt><font size="+1">System.out.println( "consult " +
|
||||
(q1.query()
|
||||
? "succeeded" : "failed"));</font></tt></blockquote>
|
||||
At this point, this process may seem a bit long-winded; however, you
|
||||
should
|
||||
soon see that the classes are sufficiently general that they provide a
|
||||
robust and powerful interface into the Prolog engine. There is
|
||||
also
|
||||
considerable scope for writing "convenience" classes and methods, but
|
||||
in
|
||||
this introduction we deliberately employ the general, primitive
|
||||
facilities
|
||||
of the <a
|
||||
href="file:///D:/jpl/docs/java_api/high-level_interface.html"><b><span
|
||||
style="font-style: italic;">JPL 2.x</span> Java API overview</b></a>.
|
||||
<h3>Querying the Database</h3>
|
||||
Using the same technique, we can query the Prolog database about
|
||||
inferences
|
||||
it can make. To ask whether the Prolog query <tt><font size="+1">child_of(joe,ralf)</font></tt>is
|
||||
true, given the above Prolog database, for example, we write:
|
||||
<blockquote><tt><font size="+1">Query q2 =</font></tt> <br>
|
||||
<tt><font size="+1"> new Query(</font></tt> <br>
|
||||
<tt><font size="+1">
|
||||
"child_of",</font></tt> <br>
|
||||
<tt><font size="+1"> new
|
||||
Term[]
|
||||
{new Atom("joe"),new Atom("ralf")}</font></tt> <br>
|
||||
<tt><font size="+1"> );</font></tt>
|
||||
<p><tt><font size="+1">System.out.println(</font></tt> <br>
|
||||
<tt><font size="+1"> "child_of(joe,ralf) is " +</font></tt>
|
||||
<br>
|
||||
<tt><font size="+1"> ( q2.query() ? "provable" :
|
||||
"not
|
||||
provable" )</font></tt> <br>
|
||||
<tt><font size="+1">);</font></tt></p>
|
||||
</blockquote>
|
||||
To take an example that requires a bit more work on the part of the
|
||||
Prolog
|
||||
engine, on the other hand, we can ask whether <tt><font size="+1">descendent_of(steve,ralf)</font></tt>
|
||||
is true:
|
||||
<blockquote><tt><font size="+1">Query q3 =</font></tt> <br>
|
||||
<tt><font size="+1"> new Query(</font></tt> <br>
|
||||
<tt><font size="+1">
|
||||
"descendent_of",</font></tt> <br>
|
||||
<tt><font size="+1"> new
|
||||
Term[]
|
||||
{new Atom("steve"),new Atom("ralf")}</font></tt> <br>
|
||||
<tt><font size="+1"> );</font></tt>
|
||||
<p><tt><font size="+1">System.out.println(</font></tt> <br>
|
||||
<tt><font size="+1"> "descendent_of(joe,ralf) is "
|
||||
+</font></tt> <br>
|
||||
<tt><font size="+1"> ( q3.query() ? "provable" :
|
||||
"not
|
||||
provable" )</font></tt> <br>
|
||||
<tt><font size="+1">);</font></tt></p>
|
||||
</blockquote>
|
||||
<h3>
|
||||
Querying with Variables</h3>
|
||||
A ground query is relatively straightforward; it is essentially
|
||||
either provable or not, and there is typically no point in
|
||||
backtracking.
|
||||
Once we use variables, however, things get
|
||||
a bit more complicated.
|
||||
<p>Using the <b>jpl.Variable</b> class, we can construct a non ground
|
||||
query;
|
||||
and using other methods of <b>Query</b> we can obtain a <i>solution</i>
|
||||
in the form of a <b>java.util.Hashtable</b>. If the
|
||||
<b>Query</b> has one or more solutions, then its
|
||||
<b>Query.</b><b>oneSolution()</b>
|
||||
method returns a <b>Hashtable</b> representing
|
||||
the first solution, otherwise
|
||||
it returns <b>null</b>:
|
||||
</p>
|
||||
<blockquote><tt><font size="+1">Variable <b>X</b> = new Variable();</font></tt>
|
||||
<p><tt><font size="+1">Query <b>q4</b> =</font></tt> <br>
|
||||
<tt><font size="+1"> new Query(</font></tt> <br>
|
||||
<tt><font size="+1">
|
||||
"descendent_of",</font></tt> <br>
|
||||
<tt><font size="+1"> new
|
||||
Term[]
|
||||
{<b>X</b>,new Atom("ralf")}</font></tt> <br>
|
||||
<tt><font size="+1"> );</font></tt> </p>
|
||||
<p><tt><font size="+1">java.util.Hashtable solution;</font></tt> </p>
|
||||
<p><tt><font size="+1">solution = <b>q4</b>.oneSolution();</font></tt>
|
||||
</p>
|
||||
<p><tt><font size="+1">System.out.println( "first solution of
|
||||
descendent_of(X,
|
||||
ralf)");</font></tt> <br>
|
||||
<tt><font size="+1">System.out.println( "X = " + solution.get(<b>X</b>));</font></tt></p>
|
||||
</blockquote>
|
||||
The <b>HashTable</b> contains bindings in the form of <b>Term</b>s,
|
||||
each
|
||||
of which is indexed by its corresponding <b>Variable</b> in the <b>Query</b>.
|
||||
<h3>
|
||||
Finding all solutions</h3>
|
||||
The previous query finds only the first solution. Often, however,
|
||||
one wants all solutions, or at least more than just the first.
|
||||
The
|
||||
<b>Query</b>
|
||||
class also provides the <b>allSolutions()</b> method, which returns an
|
||||
array of zero or more <b>Hashtable</b>s, each of which represents a
|
||||
given
|
||||
solution.
|
||||
<p>In this example we reuse the query <b><tt><font size="+1">q4</font></tt></b>,
|
||||
which was reset to its initial state by the call of <b><tt><font
|
||||
size="+1">oneSolution()</font></tt></b>,
|
||||
and instead call <b><tt><font size="+1">allSolutions()</font></tt></b>,
|
||||
which
|
||||
returns an array of solutions:
|
||||
</p>
|
||||
<blockquote><tt><font size="+1">java.util.Hashtable[] solutions = <b>q4</b>.allSolutions();</font></tt>
|
||||
<p><tt><font size="+1">for ( int i=0 ; i<solutions.length ; i++ ) {</font></tt>
|
||||
<br>
|
||||
<tt><font size="+1"> System.out.println( "X = " +
|
||||
solutions[i].get(<b>X</b>));</font></tt> <br>
|
||||
<tt><font size="+1">}</font></tt></p>
|
||||
</blockquote>
|
||||
Equivalently, one can obtain each solution by exploiting the <b>Enumeration</b>
|
||||
interface, which the <b>Query</b> class implements. In this
|
||||
example,
|
||||
we iteratively call hasMoreSolutions() and nextSolution() to
|
||||
exhaustion:
|
||||
<blockquote>
|
||||
<pre><tt><font size="+1">System.out.println( "each solution of descendent_of(X, ralf)");</font></tt></pre>
|
||||
<pre><tt><font size="+1">while ( q4.hasMoreSolutions() ){<br> solution = q4.nextSolution();<br> System.out.println( "X = " + solution.get(X));<br>}</font></tt></pre>
|
||||
</blockquote>
|
||||
In this final example, we reuse the previous variable <b><tt><font
|
||||
size="+1">X</font></tt></b>
|
||||
with a new variable <b><tt><font size="+1">Y</font></tt></b> in a new
|
||||
query
|
||||
<b><tt><font size="+1">q5</font></tt></b>:
|
||||
<blockquote><tt><font size="+1">Variable <b>Y</b> = new Variable();</font></tt>
|
||||
<p><tt><font size="+1">Query <b>q5</b> =</font></tt> <br>
|
||||
<tt><font size="+1"> new Query(</font></tt> <br>
|
||||
<tt><font size="+1">
|
||||
"descendent_of",</font></tt> <br>
|
||||
<tt><font size="+1"> new
|
||||
Term[]
|
||||
{<b>X</b>,<b>Y</b>}</font></tt> <br>
|
||||
<tt><font size="+1"> );</font></tt> </p>
|
||||
<p><tt><font size="+1">while ( <b>q5</b>.hasMoreSolutions() ){</font></tt>
|
||||
<br>
|
||||
<tt><font size="+1"> solution = <b>q5</b>.nextSolution();</font></tt>
|
||||
<br>
|
||||
<tt><font size="+1"> System.out.println( "X = " +
|
||||
solution.get(<b>X</b>)
|
||||
+ ", Y = " + solution.get(<b>Y</b>));</font></tt> <br>
|
||||
<tt><font size="+1">}</font></tt></p>
|
||||
</blockquote>
|
||||
The <b>hasMoreSolutions</b> method of the <b>Query</b> class returns
|
||||
a
|
||||
<b>boolean</b>,
|
||||
indicating whether there are any solutions "left" in the query.
|
||||
If
|
||||
the answer to this is 'yes', then the solution can be obtained in the
|
||||
form
|
||||
of a <b>Hashtable</b> by the <b>nextSolution</b> method.
|
||||
<blockquote><i><font size="-1"><b>Note.</b> By calling <b>hasMoreSolutions</b>
|
||||
you are actually making the query to the Prolog engine; the "answer" to
|
||||
the query is cached in the <b>Query</b> class instance and returned
|
||||
from <b>nextSolution</b>.</font></i></blockquote>
|
||||
<h3>
|
||||
Where to Go From Here</h3>
|
||||
This section provides a brief tutorial on getting started with the
|
||||
High-Level
|
||||
Interface. You should read the <a
|
||||
href="file:///D:/jpl/docs/java_api/high-level_interface.html"><b><span
|
||||
style="font-style: italic;">JPL 2.x</span> Java API overview</b></a>
|
||||
section for more information about using these
|
||||
interfaces.
|
||||
Feel free to consult the <a href="javadoc/index.html"><span
|
||||
style="font-style: italic;">JPL 3.x</span> Java API reference</a>
|
||||
section
|
||||
for detailed information about particular classes.
|
||||
<br>
|
||||
<div align="right">
|
||||
<hr noshade="noshade" width="100%">
|
||||
<div style="text-align: left;">
|
||||
<address>December 2003 (revised)</address>
|
||||
<br>
|
||||
<span style="text-decoration: underline;"></span></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,45 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<title>JPL 3.x Java-calls-Prolog gotchas</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;">
|
||||
JPL 3.x</span> Java API gotchas
|
||||
</h1>
|
||||
<hr width="100%">
|
||||
<h2>arg indexing</h2>
|
||||
<blockquote>the <span style="font-weight: bold;">Term[]</span> args of
|
||||
a <span style="font-weight: bold;">Compound</span> are indexed (like
|
||||
all Java arrays) from zero, whereas in Prolog the args of a structure
|
||||
are conventionally numbered from one.<br>
|
||||
</blockquote>
|
||||
<h2>representing <span style="font-family: monospace;">@(null)</span><br>
|
||||
</h2>
|
||||
<blockquote>there is no <span style="font-weight: bold;">jpl.JNull</span>
|
||||
class: instead, use <span style="font-family: monospace;">new
|
||||
JRef(null)</span> to represent <span style="font-family: monospace;">@(null)</span>
|
||||
(which itself represents Java's <span style="font-style: italic;">null</span>).
|
||||
If you don't know what this all means, don't worry: it only affects
|
||||
those writing hybrid Java+Prolog programs which call each other
|
||||
nestedly.<br>
|
||||
</blockquote>
|
||||
<h2>all solutions of a Query with no solutions</h2>
|
||||
<div style="margin-left: 40px;"><span style="font-weight: bold;">Query.allSolutions()</span>
|
||||
now returns an empty array of <span style="font-weight: bold;">Map</span>
|
||||
if the <span style="font-weight: bold;">Query</span> has no solutions
|
||||
(in 1.x versions it inconsistently returned null).<br>
|
||||
</div>
|
||||
<br>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<address><a href="mailto:p.singleton@keele.ac.uk">Paul Singleton</a></address>
|
||||
<address>
|
||||
drafted Wednesday 4th February 2004<br>
|
||||
<br>
|
||||
</address>
|
||||
</body>
|
||||
</html>
|
@ -1,537 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="CONTENT-TYPE"
|
||||
content="text/html; charset=windows-1252">
|
||||
<title>High-Level Interface</title>
|
||||
<meta name="GENERATOR" content="StarOffice 7 (Win32)">
|
||||
<meta name="AUTHOR" content="Fred Dushin">
|
||||
<meta name="CREATED" content="20040216;23165440">
|
||||
<meta name="CHANGEDBY" content="Paul Singleton">
|
||||
<meta name="CHANGED" content="20040216;23225011">
|
||||
<meta name="KEYWORDS" content="JPL,java,prolog">
|
||||
<style>
|
||||
<!--
|
||||
P { color: #000000 }
|
||||
H3 { color: #000000 }
|
||||
BLOCKQUOTE { color: #000000 }
|
||||
PRE { color: #000000 }
|
||||
H4 { color: #000000 }
|
||||
A:link { color: #00009c }
|
||||
A:visited { color: #ce31ce }
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body lang="en-US" text="#000000" link="#00009c" vlink="#ce31ce"
|
||||
bgcolor="#ffffff" dir="ltr">
|
||||
<h1><b><span style="font-style: italic;">JPL 3.x</span>
|
||||
Java API overview</b><font size="7"><b><br>
|
||||
</b></font></h1>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<h3>Table of Contents</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Introduction">Introduction</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#The%20Class%20Hierarchy">The
|
||||
Class Hierarchy</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a
|
||||
href="#Initializing%20and%20Terminating%20Prolog">Initializing Prolog</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Creating%20Terms">Creating
|
||||
Terms</a> </p>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Atoms">Atoms</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Variables">Variables</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Integers">Integers</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Floats">Floats</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Compound%20Terms">Compound
|
||||
Terms</a> </p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Creating%20Queries">Creating
|
||||
Queries</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#The%20Util%20Class">The
|
||||
Util Class</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Querying%20Prolog">Querying
|
||||
Prolog</a> </p>
|
||||
<ul>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a
|
||||
href="#Obtaining%20one%20Solution">Obtaining One Solution</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a
|
||||
href="#Obtaining%20all%20Solutions">Obtaining all Solutions</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Ground%20Queries">Discovering
|
||||
whether a Query has any Solutions</a></p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Terminating%20Queries">Terminating
|
||||
Queries</a> </p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Multi-Threaded%20Queries">Multi-Threaded
|
||||
Queries</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Exceptions">Exceptions</a>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Debugging">Debugging</a> </p>
|
||||
</li>
|
||||
<li>
|
||||
<p style="margin-bottom: 0cm;"><a href="#Version">Version
|
||||
information</a></p>
|
||||
</li>
|
||||
<li>
|
||||
<p><a href="#What%27s%20Missing">What's Missing</a> </p>
|
||||
</li>
|
||||
</ul>
|
||||
<hr size="4" noshade="noshade">
|
||||
<h3><a name="Introduction"></a>Introduction</h3>
|
||||
<p>The <b><i>JPL 3.0.1 Java-calls-Prolog API</i></b> provides a set
|
||||
of classes that hide almost all of the messy detail in the <a
|
||||
href="low-level_interface.html">Low-Level
|
||||
Interface</a>. It is less flexible than the Low-Level
|
||||
Interface, but it also has less of a learning curve, and in many ways
|
||||
is more natural and Prolog-like than the Low-Level Interface. </p>
|
||||
<p>The Java package <b>jpl</b> contains all of the classes in this
|
||||
interface. None of the classes correspond with any of the data
|
||||
types in the Prolog Foreign Language Interface (FLI). <br>
|
||||
</p>
|
||||
<h3><a name="The Class Hierarchy"></a>The Class Hierarchy</h3>
|
||||
<p>The <b><i>API</i></b> consists of the following class hierarchy: </p>
|
||||
<pre style="margin-left: 3cm; margin-right: 3cm;">Term<br> |<br> +--- Variable<br> |<br> +--- Compound<br> | |<br> | +--- Atom<br> |<br> +--- Integer<br> |<br> +--- Float<br> <br>Query<br> <br>JPLException<br> |<br> +-- PrologException</pre>
|
||||
<p><b>Term</b> is an abstract class: only its subclasses can be
|
||||
instantiated. </p>
|
||||
<p>Each instance of <b>Query</b> contains a <b>Term</b> (denoting the
|
||||
goal which is to be proven), and much more besides. </p>
|
||||
<p>Each instance of <b>Compound</b> has a (java.lang.String) name and
|
||||
an array of (<b>Term</b>) arguments (it must have at least one). </p>
|
||||
<p><b>Atom</b> is a specialisation of <b>Compound</b> with zero
|
||||
arguments. <br>
|
||||
</p>
|
||||
<h3><a name="Initializing and Terminating Prolog"></a>Initializing
|
||||
Prolog</h3>
|
||||
<p>The <b>jpl.JPL</b> class initializes the Prolog VM (e.g.
|
||||
<tt>libpl.dll</tt> in Win32), if necessary, when the first <b>Query</b>
|
||||
is activated, using default parameter values. Before
|
||||
initialization takes place, these default values can be read, and
|
||||
altered. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">public String[] getDefaultInitArgs();<br>public void setDefaultInitArgs(String[] args);</pre>
|
||||
<p>After initialization, the parameter values which were actually used
|
||||
can be read. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public String[] getActualInitArgs();</pre>
|
||||
<p>(This method returns <tt>null</tt> if initialization has not
|
||||
occurred, and thus it can be used as a test.) <br>
|
||||
This allows Java
|
||||
library classes to employ <b><i>JPL</i></b> without placing any
|
||||
burden of initialization upon the applications which use them.
|
||||
It can also ensure that the Prolog VM is initialized only if and when
|
||||
it is
|
||||
needed. </p>
|
||||
<p>Explicit initialization is supported as in <b><i>JPL 1.0.1</i></b>:
|
||||
</p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">public void init();<br>public void init( String args[] );</pre>
|
||||
<p>Java code which requires a Prolog VM to be initialized in a
|
||||
particular way can check whether initialization has already occurred:
|
||||
if not, it can specify parameters and force it to be attempted; if
|
||||
so, it can retrieve and check the initialisation parameters actually
|
||||
used, to determine whether the initialization meets its requirements.
|
||||
<br>
|
||||
<br>
|
||||
This version of <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
does not support reinitialization of a Prolog VM. </p>
|
||||
<p>For details about the legal parameter values, see your local
|
||||
Prolog documentation. Most users will rely on automatic
|
||||
initialization. <br>
|
||||
</p>
|
||||
<h3><a name="Creating Terms"></a>Creating Terms</h3>
|
||||
<p>The <b>Term</b>-based classes in the <span
|
||||
style="font-weight: bold;">jpl</span> package are best
|
||||
thought of as a structured concrete syntax for Prolog terms: they do
|
||||
not correspond to any particular terms within the Prolog engine;
|
||||
rather, they are a means for constructing queries which can called
|
||||
within Prolog, and they are also a means for representing (and
|
||||
exploring) the results
|
||||
of such calls. <br>
|
||||
<b>Term</b> instances are never changed by any
|
||||
activity within the Prolog engine: indeed; it doesn't know of their
|
||||
existence. <br>
|
||||
The <b>Term</b> class is
|
||||
abstract, so it cannot be directly instantiated; to create a Term,
|
||||
create an instance of one of its five subclasses. </p>
|
||||
<blockquote><font size="2"><b><i>Note.</i></b> <i>A <b>Term</b> in
|
||||
the <span style="font-weight: bold;">jpl</span> packagee is not to be
|
||||
confused with a <b>term_t</b> in
|
||||
the <span style="font-weight: bold;">jpl.fli</span> package. The
|
||||
latter has an important internal role in
|
||||
managing state in the Prolog stack; the former is just a data
|
||||
structure in the Java heap.</i></font></blockquote>
|
||||
<h4><a name="Atoms"></a>Atoms</h4>
|
||||
<p>An <b>Atom</b> is a <b>Compound</b> with zero arguments. To
|
||||
create an <b>Atom</b>, pass a (String) name to its constructor: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Atom aristotle = new Atom("aristotle");<br>Atom alexander = new Atom("alexander");</pre>
|
||||
<blockquote><i><font size="2"><b>Note.</b> Two <b>Atom</b>s by
|
||||
the same name
|
||||
are effectively identical. Feel free to reuse <b>Atom</b>
|
||||
instances when constructing compound <b>Term</b>s.</font></i> <br>
|
||||
<i><font size="2"><b>Note.</b>
|
||||
The name in an <b>Atom</b> need not be lower case: it can be any
|
||||
UTF-8 string (?).</font></i></blockquote>
|
||||
<p>The <b>Atom</b> class inherits <b>Compound</b>'s <b>name()</b>
|
||||
accessor to obtain the name of the <b>Atom</b> (it also inherits
|
||||
<b>Compound</b>'s <b>arity()</b> accessor, but this always returns
|
||||
zero for an <b>Atom)</b>. <span style="font-weight: bold;">Atom</span>'s
|
||||
<span style="font-weight: bold;">toString()</span> method yields a
|
||||
String form of the atom's name which is quoted, iff necessary,
|
||||
according to Prolog source text syntax, and can thus be used when
|
||||
constructing fragments of Prolog source text, e.g. new queries.<br>
|
||||
</p>
|
||||
<h4><a name="Variables"></a>Variables</h4>
|
||||
<p><b>Variable</b>s have identifying
|
||||
names, which must comply with conventional Prolog source text syntax. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">Variable X = new Variable("X"); // a regular variable</pre>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">Variable X = new Variable("_"); // an "anonymous" variable</pre>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">Variable X = new Variable("_Y"); // a "dont-tell-me" variable, whose bindings we don't want to know</pre>
|
||||
<h4><a name="Integers"></a>Integers</h4>
|
||||
<p>An <b>Integer</b> is a specialized <b>Term</b> that holds a Java <b>long</b>
|
||||
value. This class corresponds to the Prolog <i>integer</i>
|
||||
type (SWI-Prolog integers are 32-bit for now, but we are looking ahead
|
||||
and beyond...). </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">jpl.Integer i = new jpl.Integer(5);</pre>
|
||||
<p>Be careful to avoid confusion with <tt>java.lang.integer</tt>, e.g.
|
||||
by always qualifying the class name as in the example above. </p>
|
||||
<p>The <b>jpl.Integer</b> class has an <b>intValue()</b> accessor to
|
||||
obtain the <b>int</b> value of an instance, and also <span
|
||||
style="font-weight: bold;">longValue()</span>, <span
|
||||
style="font-weight: bold;">floatValue()</span> and <span
|
||||
style="font-weight: bold;">doubleValue()</span> (just like
|
||||
java.lang.Integer has). </p>
|
||||
<h4><a name="Floats"></a>Floats</h4>
|
||||
<p>A <b>Float</b> is a specialized <b>Term</b> that holds a Java
|
||||
<b>double</b> value. This class corresponds to the Prolog float
|
||||
type (SWI-Prolog floats are 64-bit ISO/IEC), on which arithmetic
|
||||
operations can be performed. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">jpl.Float f = new jpl.Float(3.14159265);</pre>
|
||||
<p>As with integers, avoid confusion between <b>jpl.Float</b> and
|
||||
<b>java.lang.Float</b>. </p>
|
||||
<p>The <b>jpl.Float</b> class has a <b>doubleValue()</b> accessor to
|
||||
obtain
|
||||
the <b>double</b> value of an instance, and also a <span
|
||||
style="font-weight: bold;">floatValue()</span> accessor. </p>
|
||||
<h4><a name="Compound Terms"></a>Compounds</h4>
|
||||
<p>A <b>Compound</b> is a <b>Term</b> that contains a name and a
|
||||
sequence (array) of <b>Term</b> arguments, as reflected in this
|
||||
class's constructor: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Compound teacher_of = new Compound(<br> "teacher_of",<br> new Term[] {<br> new Atom("aristotle"),<br> new Atom("alexander")<br> }<br> );</pre>
|
||||
<p>Note the use of Java's <i>anonymous array</i> syntax</p>
|
||||
<pre style="margin-left: 0.85cm; margin-bottom: 0.5cm;">new Term[] { ..., ... }</pre>
|
||||
<p>to specify the arguments (any quantity >= 1) of the <b>Compound</b>.<br>
|
||||
<br>
|
||||
In
|
||||
this example, the Java variable <tt>teacher_of</tt> refers to a
|
||||
<b>Compound</b> instance, which represents the Prolog term
|
||||
<i>teacher_of(aristotle,alexander).</i> </p>
|
||||
<blockquote><a name="Note.vars"></a><font size="2"><i><b>Note.</b> Care
|
||||
should be taken in creating <b>Compound</b> <b>Term</b>s, especially
|
||||
if <b>Variable</b> references are used. For example, the
|
||||
following construction:</i></font></blockquote>
|
||||
<pre style="margin-left: 2cm; margin-right: 2cm;"><font size="2"><i>Variable X = new Variable();</i></font>
|
||||
<font size="2"><i>Variable Y = new Variable();</i></font>
|
||||
<font size="2"><i>Compound father_of = new Compound( "teacher_of", new Term[]{X,Y});</i></font></pre>
|
||||
<blockquote><font size="2"><i>corresponds with the Prolog term </i><font
|
||||
face="monospace">teacher_of(X,Y)</font><i>,
|
||||
whereas</i></font> </blockquote>
|
||||
<pre style="margin-left: 2cm; margin-right: 2cm;"><font size="2"><i>Variable X = new Variable();</i></font>
|
||||
<font size="2"><i>Compound father_of = new Compound( "teacher_of", new Term[]{X,X});</i></font></pre>
|
||||
<blockquote><font size="2"><i>corresponds with the Prolog term </i><font
|
||||
face="monospace">teacher_of(X,X)</font><i>,
|
||||
two terms that can resolve very differently depending on the Prolog
|
||||
database. The general rule of thumb should be, reuse </i><b>Term</b>
|
||||
<i>references that are or contain <b>Variable</b>s only if you know
|
||||
that that is what you mean.</i></font></blockquote>
|
||||
<p>To obtain the (String) name of a <b>Compound</b>, use the <b>name()</b>
|
||||
accessor method. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public String name();</pre>
|
||||
<p>To obtain the arity of a <b>Compound</b>, use the <b>arity()</b>
|
||||
accessor method. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public int arity();</pre>
|
||||
<p>To obtain an array of a <b>Compound</b>'s arguments, use the <b>args()</b>
|
||||
accessor method. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public Term[] args();</pre>
|
||||
<p>To obtain the <i>ith</i> argument of a compound (numbered from 1),
|
||||
use the <b>arg() </b>accessor method (with an <b>int </b>parameter
|
||||
value between 1 and Arity inclusive). </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public Term arg( int i);</pre>
|
||||
<p>To obtain the <i>ith</i> argument of a compound (numbered from 0),
|
||||
use the <b>arg0() </b>accessor method (with an <b>int </b>parameter
|
||||
value between 0 and Arity-1 inclusive). </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public Term arg0( int i);</pre>
|
||||
<h3><a name="Creating Queries"></a>Queries</h3>
|
||||
<p>A <b>Query</b> contains a <b>Term</b>, representing a Prolog goal:
|
||||
</p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Term goal = new Compound( "teacher_of", new Term[]{new Atom("aristotle"),new Atom("alexander")});<br>Query q = new Query( goal );</pre>
|
||||
<p>The <b>Query</b> <b>q</b> in this example represents the Prolog
|
||||
query
|
||||
</p>
|
||||
<blockquote><i>?- teacher_of(aristotle,alexander).</i></blockquote>
|
||||
<h3><a name="The Util Class"></a>The Util Class</h3>
|
||||
<p>The <b>Util</b> class provides various static utility methods for
|
||||
managing <b><i>JPL</i></b> <b>Term</b>s. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">Term termArrayToList( Term t[])<br>Term[] listToTermArray( Term t)<br>Term[] bindingsToTermArray( Hashtable bs)</pre>
|
||||
<h3><a name="Querying Prolog"></a>Querying Prolog</h3>
|
||||
<p>To ask the Prolog engine a query via the High-Level Interface, one
|
||||
first constructs a <b>Query</b> instance, as in the above example,
|
||||
and then uses the <b>java.util.Enumeration</b> interface, which the
|
||||
<b>Query</b> class implements, to obtain solutions (where a
|
||||
"solution" is what is known in logic programming jargon as
|
||||
a <i>substitution</i>, which is a collection of <i>bindings</i>, each
|
||||
of which relates one of the <b>Variables</b> within the <b>Query</b>'s
|
||||
goal to a <b>Term</b> representation of the Prolog term to which the
|
||||
corresponding Prolog variable was bound by the proof). </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">public interface Enumeration {<br> public boolean hasMoreElements();<br> public Object nextElement();<br>}</pre>
|
||||
<p>The <b>hasMoreElements()</b> method can be used to determine
|
||||
whether
|
||||
a <b>Query</b> has any (or any further) solutions. In the above
|
||||
example, the method call </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">q.hasMoreElements()</pre>
|
||||
<p>returns <b>true</b> if the Prolog query <i>teaches(aristotle,alexander)</i>
|
||||
is provable, and <b>false</b> otherwise. In this example, the
|
||||
Prolog query is a ground term, so the "solution" to the
|
||||
<b>Query</b> is merely a truth value, and is given by the
|
||||
<b>hasMoreElements()</b> method. </p>
|
||||
<p>Where a <b>Query</b>'s goal contains <b>Variable</b>s, on the
|
||||
other hand, its execution yields a sequence of bindings of these
|
||||
<b>Variable</b>s to <b>Term</b>s. The High-Level interface uses
|
||||
a <b>java.util.Hashtable</b> to represent these bindings; the <b>Object</b>s
|
||||
in the table are <b>Term</b>s, keyed (uniquely) by <b>Variable</b>
|
||||
instances. </p>
|
||||
<p>For example, to print all of Aristotle's pupils, i.e., all the
|
||||
bindings of <b>X</b> which satisfy <i>teaches(aristotle,X)</i>, one
|
||||
could write </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Variable X = new Variable();<br>Query q = new Query( "teaches", new Term[]{new Atom("aristotle"),X});<br>while ( q.hasMoreElements() ) {<br> Hashtable binding = (Hashtable) q.nextElement();<br> Term t = (Term) binding.get( X);<br> System.out.println( t);<br>}</pre>
|
||||
<blockquote><i><font size="2"><b>Note.</b> If a <b>Query</b>'s
|
||||
goal contains
|
||||
no variables (i.e. it is "ground"), the <b>Query.
|
||||
nextElement() </b>method will still return a <b>Hashtable</b> for
|
||||
each solution, although each table will be empty.</font></i> <br>
|
||||
<i><font size="2"><b>Note.</b>
|
||||
If a <b>Query</b>'s goal contains more than one occurrence of some <b>Variable</b>,
|
||||
then each solution <b>Hashtable</b> will have
|
||||
only one binding for that <b>Variable</b>.</font></i></blockquote>
|
||||
<p>For convenience, the <b>Query</b> class provides a
|
||||
<b>hasMoreSolutions()</b> and <b>nextSolution() </b>method with the
|
||||
following signatures: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">public boolean hasMoreSolutions();<br>public Hashtable nextSolution();</pre>
|
||||
<p>Using the <b>nextSolution()</b> method avoids having to cast the
|
||||
result of the <b>nextElement() </b>method to <b>Hashtable</b>. </p>
|
||||
<h4><a name="Obtaining one Solution"></a>Obtaining one Solution</h4>
|
||||
<p>Often, you'll just want just the first solution to a query.
|
||||
The <b>Query</b> class provides a method for this: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public Hashtable oneSolution();</pre>
|
||||
<p>If the <b>Query</b> has no solutions, this method returns <b>null</b>;
|
||||
otherwise, a non-null return indicates success. If the <b>Query</b>
|
||||
is a ground query (i.e. contains no variables), the returned
|
||||
<b>Hashtable</b> will be empty (i.e. will contain no bindings). </p>
|
||||
<h4><a name="Obtaining all Solutions"></a>Obtaining all Solutions</h4>
|
||||
<p>You may want all solutions to a query. The <b>Query</b>
|
||||
class provides a method for this: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public Hashtable[] allSolutions();</pre>
|
||||
<p>The returned array will contain all the <b>Query</b>'s solutions,
|
||||
in
|
||||
the order they were obtained (as with Prolog's findall/3, duplicates
|
||||
are not removed). If the <b>Query</b> has no solutions, this
|
||||
method returns an empty array (N.B. not <b>null</b> as in <b>JPL
|
||||
1.0.1</b>). </p>
|
||||
<h4><a name="Ground Queries"></a>Discovering whether a query has any
|
||||
solutions</h4>
|
||||
<p>Sometimes an application is interested only in whether or not a
|
||||
query is provable, but not in any details of its possible
|
||||
solutions.
|
||||
The <b>Query</b> class provides the <b>hasSolution</b> method for
|
||||
this common special case: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public boolean hasSolution();</pre>
|
||||
<p>This method is equivalent to (but sometimes more efficient than)
|
||||
calling <b>oneSolution</b> and asking whether the return value is
|
||||
non-<b>null</b> (i.e. whether the query succeeded). </p>
|
||||
<h4><a name="Terminating Queries"></a>Terminating Queries</h4>
|
||||
<p>Queries terminate automatically when the <b>hasMoreSolutions()
|
||||
</b>method returns <b>false</b>, and once a <b>Query</b> is
|
||||
terminated, another can be started. Unfortunately, the Prolog
|
||||
engine is currently such that it can handle only one query at a
|
||||
time. As a result, <i>it is not possible, in the High-Level
|
||||
Interface, to ask two different <b>Query</b> objects whether they
|
||||
have any solutions without first exhausting all of the solutions of
|
||||
one.</i> Therefore, programmers must take care to ensure that
|
||||
all solutions are exhausted before starting new queries. This
|
||||
has particular importance in multi-threaded contexts, but it can also
|
||||
present difficulties even in single-threaded programs. See the
|
||||
<a href="#Multi-Threaded%20Queries">Multi-Threaded Queries</a> section
|
||||
for a discussion of how to manage Queries in multi-threaded contexts.
|
||||
</p>
|
||||
<p>To terminate a <b>Query</b> before all of its solutions have been
|
||||
exhausted, use the <b>rewind()</b> method: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public void rewind();</pre>
|
||||
<p>This method stops a <b>Query</b>, setting it back into a state
|
||||
where
|
||||
it can be restarted. It also permits other queries to be
|
||||
started. Here is an example in which the first three solutions
|
||||
to the <b>Query</b> are obtained: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Query query = // obtain Query somehow<br>for ( int i = 0; i < 3 && query.hasMoreSolutions(); ++i ){<br> Hashtable solution = query.nextSolution();<br> // process solution...<br>}<br>query.rewind();</pre>
|
||||
<p>You may call <b>rewind()</b> on an inactive <b>Query</b> without
|
||||
ill-effect, and you should <i>always</i> call rewind if you have not
|
||||
exhausted all solutions to a <b>Query</b>. </p>
|
||||
<p>If you are using the <b>query()</b>, <b>oneSolution()</b>, or
|
||||
<b>allSolutions() </b>methods, you need not worry about rewinding the
|
||||
<b>Query</b>; it is done automatically for you. <br>
|
||||
</p>
|
||||
<h3><a name="Multi-Threaded Queries"></a>Multi-Threaded Queries</h3>
|
||||
<p>The Prolog engine can only have one query open at a time.
|
||||
This presents difficulties for multi-threaded programs in which the
|
||||
programmer has no control over when Queries are executed. <b><i>JPL</i></b>
|
||||
makes as much of the High-Level Interface thread-safe as it can.
|
||||
Unfortunately, the programmer must take responsibility in a limited
|
||||
set of circumstances to ensure that all calls to the High-Level
|
||||
Interface are thread safe. </p>
|
||||
<p>It is worth noting that if the programmer confines use of Query
|
||||
methods to <b>hasSolution()</b>, <b>oneSolution()</b>, and
|
||||
<b>allSolutions()</b>, that subset of the <b>Query</b> interface <i>is</i>
|
||||
thread-safe. For many programmers, these methods suffice.
|
||||
However, if the <b>hasMoreSolutions()</b>, <b>hasMoreElements()</b>,
|
||||
<b>nextSolution()</b>, <b>nextElement()</b>, or <b>rewind()</b>
|
||||
methods are explicitly invoked, thread-safety is lost. The
|
||||
problem is that while the blocks of these programs are synchronized
|
||||
so that in effect no two <b>Query</b> objects can invoke any of these
|
||||
methods concurrently, there is nothing that prevents a <b>Query</b>
|
||||
object in one thread from calling one of these methods, and another
|
||||
<b>Query</b> object in a different thread from calling this same
|
||||
method, or even another that could produce indeterminate results. </p>
|
||||
<p>The <b>Query</b> class, however, does make synchronization around
|
||||
these methods possible by providing a reference to the monitor object
|
||||
that locks competing threads from executing critical code. The
|
||||
reference is obtained by the static method </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm; margin-bottom: 0.5cm;">public static Object lock();</pre>
|
||||
<p>Thus, programmers can wrap calls to these non-thread-safe methods in
|
||||
synchronized blocks, using the lock object to prevent other threads
|
||||
from entering any of these methods. To write a thread-safe loop
|
||||
to process all of a <b>Query</b>'s solutions, for example, one might
|
||||
write </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">Query query = // obtain Query<br>synchronized ( Query.lock() ){<br> while ( query.hasMoreSolutions() ){<br> Hashtable solution = query.nextSolution();<br> // process solution...<br> }<br>}</pre>
|
||||
<p><br>
|
||||
Note that the <b>query()</b>, <b>oneSolution()</b>, and
|
||||
<b>allSolutions() </b>methods effectively do the same as the above
|
||||
code snippet, so there is no need to explicitly synchronized on the
|
||||
<b>Query</b>'s monitor object when these methods are called. <br>
|
||||
|
||||
</p>
|
||||
<h3><a name="Exceptions"></a>Exceptions</h3>
|
||||
<p>The <b><i>JPL</i></b> package provides fairly crude exception
|
||||
handling. The base class for all <b><i>JPL</i></b> Exceptions
|
||||
is <b>JPLException</b>, which is a <b>java.lang.RuntimeException</b>
|
||||
(and hence need not be declared), and which will be thrown in the
|
||||
absence of any other kind of exception that can be thrown, usually as
|
||||
the result of some programming error. Converting the exception
|
||||
to a <b>java.lang.String</b> should provide some descriptive
|
||||
information about the reason for the error. All other <b><i>JPL</i></b>
|
||||
excpetion classes extend this class. Currently there are two,
|
||||
the <b>QueryInProgressException</b> class and the <b>PrologException</b>
|
||||
class. </p>
|
||||
<p>A <b>QueryInProgressException</b> is thrown when a <b>Query</b> is
|
||||
opened while another is in progress; this exception can be caught in
|
||||
multi-threaded situations, but a better strategy for managing
|
||||
multi-threaded situations is discussed in the <a
|
||||
href="#Multi-Threaded%20Queries">Multi-Threaded
|
||||
Queries</a> section. If you obey the rules discussed in this
|
||||
section, you should have no reason to catch this exception. </p>
|
||||
<p>A <b>PrologException</b> is thrown either during execution of a
|
||||
Prolog built-in predicate or by an explicit call, by Prolog
|
||||
application code, of the Prolog predicate <i>throw/1.</i> </p>
|
||||
<p>There is currently no means of gracefully handling exceptions
|
||||
caused by malformed parameters (e.g., undefined predicates) passed
|
||||
through the High-Level Interface to the Prolog engine (?). <br>
|
||||
|
||||
</p>
|
||||
<h3><a name="Debugging"></a>Debugging</h3>
|
||||
<p>Each <b>Term</b> type (together with the <b>Query</b> class)
|
||||
supports an implementation of <b>toString()</b> which returns a
|
||||
more-or-less familiar Prolog textual representation of the <b>Term</b>
|
||||
or <b>Query</b>. </p>
|
||||
<p>Sometimes, however, this information is not sufficient, so we have
|
||||
provided a method <b>debugString()</b> which provides a more verbose
|
||||
and explicit representation, including the types (atom, integer etc)
|
||||
of each term and subterm. </p>
|
||||
<p>In general, <b>Term</b> and <b>Query</b> instances are represented
|
||||
in the form (<i>type data</i>), where <i>type</i> is the name of the
|
||||
type (e.g., <b>Atom</b>, <b>Compound</b>, <b>Tuple</b>, etc.), and
|
||||
<i>data</i> is a representation of the contents of the <b>Term</b>.
|
||||
For example, if the <b>Term</b> is an <b>Atom</b>, the data is the
|
||||
<b>Atom</b>'s name. The arguments of <b>Compounds</b> are
|
||||
represented by comma-separated lists within square brackets ('['
|
||||
']'). </p>
|
||||
<p>Viewing the structure of a <b>Term</b> or <b>Query</b> can be
|
||||
useful in determining whether an error lies on the Prolog or Java
|
||||
side of your JPL applications. </p>
|
||||
<p>Perhaps better still, <b>Term</b> implements (in a basic but
|
||||
adequate way) the <b>javax.swing.TreeModel</b> interface, and its
|
||||
<b>display()</b> method creates a <b>JFrame</b> containing a
|
||||
browseable <b>JTree</b> representation of the term. <br>
|
||||
</p>
|
||||
<h3><a name="Version"></a>Version information</h3>
|
||||
<p>To obtain the current version of <b><i>JPL</i></b> you are using,
|
||||
you may obtain a reference to the <b>jpl.Version</b> static instance
|
||||
of the <b><i>JPL</i></b> class by calling the <b>JPL.version() </b>static
|
||||
method. This will return a <b>jpl.Version</b> structure, which
|
||||
has the following final fields: </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">package jpl;<br>public class Version {<br> public final int major; // e.g. 2<br> public final int minor; // e.g. 0<br> public final int patch; // e.g. 2<br> public final java.lang.String status; // e.g. "alpha"<br>}</pre>
|
||||
<p>You may wish to use this class instance to obtain fine-grained
|
||||
information about the current JPL version, e.g.</p>
|
||||
<pre style="margin-left: 0.85cm; margin-bottom: 0.5cm;">if ( JPL.version().major == 2 ) {</pre>
|
||||
<p>You may also simply call the <b>version_string() </b>static method
|
||||
of
|
||||
the <b>jpl.JPL</b> class. This will return a <b>java.lang.String</b>
|
||||
representation of the current <b><i>JPL</i></b> version. </p>
|
||||
<p>The version string can be written to the standard output stream by
|
||||
running the <b>main()</b> method of the <b>jpl.JPL</b> class. </p>
|
||||
<pre style="margin-left: 1cm; margin-right: 1cm;">linux% java jpl.JPL<br>JPL 2.0.2-alpha</pre>
|
||||
<h3><a name="What's Missing"></a>What's Missing</h3>
|
||||
<p style="margin-bottom: 0cm;">The current implementation of the
|
||||
High-Level Interface lacks support for modules, and for multiple
|
||||
Prolog engines.<br>
|
||||
<br>
|
||||
</p>
|
||||
<hr size="4" noshade="noshade">
|
||||
<p align="right" style="margin-bottom: 0cm;"><a href="index.html">up</a>
|
||||
<a href="low-level_interface.html">prev</a> next <a
|
||||
href="api/packages.html">API</a></p>
|
||||
</body>
|
||||
</html>
|
@ -1,166 +0,0 @@
|
||||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.7 [en] (WinNT; I) [Netscape]">
|
||||
|
||||
<meta name="Author" content="Fred Dushin">
|
||||
|
||||
<meta name="Keywords" content="java,prolog">
|
||||
<title>JPL A Java Interface to Prolog</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#ffffff" link="#00009c" vlink="#ce31ce"
|
||||
alink="#ff0000">
|
||||
|
||||
<hr noshade="noshade" width="100%">
|
||||
<center>
|
||||
<p><img src="logo.jpg" nosave="" height="113" width="204">
|
||||
<br>
|
||||
<i>A Java Interface to Prolog</i></p>
|
||||
</center>
|
||||
|
||||
<h3> <a name="News"></a>News</h3>
|
||||
March 18, 2003
|
||||
<ul>
|
||||
<li> JPL 2.0.2 re-released.</li>
|
||||
|
||||
<ul>
|
||||
<li>see <a href="release_notes_202.html">Release Notes</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
May 5, 1999
|
||||
<ul>
|
||||
<li> JPL 1.0.1 released. This release contains the following changes:</li>
|
||||
|
||||
<ul>
|
||||
<li> Fixed a bug with the representation of Tuples. They are now
|
||||
<i>always</i> binary terms, though generally structured as binary
|
||||
trees. The interface is the same, except we now require that Tuples
|
||||
contain <i>at least</i> two elements. (The single element constructor
|
||||
has been removed, but I consider this a patch, not an interface change)</li>
|
||||
<li> Added an ith() accessor to the Compound and Query classes. This is
|
||||
used to obtain the ith element in the array of Terms in the Compound or Query.</li>
|
||||
<li> Added a debugString() method to the Term and Query classes.
|
||||
This is used to obtain more detailed information about the structure of the
|
||||
Term or Query.</li>
|
||||
<li> Updated and fixed some of the documentation.</li>
|
||||
<li> JPL is now released under the terms of the Gnu Library Public License,
|
||||
not the Gnu General Public License. All relevant files have been updated.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
See the <a href="#Copyright%20and%20License%20Information">Copyright and
|
||||
License Information</a> section for more information.
|
||||
<p>Feb 25, 1999 </p>
|
||||
|
||||
<ul>
|
||||
<li> JPL 1.0.0 is out. Check the <a href="#Download">download</a>
|
||||
section for information about how to retrieve it. I <i>hope</i> most
|
||||
of the core interfaces are frozen.</li>
|
||||
<li> I am in need of Solaris testers! I have access to a Solaris
|
||||
box, but it has ancient and outdated compilers, libs, etc. If anyone
|
||||
gets this to compile on any platform other than Linux, please send me patches.</li>
|
||||
<li> Eventually I'd like to work out some config scripts. For now
|
||||
you must config manually. Sorry.</li>
|
||||
<li> I have not even tried getting this to run under Windows. Anyone
|
||||
with more expertise (and patience) than I is welcome to give it a go!</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<h3> <a name="General Description"></a>General Description</h3>
|
||||
JPL is a set of Java classes and C functions providing an interface between
|
||||
Java and Prolog. JPL uses the Java Native Interface (JNI) to connect
|
||||
to a Prolog engine through the Prolog Foreign Language Interface (FLI),
|
||||
which is more or less in the process of being standardized in various implementations
|
||||
of Prolog. JPL is not a pure Java implementation of Prolog; it makes
|
||||
extensive use of native implementations of Prolog on supported platforms.
|
||||
The current version of JPL only works with SWI-Prolog.
|
||||
<p>Currently, JPL only supports the embedding of a Prolog engine within the
|
||||
Java VM. Future versions may support the embedding of a Java VM within
|
||||
Prolog, so that, for example, one could take advantage of the rich class structure
|
||||
of the Java environment from within Prolog. </p>
|
||||
|
||||
<p>JPL is designed in two layers, a low-level interface to the Prolog FLI
|
||||
and a high-level Java interface for the Java programmer who is not concerned
|
||||
with the details of the Prolog FLI. The low-level interface is provided
|
||||
for C programmers who may wish to port their C implementations which use
|
||||
the FLI to Java with minimal fuss. </p>
|
||||
|
||||
<h3> <a name="Requirements"></a>Requirements</h3>
|
||||
JPL now requires SWI-Prolog version 3.1.0 or later, which is available
|
||||
at the following URL:
|
||||
<blockquote><a href="http://www.swi-prolog.org/">http://www.swi-prolog.org/</a></blockquote>
|
||||
SWI-Prolog license information is available here:
|
||||
<blockquote><a href="http://www.swi-prolog.org/license.html">http://www.swi-prolog.org/license.html</a></blockquote>
|
||||
You will also need a Java development environment. Sun's Java website
|
||||
is a good place to start:
|
||||
<blockquote><a href="http://java.sun.com/">http://java.sun.com/</a></blockquote>
|
||||
JPL 2.0.2 was developed and tested on Windows NT4, and has not yet been compiled
|
||||
on any non-Windows platform<br>
|
||||
JPL1.0.1 was written and tested on Linux kernel 2.1.24. It should compile
|
||||
on any other UNIX system with a full suite of gnu tools.
|
||||
<h3> <a name="Copyright and License Information"></a>Copyright and License
|
||||
Information</h3>
|
||||
JPL is released under the terms of the Gnu Library Public License:
|
||||
<blockquote><i>Copyright (c) 2003 Paul Singleton. All rights reserved.</i>
|
||||
<i><br>
|
||||
Copyright (c) 1998 Fred Dushin. All rights reserved.</i>
|
||||
<p><i><font size="-1">This library is free software; you can redistribute
|
||||
it and/or modify it under the terms of the GNU Library Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.</font></i> </p>
|
||||
|
||||
<p><i><font size="-1">This library is distributed in the hope that it will
|
||||
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
|
||||
Public License for more details.</font></i></p>
|
||||
</blockquote>
|
||||
This means, among other things, that you may <i>use</i> this software in
|
||||
commercial products without being required to distribute your software under
|
||||
the same licensing terms. See the <a href="lgpl.html">License</a> for
|
||||
more details.
|
||||
<h3> <a name="Documentation"></a>Documentation</h3>
|
||||
The Documentation for JPL is organized into the following sections:
|
||||
<ol>
|
||||
<li> <a href="getting_started.html">Getting Started</a></li>
|
||||
<li> <a href="low-level_interface.html">The Low-Level Interface</a></li>
|
||||
<li> <a href="high-level_interface.html">The High-Level Interface</a></li>
|
||||
<li> <a href="gpl.html">Gnu Public License</a></li>
|
||||
<li> <a href="javadoc/index.html">The JPL API</a></li>
|
||||
|
||||
</ol>
|
||||
|
||||
<h3> <a name="Download"></a>Download (this section is obsolete)</h3>
|
||||
Gnu-zipped, UNIX compressed, and Zipped versions of the source distribution
|
||||
are available at:
|
||||
<blockquote><a
|
||||
href="http://blackcat.cat.syr.edu/%7Efadushin/software/jpl/download">http://blackcat.cat.syr.edu/~fadushin/software/jpl/download</a></blockquote>
|
||||
You may be interested in viewing the <a href="ChangeLog">ChangeLog</a>.
|
||||
|
||||
<p>The latest version of JPL is available by the World Wide Web at the following
|
||||
URL: </p>
|
||||
|
||||
<blockquote><a
|
||||
href="http://blackcat.cat.syr.edu/%7Efadushin/software/jpl">http://blackcat.cat.syr.edu/~fadushin/software/jpl</a></blockquote>
|
||||
Writing free software is only gratifying if you hear from users.
|
||||
Please feel free to contact the author, Fred Dushin, at the following address:
|
||||
|
||||
<blockquote><a href="mailto:fadushin@top.cis.syr.edu">fadushin@top.cis.syr.edu</a></blockquote>
|
||||
|
||||
<div align="right"><font size="-2">Happy Prologging.</font></div>
|
||||
|
||||
<hr noshade="noshade" width="100%"> <br>
|
||||
These pages were created using <a href="http://www.netscape.com">Netscape</a>
|
||||
Communicator, 4.5 for <a href="http://www.linuxppc.org">Linux </a>on the
|
||||
<a href="http://www.chips.ibm.com/products/powerpc/">PowerPC</a>. The
|
||||
JPL logo was made by the <a href="http://www.gimp.org">Gimp</a>. <br>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
@ -1,471 +0,0 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.5 [en] (X11; I; Linux 2.1.24 ppc) [Netscape]">
|
||||
<title>GNU Library General Public License - GNU Project - Free Software Foundation (FSF)</title>
|
||||
<link REV="made" HREF="mailto:webmasters@www.gnu.org">
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF" link="#1F00FF" vlink="#9900DD" alink="#FF0000">
|
||||
|
||||
<h1>
|
||||
GNU Library General Public License</h1>
|
||||
<a href="philosophical-gnu-sm.jpg"><img SRC="philosophical-gnu-sm.jpg" ALT="[image of a Philosophical Gnu]" height=200 width=160></a><a href="/graphics/philosophical-gnu-sm.jpg">
|
||||
(jpeg 7k)</a><a href="/graphics/philosophical-gnu.jpg">(jpeg 141k)</a><a href="/philosophy/gif.html">no
|
||||
gifs due to patent problems</a>
|
||||
<p>
|
||||
<hr>
|
||||
<h2>
|
||||
Table of Contents</h2>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a NAME="TOC1" HREF="lgpl.html#SEC1"></a><a href="lgpl.html#SEC1" NAME="TOC1">GNU
|
||||
LIBRARY GENERAL PUBLIC LICENSE</a></li>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a NAME="TOC2" HREF="lgpl.html#SEC2"></a><a href="lgpl.html#SEC2" NAME="TOC2">Preamble</a></li>
|
||||
|
||||
<li>
|
||||
<a NAME="TOC3" HREF="lgpl.html#SEC3"></a><a href="lgpl.html#SEC3" NAME="TOC3">TERMS
|
||||
AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</a></li>
|
||||
|
||||
<li>
|
||||
<a NAME="TOC4" HREF="lgpl.html#SEC4"></a><a href="lgpl.html#SEC4" NAME="TOC4">How
|
||||
to Apply These Terms to Your New Libraries</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
<h2>
|
||||
<a NAME="SEC1" HREF="lgpl.html#TOC1"></a><a href="lgpl.html#TOC1" NAME="SEC1">GNU
|
||||
LIBRARY GENERAL PUBLIC LICENSE</a></h2>
|
||||
Version 2, June 1991
|
||||
<pre>Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]</pre>
|
||||
|
||||
<h2>
|
||||
<a NAME="SEC2" HREF="lgpl.html#TOC2"></a><a href="lgpl.html#TOC2" NAME="SEC2">Preamble</a></h2>
|
||||
The licenses for most software are designed to take away your freedom to
|
||||
share and change it. By contrast, the GNU General Public Licenses are intended
|
||||
to guarantee your freedom to share and change free software--to make sure
|
||||
the software is free for all its users.
|
||||
<p>This license, the Library General Public License, applies to some specially
|
||||
designated Free Software Foundation software, and to any other libraries
|
||||
whose authors decide to use it. You can use it for your libraries, too.
|
||||
<p>When we speak of free software, we are referring to freedom, not price.
|
||||
Our General Public Licenses are designed to make sure that you have the
|
||||
freedom to distribute copies of free software (and charge for this service
|
||||
if you wish), that you receive source code or can get it if you want it,
|
||||
that you can change the software or use pieces of it in new free programs;
|
||||
and that you know you can do these things.
|
||||
<p>To protect your rights, we need to make restrictions that forbid anyone
|
||||
to deny you these rights or to ask you to surrender the rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies
|
||||
of the library, or if you modify it.
|
||||
<p>For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source code.
|
||||
If you link a program with the library, you must provide complete object
|
||||
files to the recipients so that they can relink them with the library,
|
||||
after making changes to the library and recompiling it. And you must show
|
||||
them these terms so they know their rights.
|
||||
<p>Our method of protecting your rights has two steps: (1) copyright the
|
||||
library, and (2) offer you this license which gives you legal permission
|
||||
to copy, distribute and/or modify the library.
|
||||
<p>Also, for each distributor's protection, we want to make certain that
|
||||
everyone understands that there is no warranty for this free library. If
|
||||
the library is modified by someone else and passed on, we want its recipients
|
||||
to know that what they have is not the original version, so that any problems
|
||||
introduced by others will not reflect on the original authors' reputations.
|
||||
<p>Finally, any free program is threatened constantly by software patents.
|
||||
We wish to avoid the danger that companies distributing free software will
|
||||
individually obtain patent licenses, thus in effect transforming the program
|
||||
into proprietary software. To prevent this, we have made it clear that
|
||||
any patent must be licensed for everyone's free use or not licensed at
|
||||
all.
|
||||
<p>Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain designated
|
||||
libraries. This license is quite different from the ordinary one; be sure
|
||||
to read it in full, and don't assume that anything in it is the same as
|
||||
in the ordinary license.
|
||||
<p>The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to
|
||||
a program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However,
|
||||
in a textual and legal sense, the linked executable is a combined work,
|
||||
a derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
<p>Because of this blurred distinction, using the ordinary General Public
|
||||
License for libraries did not effectively promote software sharing, because
|
||||
most developers did not use the libraries. We concluded that weaker conditions
|
||||
might promote sharing better.
|
||||
<p>However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the libraries
|
||||
themselves. This Library General Public License is intended to permit developers
|
||||
of non-free programs to use free libraries, while preserving your freedom
|
||||
as a user of such programs to change the free libraries that are incorporated
|
||||
in them. (We have not seen how to achieve this as regards changes in header
|
||||
files, but we have achieved it as regards changes in the actual functions
|
||||
of the Library.) The hope is that this will lead to faster development
|
||||
of free libraries.
|
||||
<p>The precise terms and conditions for copying, distribution and modification
|
||||
follow. Pay close attention to the difference between a "work based on
|
||||
the library" and a "work that uses the library". The former contains code
|
||||
derived from the library, while the latter only works together with the
|
||||
library.
|
||||
<p>Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
<h2>
|
||||
<a NAME="SEC3" HREF="lgpl.html#TOC3"></a><a href="lgpl.html#TOC3" NAME="SEC3">TERMS
|
||||
AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</a></h2>
|
||||
<b>0.</b> This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized party
|
||||
saying it may be distributed under the terms of this Library General Public
|
||||
License (also called "this License"). Each licensee is addressed as "you".
|
||||
<p>A "library" means a collection of software functions and/or data prepared
|
||||
so as to be conveniently linked with application programs (which use some
|
||||
of those functions and data) to form executables.
|
||||
<p>The "Library", below, refers to any such software library or work which
|
||||
has been distributed under these terms. A "work based on the Library" means
|
||||
either the Library or any derivative work under copyright law: that is
|
||||
to say, a work containing the Library or a portion of it, either verbatim
|
||||
or with modifications and/or translated straightforwardly into another
|
||||
language. (Hereinafter, translation is included without limitation in the
|
||||
term "modification".)
|
||||
<p>"Source code" for a work means the preferred form of the work for making
|
||||
modifications to it. For a library, complete source code means all the
|
||||
source code for all modules it contains, plus any associated interface
|
||||
definition files, plus the scripts used to control compilation and installation
|
||||
of the library.
|
||||
<p>Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of running
|
||||
a program using the Library is not restricted, and output from such a program
|
||||
is covered only if its contents constitute a work based on the Library
|
||||
(independent of the use of the Library in a tool for writing it). Whether
|
||||
that is true depends on what the Library does and what the program that
|
||||
uses the Library does.
|
||||
<p><b>1.</b> You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate copyright
|
||||
notice and disclaimer of warranty; keep intact all the notices that refer
|
||||
to this License and to the absence of any warranty; and distribute a copy
|
||||
of this License along with the Library.
|
||||
<p>You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
<p><b>2.</b> You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and distribute
|
||||
such modifications or work under the terms of Section 1 above, provided
|
||||
that you also meet all of these conditions: <!-- we use this doubled UL to get the sub-sections indented, --><!-- while making the bullets as unobvious as possible. -->
|
||||
<ul>
|
||||
<li>
|
||||
<b>a)</b> The modified work must itself be a software library.</li>
|
||||
|
||||
<li>
|
||||
<b>b)</b> You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.</li>
|
||||
|
||||
<li>
|
||||
<b>c)</b> You must cause the whole of the work to be licensed at no charge
|
||||
to all third parties under the terms of this License.</li>
|
||||
|
||||
<li>
|
||||
<b>d)</b> If a facility in the modified Library refers to a function or
|
||||
a table of data to be supplied by an application program that uses the
|
||||
facility, other than as an argument passed when the facility is invoked,
|
||||
then you must make a good faith effort to ensure that, in the event an
|
||||
application does not supply such function or table, the facility still
|
||||
operates, and performs whatever part of its purpose remains meaningful.
|
||||
(For example, a function in a library to compute square roots has a purpose
|
||||
that is entirely well-defined independent of the application. Therefore,
|
||||
Subsection 2d requires that any application-supplied function or table
|
||||
used by this function must be optional: if the application does not supply
|
||||
it, the square root function must still compute square roots.)</li>
|
||||
</ul>
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Library, and can be reasonably
|
||||
considered independent and separate works in themselves, then this License,
|
||||
and its terms, do not apply to those sections when you distribute them
|
||||
as separate works. But when you distribute the same sections as part of
|
||||
a whole which is a work based on the Library, the distribution of the whole
|
||||
must be on the terms of this License, whose permissions for other licensees
|
||||
extend to the entire whole, and thus to each and every part regardless
|
||||
of who wrote it.
|
||||
<p>Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to exercise
|
||||
the right to control the distribution of derivative or collective works
|
||||
based on the Library.
|
||||
<p>In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of a
|
||||
storage or distribution medium does not bring the other work under the
|
||||
scope of this License.
|
||||
<p><b>3.</b> You may opt to apply the terms of the ordinary GNU General
|
||||
Public License instead of this License to a given copy of the Library.
|
||||
To do this, you must alter all the notices that refer to this License,
|
||||
so that they refer to the ordinary GNU General Public License, version
|
||||
2, instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in these
|
||||
notices.
|
||||
<p>Once this change is made in a given copy, it is irreversible for that
|
||||
copy, so the ordinary GNU General Public License applies to all subsequent
|
||||
copies and derivative works made from that copy.
|
||||
<p>This option is useful when you wish to copy part of the code of the
|
||||
Library into a program that is not a library.
|
||||
<p><b>4.</b> You may copy and distribute the Library (or a portion or derivative
|
||||
of it, under Section 2) in object code or executable form under the terms
|
||||
of Sections 1 and 2 above provided that you accompany it with the complete
|
||||
corresponding machine-readable source code, which must be distributed under
|
||||
the terms of Sections 1 and 2 above on a medium customarily used for software
|
||||
interchange.
|
||||
<p>If distribution of object code is made by offering access to copy from
|
||||
a designated place, then offering equivalent access to copy the source
|
||||
code from the same place satisfies the requirement to distribute the source
|
||||
code, even though third parties are not compelled to copy the source along
|
||||
with the object code.
|
||||
<p><b>5.</b> A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a work,
|
||||
in isolation, is not a derivative work of the Library, and therefore falls
|
||||
outside the scope of this License.
|
||||
<p>However, linking a "work that uses the Library" with the Library creates
|
||||
an executable that is a derivative of the Library (because it contains
|
||||
portions of the Library), rather than a "work that uses the library". The
|
||||
executable is therefore covered by this License. Section 6 states terms
|
||||
for distribution of such executables.
|
||||
<p>When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a derivative
|
||||
work of the Library even though the source code is not. Whether this is
|
||||
true is especially significant if the work can be linked without the Library,
|
||||
or if the work is itself a library. The threshold for this to be true is
|
||||
not precisely defined by law.
|
||||
<p>If such an object file uses only numerical parameters, data structure
|
||||
layouts and accessors, and small macros and small inline functions (ten
|
||||
lines or less in length), then the use of the object file is unrestricted,
|
||||
regardless of whether it is legally a derivative work. (Executables containing
|
||||
this object code plus portions of the Library will still fall under Section
|
||||
6.)
|
||||
<p>Otherwise, if the work is a derivative of the Library, you may distribute
|
||||
the object code for the work under the terms of Section 6. Any executables
|
||||
containing that work also fall under Section 6, whether or not they are
|
||||
linked directly with the Library itself.
|
||||
<p><b>6.</b> As an exception to the Sections above, you may also compile
|
||||
or link a "work that uses the Library" with the Library to produce a work
|
||||
containing portions of the Library, and distribute that work under terms
|
||||
of your choice, provided that the terms permit modification of the work
|
||||
for the customer's own use and reverse engineering for debugging such modifications.
|
||||
<p>You must give prominent notice with each copy of the work that the Library
|
||||
is used in it and that the Library and its use are covered by this License.
|
||||
You must supply a copy of this License. If the work during execution displays
|
||||
copyright notices, you must include the copyright notice for the Library
|
||||
among them, as well as a reference directing the user to the copy of this
|
||||
License. Also, you must do one of these things: <!-- we use this doubled UL to get the sub-sections indented, --><!-- while making the bullets as unobvious as possible. -->
|
||||
<ul>
|
||||
<li>
|
||||
<b>a)</b> Accompany the work with the complete corresponding machine-readable
|
||||
source code for the Library including whatever changes were used in the
|
||||
work (which must be distributed under Sections 1 and 2 above); and, if
|
||||
the work is an executable linked with the Library, with the complete machine-readable
|
||||
"work that uses the Library", as object code and/or source code, so that
|
||||
the user can modify the Library and then relink to produce a modified executable
|
||||
containing the modified Library. (It is understood that the user who changes
|
||||
the contents of definitions files in the Library will not necessarily be
|
||||
able to recompile the application to use the modified definitions.)</li>
|
||||
|
||||
<li>
|
||||
<b>b)</b> Accompany the work with a written offer, valid for at least three
|
||||
years, to give the same user the materials specified in Subsection 6a,
|
||||
above, for a charge no more than the cost of performing this distribution.</li>
|
||||
|
||||
<li>
|
||||
<b>c)</b> If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above specified
|
||||
materials from the same place.</li>
|
||||
|
||||
<li>
|
||||
<b>d)</b> Verify that the user has already received a copy of these materials
|
||||
or that you have already sent this user a copy.</li>
|
||||
</ul>
|
||||
For an executable, the required form of the "work that uses the Library"
|
||||
must include any data and utility programs needed for reproducing the executable
|
||||
from it. However, as a special exception, the source code distributed need
|
||||
not include anything that is normally distributed (in either source or
|
||||
binary form) with the major components (compiler, kernel, and so on) of
|
||||
the operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
<p>It may happen that this requirement contradicts the license restrictions
|
||||
of other proprietary libraries that do not normally accompany the operating
|
||||
system. Such a contradiction means you cannot use both them and the Library
|
||||
together in an executable that you distribute.
|
||||
<p><b>7.</b> You may place library facilities that are a work based on
|
||||
the Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on the
|
||||
Library and of the other library facilities is otherwise permitted, and
|
||||
provided that you do these two things: <!-- we use this doubled UL to get the sub-sections indented, --><!-- while making the bullets as unobvious as possible. -->
|
||||
<ul>
|
||||
<li>
|
||||
<b>a)</b> Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities. This must
|
||||
be distributed under the terms of the Sections above.</li>
|
||||
|
||||
<li>
|
||||
<b>b)</b> Give prominent notice with the combined library of the fact that
|
||||
part of it is a work based on the Library, and explaining where to find
|
||||
the accompanying uncombined form of the same work.</li>
|
||||
</ul>
|
||||
<b>8.</b> You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense, link with, or distribute the Library
|
||||
is void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under this
|
||||
License will not have their licenses terminated so long as such parties
|
||||
remain in full compliance.
|
||||
<p><b>9.</b> You are not required to accept this License, since you have
|
||||
not signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are prohibited
|
||||
by law if you do not accept this License. Therefore, by modifying or distributing
|
||||
the Library (or any work based on the Library), you indicate your acceptance
|
||||
of this License to do so, and all its terms and conditions for copying,
|
||||
distributing or modifying the Library or works based on it.
|
||||
<p><b>10.</b> Each time you redistribute the Library (or any work based
|
||||
on the Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further restrictions
|
||||
on the recipients' exercise of the rights granted herein. You are not responsible
|
||||
for enforcing compliance by third parties to this License.
|
||||
<p><b>11.</b> If, as a consequence of a court judgment or allegation of
|
||||
patent infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or otherwise)
|
||||
that contradict the conditions of this License, they do not excuse you
|
||||
from the conditions of this License. If you cannot distribute so as to
|
||||
satisfy simultaneously your obligations under this License and any other
|
||||
pertinent obligations, then as a consequence you may not distribute the
|
||||
Library at all. For example, if a patent license would not permit royalty-free
|
||||
redistribution of the Library by all those who receive copies directly
|
||||
or indirectly through you, then the only way you could satisfy both it
|
||||
and this License would be to refrain entirely from distribution of the
|
||||
Library.
|
||||
<p>If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply, and the section as a whole is intended to apply in other circumstances.
|
||||
<p>It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any such
|
||||
claims; this section has the sole purpose of protecting the integrity of
|
||||
the free software distribution system which is implemented by public license
|
||||
practices. Many people have made generous contributions to the wide range
|
||||
of software distributed through that system in reliance on consistent application
|
||||
of that system; it is up to the author/donor to decide if he or she is
|
||||
willing to distribute software through any other system and a licensee
|
||||
cannot impose that choice.
|
||||
<p>This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
<p><b>12.</b> If the distribution and/or use of the Library is restricted
|
||||
in certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may
|
||||
add an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus excluded.
|
||||
In such case, this License incorporates the limitation as if written in
|
||||
the body of this License.
|
||||
<p><b>13.</b> The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time. Such
|
||||
new versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
<p>Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free Software
|
||||
Foundation. If the Library does not specify a license version number, you
|
||||
may choose any version ever published by the Free Software Foundation.
|
||||
<p><b>14.</b> If you wish to incorporate parts of the Library into other
|
||||
free programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is copyrighted
|
||||
by the Free Software Foundation, write to the Free Software Foundation;
|
||||
we sometimes make exceptions for this. Our decision will be guided by the
|
||||
two goals of preserving the free status of all derivatives of our free
|
||||
software and of promoting the sharing and reuse of software generally.
|
||||
<p><b>NO WARRANTY</b>
|
||||
<p><b>15.</b> BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS
|
||||
NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
|
||||
PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
|
||||
AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE
|
||||
LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
<p><b>16.</b> IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO
|
||||
IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
|
||||
DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT
|
||||
LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED
|
||||
BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY
|
||||
OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGES.
|
||||
<h2>
|
||||
END OF TERMS AND CONDITIONS</h2>
|
||||
|
||||
<h2>
|
||||
<a NAME="SEC4" HREF="lgpl.html#TOC4"></a><a href="lgpl.html#TOC4" NAME="SEC4">How
|
||||
to Apply These Terms to Your New Libraries</a></h2>
|
||||
If you develop a new library, and you want it to be of the greatest possible
|
||||
use to the public, we recommend making it free software that everyone can
|
||||
redistribute and change. You can do so by permitting redistribution under
|
||||
these terms (or, alternatively, under the terms of the ordinary General
|
||||
Public License).
|
||||
<p>To apply these terms, attach the following notices to the library. It
|
||||
is safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
<pre><i>one line to give the library's name and an idea of what it does.
|
||||
</i>Copyright (C) <i>year</i> <i>name of author
|
||||
|
||||
</i>This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.</pre>
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
<p>You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if necessary.
|
||||
Here is a sample; alter the names:
|
||||
<pre>Yoyodyne, Inc., hereby disclaims all copyright interest in
|
||||
the library `Frob' (a library for tweaking knobs) written
|
||||
by James Random Hacker.
|
||||
|
||||
<i>signature of Ty Coon</i>, 1 April 1990
|
||||
Ty Coon, President of Vice</pre>
|
||||
That's all there is to it!
|
||||
<hr>Return to <a href="/home.html">GNU's home page</a>.
|
||||
<p>FSF & GNU inquiries & questions to
|
||||
<i><a href="mailto:gnu@gnu.org">gnu@gnu.org</a></i>.
|
||||
Other <a href="/home.html#ContactInfo">ways to contact</a> the FSF.
|
||||
<p>Comments on these web pages to
|
||||
<i><a href="mailto:webmasters@www.gnu.org">webmasters@www.gnu.org</a></i>,
|
||||
send other questions to
|
||||
<i><a href="mailto:gnu@gnu.org">gnu@gnu.org</a></i>.
|
||||
<p>Copyright notice above.
|
||||
<br>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111, USA
|
||||
<p>Updated:<!-- hhmts start -->16 Feb 1998 tower<!-- hhmts end -->
|
||||
<hr>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
@ -1,311 +0,0 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<meta name="Author" content="Fred Dushin">
|
||||
<meta name="Keywords" content="JPL,java,prolog">
|
||||
<title>Low-Level Interface</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF" link="#00009C" vlink="#CE31CE" alink="#FF0000">
|
||||
|
||||
<div align=right><a href="index.html">up</a> <a href="getting_started.html">prev</a>
|
||||
|
||||
<a href="high-level_interface.html">next</a> <a href="api/packages.html">API</a>
|
||||
<hr NOSHADE WIDTH="100%"></div>
|
||||
|
||||
<center>
|
||||
<p><br><b><font size=+4>JPL 2.0.2 Low-Level Interface</font></b></center>
|
||||
|
||||
<p><br>
|
||||
<br>
|
||||
<h3>
|
||||
Table of Contents</h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#Introduction">Introduction</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Supported Data Types">Supported Data Types</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#jpl.fli.Prolog">jpl.fli.Prolog</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Using the Low-Level Interface">Using the Low-Level Interface</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Caveats">Caveats</a></li>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#Sequential Term References">Sequential Term References</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#Variable-length Argument Lists">Variable-length Argument Lists</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#currently unsupported fli functions">Currently unsupported FLI
|
||||
functions</a></li>
|
||||
|
||||
<li>
|
||||
<a href="#unsupportable fli functions">Unsupportable FLI functions</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<hr NOSHADE WIDTH="100%">
|
||||
<h3>
|
||||
<a NAME="Introduction"></a>Introduction</h3>
|
||||
<i>[Note: if you just want to build hybrid Java+Prolog applications, you
|
||||
probably don't need to know about this interface: see the <a href="high-level_interface.html">High-Level
|
||||
interface</a> documentation]</i>
|
||||
<br>
|
||||
<br>The <b><i>JPL</i></b> Low-Level interface is implemented by the Java
|
||||
package <b>jpl.fli</b>. This package contains a set of classes that
|
||||
mirror the data types in the SWI-Prolog <i>Foreign Language Interface</i>
|
||||
(FLI), together with a class <b>jpl.fli.Prolog</b>, which contains static
|
||||
variables and static native methods which reflect the constants and functions
|
||||
in the FLI. The package is designed to serve as a direct translation
|
||||
of the Prolog FLI and is generally not intended for the average user.
|
||||
Its main purpose is to support the High-Level interface (q.v.), use of
|
||||
which is preferable in most applications.
|
||||
<p>This section provides a detailed description of the Low-Level interface
|
||||
for the programmer who may wish to use it much as he or she would the FLI.
|
||||
As such, it presumes familiarity with the Prolog FLI. <i>This document
|
||||
is not a tutorial on how to use the Prolog FLI; </i>consult your local
|
||||
Prolog documentation for how to use the FLI. Programmers who wish
|
||||
to use <b><i>JPL</i></b> without having to know any of the nitty gritty
|
||||
details of the Low-Level interface may skip this section and read the <a href="high-level_interface.html">High-Level</a>
|
||||
interface section. For information about the SWI-Prolog FLI, see
|
||||
your local SWI-Prolog documentation.
|
||||
<br>
|
||||
<br>The <b><i>JPL</i></b> Low-Level interface is highly SWI-Prolog specific,
|
||||
unlike the High-Level interface (which could potentially be implemented
|
||||
on top of at least some other Prolog systems).
|
||||
<br>
|
||||
<h3>
|
||||
<a NAME="Supported Data Types"></a>Supported Data Types</h3>
|
||||
The Low-Level interface provides definitions for the following support
|
||||
classes, which are essentially "holder" classes for the corresponding data
|
||||
types in the FLI:
|
||||
<ul>
|
||||
<pre>LongHolder
|
||||
|
|
||||
+--- term_t
|
||||
|
|
||||
+-- atom_t
|
||||
|
|
||||
+-- functor_t
|
||||
|
|
||||
+-- qid_t
|
||||
|
|
||||
+-- fid_t
|
||||
|
||||
PointerHolder
|
||||
|
|
||||
+-- predicate_t
|
||||
|
|
||||
+-- module_t</pre>
|
||||
</ul>
|
||||
With the exception of <b>predicate_t</b> and <b>module_t</b>, these classes
|
||||
hold Java long (signed 64-bit) values, corresponding to the C types in
|
||||
the FLI by the same name (unsigned long values). The <b>module_t</b>
|
||||
and <b>predicate_t</b> classes also hold long values, but their values
|
||||
are understood to be C pointers (void *).
|
||||
<blockquote><i><font size=-1><b>Note. </b> The fact that we are using
|
||||
signed values to represent unsigned values should not be a problem, since
|
||||
we are not using these values in arithmetic expressions that could cause
|
||||
errors as a result of casts. However, any SWI-Prolog implementation
|
||||
that has a word size larger than 4 bytes is not guaranteed to work correctly
|
||||
with this version of the Low-Level interface.</font></i></blockquote>
|
||||
The Low-Level interface also provides the following convenience classes
|
||||
used to get information back to the JavaVM from Prolog:
|
||||
<ul>
|
||||
<li>
|
||||
<b>IntHolder</b></li>
|
||||
|
||||
<li>
|
||||
<b>LongHolder</b></li>
|
||||
|
||||
<li>
|
||||
<b>DoubleHolder</b></li>
|
||||
|
||||
<li>
|
||||
<b>StringHolder</b></li>
|
||||
|
||||
<li>
|
||||
<b>PointerHolder</b></li>
|
||||
</ul>
|
||||
These classes are for use where a SWI-Prolog FLI function takes modifiable
|
||||
(by reference) parameters.
|
||||
<h3>
|
||||
<a NAME="jpl.fli.Prolog"></a>jpl.fli.Prolog</h3>
|
||||
The class <b>jpl.fli.Prolog</b> contains a set of Java constant (static
|
||||
final) and static native method declarations. These declarations
|
||||
more or less mirror those in the header files for the FLI (in SWI-Prolog,
|
||||
<i>SWI-Prolog.h</i>), and can all be found in the C source file <i>jpl_fli_Prolog.c</i>.
|
||||
<p>The general rule of thumb is as follows:
|
||||
<ul>
|
||||
<li>
|
||||
All constant and function names (with a few notable exceptions) are the
|
||||
same as those in the FLI, with the Prolog implementation-specific prefix
|
||||
(in the case of SWI-Prolog, <font face="Courier New,Courier">PL_</font>)
|
||||
removed. For example, the constant <font face="Courier New,Courier">PL_VARIABLE</font>
|
||||
in the FLI becomes just <font face="Courier New,Courier">VARIABLE</font>,
|
||||
and the FLI function <font face="Courier New,Courier">PL_new_term_ref()</font>
|
||||
becomes just <font face="Courier New,Courier">new_term_ref()</font>.
|
||||
A notable exception is the <font face="Courier New,Courier">throw</font>
|
||||
FLI function, which is renamed to <b>_throw</b> in the FLI; <i>throw</i>
|
||||
is a reserved word in Java.</li>
|
||||
|
||||
<li>
|
||||
All the constant values are the same in the Low-Level interface as they
|
||||
are in the FLI.</li>
|
||||
|
||||
<li>
|
||||
The signatures of FLI functions (with a few notable exceptions) are preserved
|
||||
in the Low-Level interface. The Low-Level interface provides the
|
||||
above types for this purpose.</li>
|
||||
|
||||
<li>
|
||||
Read parameters of the primitive Java types (e.g., <b>int</b>, <b>float</b>,
|
||||
<b>long</b>,
|
||||
etc.) are preserved.</li>
|
||||
|
||||
<li>
|
||||
Modify parameters of the primitive Java types take Holder classes (e.g.,
|
||||
<b>IntHolder</b>,
|
||||
<b>DoubleHolder</b>,
|
||||
<b>LongHolder</b>,
|
||||
etc.) in which the values are written, instead of pointers to these types.</li>
|
||||
|
||||
<li>
|
||||
Parameters of other types that are read and read/modify parameters in the
|
||||
FLI still take structures (e.g., <b>jpl.fli.term_t</b>) as arguments in
|
||||
the Low-Level interface. This preserves the signature of these methods
|
||||
as much as possible. A notable exception is the FLI <font face="Courier New,Courier">strip_module</font>
|
||||
function, which takes a <font face="Courier New,Courier">module_t *</font>
|
||||
as a parameter; in the Low-Level interface, the <b>strip_module</b> method
|
||||
takes a <b>module_t</b>, not a Holder for this type.</li>
|
||||
</ul>
|
||||
|
||||
<h3>
|
||||
<a NAME="Using the Low-Level Interface"></a>Using the Low-Level Interface</h3>
|
||||
Programmers already comfortable with the FLI should find no surprises.
|
||||
For example, to create a <b>term_t</b> in Java, one would do the same as
|
||||
one would do in C:
|
||||
<blockquote>
|
||||
<pre>term_t t = Prolog.new_term_ref();</pre>
|
||||
</blockquote>
|
||||
The difference is that the Java method is now a static native method of
|
||||
the Prolog class, so the syntax is slightly different than the corresponding
|
||||
call in C. Moreover, many of the same rules in the FLI apply to the
|
||||
Low-Level interface, as well. To make a term reference which contains
|
||||
an atom, for example, one must first create the <b>term_t</b>, then an
|
||||
<b>atom_t</b>,
|
||||
and then put the atom into the term, as in the FLI:
|
||||
<blockquote>
|
||||
<pre>term_t term = Prolog.new_term_ref();
|
||||
atom_t atom = Prolog.new_atom( "foo" );
|
||||
Prolog.put_atom( term, atom );</pre>
|
||||
</blockquote>
|
||||
|
||||
<h3>
|
||||
<a NAME="Caveats"></a>Caveats</h3>
|
||||
There is nothing special about the Low-Level interface; it is really just
|
||||
a straight Java mapping of the FLI, and C programmers familiar with the
|
||||
FLI should have little difficulty using it. On the other hand, translating
|
||||
the FLI to Java raises some peculiarities that should be mentioned.
|
||||
<h4>
|
||||
<a NAME="Sequential Term References"></a>Sequential Term References</h4>
|
||||
In the FLI, one can create sequential term references via the <font face="Courier New,Courier">new_term_refs</font>
|
||||
function:
|
||||
<blockquote>
|
||||
<pre>term_t t0 = Prolog.new_term_refs( n);</pre>
|
||||
</blockquote>
|
||||
Subsequent references are obtained by <b>t0+1</b>, <b>t0+2</b>, etc.
|
||||
However, Java does not support operator overloading, so we can't obtain
|
||||
subsequent term references by offsetting an initial reference. We
|
||||
can, however, obtain the value field of a <b>term_t</b> structure an compute
|
||||
subsequent references off that value, as in, for example, <b>t0.value+1</b>,
|
||||
<b>t0.value+2</b>,
|
||||
etc.
|
||||
<h4>
|
||||
<a NAME="Variable-length Argument Lists"></a>Variable-length Argument Lists</h4>
|
||||
Some of the C functions in the FLI (e.g, <b>PL_cons_functor()</b>) take
|
||||
variable-length arguments, function definitions whose argument lengths
|
||||
are not known at compile time. However, Java has no support for such
|
||||
definitions; all method definitions must have determinable signatures at
|
||||
compile time.
|
||||
<br>
|
||||
<br>JPL 1.0.1 was designed and implemented before Java acquired <i>anonymous
|
||||
array</i> syntax (in Java 1.1), which make it feasible to redefine a method
|
||||
to take an array of arguments in place of a variable-length argument list.
|
||||
Since the SWI-Prolog FLI provides alternative functions that are equivalent
|
||||
to these variable-length argument functions, <i>JPL 1.0.1</i> implemented
|
||||
these. The High-Level interface exploits anonymous array syntax (e.g.
|
||||
when constructing a <b>Compound</b>), but it has not been considered necessary
|
||||
to revise the implementation of the Low-Level interface.
|
||||
<br>
|
||||
<h4>
|
||||
<a NAME="currently unsupported fli functions"></a>Currently unsupported
|
||||
FLI functions</h4>
|
||||
A number of SWI-Prolog FLI functions are currently unsupported, and not
|
||||
needed by the High-Level interface, but could and might be supported in
|
||||
future versions (preference is likely to be given to those which can sensibly
|
||||
be made available to applications via the High-Level interface, or which
|
||||
are necessary to support future extensions to the High-Level interface).
|
||||
<br>
|
||||
<h4>
|
||||
<a NAME="unsupportable fli functions"></a>Unsupportable FLI functions</h4>
|
||||
Some SWI-Prolog FLI functions seem inherently unsupportable within this
|
||||
interface:
|
||||
<dl>
|
||||
<dl>
|
||||
<dt>
|
||||
<b>PL_signal()</b></dt>
|
||||
|
||||
<dd>
|
||||
Java can't feasibly register a C function as s signal handler<br>
|
||||
<BR></dd>
|
||||
|
||||
<dt>
|
||||
<b>PL_action()</b></dt>
|
||||
|
||||
<dd>
|
||||
problems with the argument types and qty; some of these actions may be
|
||||
useful...<br>
|
||||
<BR></dd>
|
||||
|
||||
<dt>
|
||||
<b>PL_query()</b></dt>
|
||||
|
||||
<dd>
|
||||
the ARGC, ARGV, MAX_INTEGER, MIN_INTEGER options are redundant</dd>
|
||||
|
||||
<dd>
|
||||
QUERY_VERSION might be useful...</dd>
|
||||
|
||||
<dd>
|
||||
SYMBOLFILE ?<br>
|
||||
<BR></dd>
|
||||
|
||||
<dt>
|
||||
<b>PL_dispatch_hook()<br>
|
||||
PL_abort_hook()<br>
|
||||
PL_abort_unhook()<br>
|
||||
PL_on_halt()<br>
|
||||
PL_agc_hook()</b></dt>
|
||||
|
||||
<dd>
|
||||
these are of little value within Java (unless we can install Java methods?!)</dd>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<div align=right>
|
||||
<hr NOSHADE WIDTH="100%"><a href="index.html">up</a> <a href="getting_started.html">prev</a>
|
||||
<a href="high-level_interface.html">next </a> <a href="api/packages.html">API</a></div>
|
||||
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 6.0 KiB |
@ -1,135 +0,0 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.5 [en] (X11; I; Linux 2.1.24 ppc) [Netscape]">
|
||||
<meta name="Author" content="Fred Dushin">
|
||||
<meta name="Keywords" content="JPL,java,prolog">
|
||||
<title>Programming Notes</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF" link="#00009C" vlink="#CE31CE" alink="#FF0000">
|
||||
|
||||
<div align=right><a href="index.html">up</a> <a href="high-level_interface.html">prev</a>
|
||||
next <a href="api/packages.html">API</a>
|
||||
<hr NOSHADE WIDTH="100%"></div>
|
||||
|
||||
<center>
|
||||
<p><br><b><font size=+4>Programming Notes</font></b></center>
|
||||
|
||||
<p><br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<p>This section provides a description of some of the nitty-gritty involved
|
||||
in getting the high-level interface to work. It presumes <i>extensive</i>
|
||||
familiarity with the High-Level interface, in addition to the Low-Level
|
||||
Interface and the Prolog Foreign Language Interface (FLI).
|
||||
<h3>
|
||||
Overview</h3>
|
||||
The High-Level Interface provides, in essence, a set of Java data structures
|
||||
for invoking queries on a Prolog engine. By itself, the High-Level
|
||||
interface makes no direct calls to the Prolog Abstract Machine (AM).
|
||||
Instead, the High-Level interface rests entirely on top of the Low-LevelInterface,
|
||||
a Java implementation of the FLI. The Low-Level interface is more
|
||||
or less in 1-1 correspondence with the FLI (barring methods that do not
|
||||
make sense in the Java environment).
|
||||
<p>The following describes a typical execution of a Prolog query using
|
||||
the interfaces described in the jpl.Query class. Assume the High-Level
|
||||
Interface programmer (hereafter, just 'the programmer') has constructed
|
||||
a jpl.Term structure (assume, for simplicity, that the programmer is invoking
|
||||
a predicate of arity 1), and is about to use the Query class to make a
|
||||
query using the hasMoreSolutions/nextSolution protocol. Roughly the
|
||||
following sequence of events occurs.
|
||||
<ol>
|
||||
<li>
|
||||
The <b>jpl.Term</b> is converted to a <b>jpl.fli.term_t</b></li>
|
||||
|
||||
<li>
|
||||
A call to the Prolog AM is opened using the Low-Level Interface <b>Prolog.open_query</b>
|
||||
method with the predicate name and <b>term_t</b> just created</li>
|
||||
|
||||
<li>
|
||||
For any <b>jpl.Variable</b> occurrence (i.e., instance) in the original
|
||||
<b>jpl.Term</b>
|
||||
given to the <b>Query</b>, convert the <b>term_t</b>s that are bound to
|
||||
those variables o <b>jpl.Term</b>s, and construct a
|
||||
<b>Hashtable</b> of
|
||||
these <b>Term</b>s, indexed by the <b>Variable</b>s in the <b>Query</b>.</li>
|
||||
|
||||
<li>
|
||||
Close the query using the Low-Level Interface <b>Prolog.close_query</b>
|
||||
method if there are no more solutions. Otherwise, keep the query
|
||||
open for subsequent calls to <b>hasMoreSolutions</b>.</li>
|
||||
</ol>
|
||||
Significantly more bookeeping is required to prevent the programmer from
|
||||
opening a query while another is open, maintaining state about the status
|
||||
of the query, and so forth, but the above gives a rough approximation of
|
||||
what occurs in typical "successful" calls to the Prolog AM. The remainder
|
||||
of this section describes these steps in some detail.
|
||||
<h3>
|
||||
Translating Terms to term_ts</h3>
|
||||
Translating <b>jpl.Term</b>s to <b>jpl.fli.term_t</b>s is relatively straightforward.
|
||||
Each <b>Term</b> subclass knows more or less how to convert itself to a
|
||||
term_t via its <b>pack</b> method, and the top-level <b>Term</b> static
|
||||
method <b>terms_to_term_ts </b>takes an array of <b>Term</b>s and performs
|
||||
the conversion for the <b>Query</b>. The following features of the
|
||||
FLI, however, help explain the perhaps mysterious signature of <b>pack</b>.
|
||||
<ul>
|
||||
<li>
|
||||
The Prolog FLI requires that <i>term_t</i> references first be created,
|
||||
and then data of an appropriate type be "put" into the <i>term_t </i>reference
|
||||
using one of the FLI <i>_put</i> functions. For example, to create
|
||||
an atom in the FLI, one first creates a <i>term_t,</i> and then "puts"
|
||||
an <i>atom_t </i>into the <i>term_t.</i></li>
|
||||
|
||||
<p><br><font face="Courier New,Courier"><font size=+1>
|
||||
term_t t = PL_new_term_ref();</font></font>
|
||||
<br><font face="Courier New,Courier"><font size=+1> atom_t
|
||||
a = PL_new_atom( "a" );</font></font>
|
||||
<br><font face="Courier New,Courier"><font size=+1> PL_put_atom(
|
||||
t, a );</font></font>
|
||||
<p>Translating a Term to a term_t requires mimicking this behavior.
|
||||
<li>
|
||||
In the case of Compound Terms,</li>
|
||||
|
||||
<li>
|
||||
A <i>term_t</i> in the Prolog FLI is, literally, an unsigned long value.
|
||||
It is essentially an index into the Prolog AM. A sequence of <i>term_t</i>s
|
||||
is a set of <i>consecutive</i> long values, typically created via the FLI
|
||||
C funtion <i>PL_new_term_refs().</i> In order to construct a compound
|
||||
<i>term_t,</i> in the FLI, one must create such a sequence of <i>term_t</i>s
|
||||
(as many as the arity of the compound), and then use the various FLI <i>_put
|
||||
</i>functions to put terms into the term_ts that have just been created.</li>
|
||||
|
||||
<br> </ul>
|
||||
|
||||
<h3>
|
||||
Computing Substitutions</h3>
|
||||
|
||||
<p><br>Translating term_ts to Terms
|
||||
<h3>
|
||||
Terms</h3>
|
||||
A <b>jpl.Term</b> structure holds, as an element, a <b>jpl.fli.term_t</b>
|
||||
structure, which itself is a class which holds a long value. This
|
||||
long value is in fact a pointer (though not a C pointer) to Prolog term
|
||||
in the Prolog Abstract Machine (AM). Unfortunately, these low-level
|
||||
values are not really valid throughout the life of the jpl.Term.
|
||||
Indeed, they are only valid pointers into the Prolog AM <i>during the execution
|
||||
of a Prolog query. </i>They must, therefore, be treated with exceptional
|
||||
caution, and are consequently kept well-hidden from the user of the High-Level
|
||||
Interface.
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<div align=right>
|
||||
<hr NOSHADE WIDTH="100%"><a href="index.html">up</a>
|
||||
<a href="high-level_interface.html">prev</a>
|
||||
next
|
||||
<a href="api/packages.html">API</a></div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,42 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>JPL 3.x objectives</title>
|
||||
<meta name="author" content="Paul Singleton">
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;">JPL 3.x</span> Objectives</h1>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<ul>
|
||||
<li>enable Prolog applications to exploit <span
|
||||
style="font-style: italic;">any </span>Java classes, instances,
|
||||
methods etc. (without requiring any wrappers, metadata etc. to be set
|
||||
up first)</li>
|
||||
<li>enable Java applications to manipulate <span
|
||||
style="font-style: italic;">any </span>Standard Prolog libraries,
|
||||
predicates, etc. (without requiring any wrappers, metadata etc. to be
|
||||
set up first)</li>
|
||||
<li>enable hybrid Prolog+Java applications to be designed and
|
||||
implemented so as to take best advantage of both language systems, and
|
||||
to be testable, debuggable, maintainable etc.</li>
|
||||
<li>minimum <span style="font-style: italic;">impact </span>deployability:
|
||||
runtime support for Prolog+Java apps must be a position-independent,
|
||||
self-sufficient filestore tree, requiring no changes to registries,
|
||||
system libraries, system configuration files etc.<br>
|
||||
</li>
|
||||
<li>minimum <span style="font-style: italic;">dependency </span>deployability:
|
||||
as with JVMs, the Prolog+Java runtime support must depend upon nothing
|
||||
which cannot be taken for granted in healthy OS installations</li>
|
||||
<li>minimum <span style="font-style: italic;">vulnerability </span>deployability:
|
||||
the Prolog+Java runtime support must be immune to legitimate variations
|
||||
in its environment (PATH settings, other applications and libraries
|
||||
including other Prolog+Java apps, etc.)</li>
|
||||
<li><span style="font-style: italic;">(to be developed...)</span><br>
|
||||
</li>
|
||||
</ul>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>drafted 19th February 2004</address>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
@ -1,382 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="CONTENT-TYPE"
|
||||
content="text/html; charset=windows-1252">
|
||||
<title>api</title>
|
||||
<meta name="GENERATOR" content="StarOffice 7 (Win32)">
|
||||
<meta name="AUTHOR" content="Paul Singleton">
|
||||
<meta name="CREATED" content="20040218;18025294">
|
||||
<meta name="CHANGED" content="16010101;0">
|
||||
<style>
|
||||
<!--
|
||||
@page { size: 21cm 29.7cm }
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body lang="en-US" dir="ltr">
|
||||
<h1><span style="font-style: italic;">JPL 3.x</span> Prolog API
|
||||
reference</h1>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<dl>
|
||||
<dt> <a name="jpl_new/3"></a><b>jpl_new</b>( <var>+ClassOrType,
|
||||
+Params, -Result</var>) </dt>
|
||||
<dd> unifies <i>Result</i> with a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a new instance of <var>ClassOrType</var>, constructed with <var>Params</var>,
|
||||
e.g. <code>jpl_new('javax.swing.JFrame', ['JPL demo'], F)</code>.
|
||||
There are many other ways to call this predicate: see <a
|
||||
href="overview/index.html">BlahBlah</a>.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_call/4"></a><b>jpl_call</b>( <i>+Object,
|
||||
+Method, +Params, -Result</i>) </dt>
|
||||
<dd> unifies <i>Result</i> with a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
(or value of) the result of calling the named method of <var>Object</var>
|
||||
with <var>Params</var>, e.g. <code>jpl_call(F, setVisible, [@(true)],
|
||||
_)</code>. There are many other ways to call this predicate: see <a
|
||||
href="file:///D:/jpl/doc/prolog_calls_java/overview/index.html">BlahBlah</a>.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_get/3"></a><b>jpl_get</b>( <i>+Object,
|
||||
+Field, -Value</i>) </dt>
|
||||
<dd> unifies <i>Value</i> to the value of, or a reference to, the
|
||||
named field of Object. There are many other ways to call this
|
||||
predicate: see <a href="overview/index.html">BlahBlah</a>..<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_get/3"></a><b>jpl_set</b>( <i>+Object,
|
||||
+Field, +Value</i>) </dt>
|
||||
<dd>sets the named field of <var>Object</var> to <var>Value</var>
|
||||
(a <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
reference or value). There are many other ways to call this
|
||||
predicate: see <a href="overview/index.html">BlahBlah</a>..<br>
|
||||
<br>
|
||||
</dd>
|
||||
</dl>
|
||||
<h2><br>
|
||||
Java inspection</h2>
|
||||
<dl>
|
||||
<dt><a name="jpl_class_to_classname"></a><b>jpl_class_to_classname</b>(
|
||||
<var>+Class, -Classname</var>) </dt>
|
||||
<dd><var>Class</var> must be a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java class object (i.e. an instance of <span
|
||||
style="font-style: italic;">java.lang.Class</span>); <var>Classname</var>
|
||||
is its canonical dotted name, e.g. <code>'java.util.Date'</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_class_to_type"></a><b>jpl_class_to_type</b>( <var>+Class,
|
||||
-Type)</var></dt>
|
||||
<dd><var>Class</var> must be a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java class object (i.e. an instance of <span
|
||||
style="font-style: italic;">java.lang.Class</span>); <var>Type</var>
|
||||
is its <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
type, e.g. <code>class([java,util],['Date'])</code>
|
||||
or <code>array(double)</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_classname_to_class"></a><b>jpl_classname_to_class</b>(
|
||||
<var>+Classname, -Class</var>)</dt>
|
||||
<dd><var> Classname</var> must be a canonical dotted name (an atom)
|
||||
of a
|
||||
Java class, e.g. <code>'java.util.Date'</code>; <var>Class</var> is a
|
||||
<span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
reference to a corresponding Java class object (i.e. an instance of
|
||||
java.lang.Class).<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_classname_to_type"></a><b>jpl_classname_to_type</b>(
|
||||
<var>+Classname, -Type</var>)</dt>
|
||||
<dd><var> Classname</var> must be a canonical dotted name (an atom)
|
||||
of a Java class, e.g. <code>'java.util.Date'</code>; <var>Type</var>
|
||||
is its <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
type, e.g. <code>class([java,util],['Date'])</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_datum_to_type"></a><b>jpl_datum_to_type</b>( <var>+Datum,
|
||||
-Type</var>)</dt>
|
||||
<dd><var>Datum</var> must be a valid <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of some Java object or value e.g. <code>3</code>, <code>fred</code>,
|
||||
<code>@(false)</code>; <var>Type</var> is its <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type, e.g. <code>char_byte</code>,
|
||||
<code>class([java,lang],['String'])</code>, <code>boolean</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_false"></a><b>jpl_false</b>( <var>-Datum</var>)</dt>
|
||||
<dd><var>Datum</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the Java boolean value <span
|
||||
style="font-style: italic;">false</span>, i.e. <code>@(false)</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_class"></a><b>jpl_is_class</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java class object, i.e. to an instance of <span
|
||||
style="font-style: italic;">java.lang.Class</span>. No further
|
||||
instantiation of <var>Term</var> will take place; if it is not ground,
|
||||
this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_false"></a><b>jpl_is_false</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the Java boolean value <span
|
||||
style="font-style: italic;">false</span>. No further instantiation of <var>Term</var>
|
||||
will take place; if it is not ground, this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_null"></a><b>jpl_is_null</b>( <var>?Term</var>) </dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-style: italic; font-weight: bold;">JPL</span>
|
||||
representation of the Java boolean value <span
|
||||
style="font-style: italic;">null</span>. No further instantiation of <var>Term</var>
|
||||
will take place; if it is not ground, this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_object"></a><b>jpl_is_object</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object. No further instantiation of <var>Term</var> will take
|
||||
place; if it is not ground, this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_object_type"></a><b>jpl_is_object_type</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> class or
|
||||
array type (but not <code>null</code>, <code>void</code>, or one of
|
||||
the primitive types). No further instantiation of <var>Term</var>
|
||||
will take place; if it is not ground, this predicate fails.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_is_ref"></a><b>jpl_is_ref</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> class or
|
||||
array type, or is <code>null</code> (i.e. the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type of
|
||||
Java's null reference) (but not <code>void</code> or one of the
|
||||
primitive types). No further instantiation of <var>Term</var>
|
||||
will take place; if it is not ground, this predicate fails.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_is_true"></a><b>jpl_is_true</b>( <var>?Term</var>)
|
||||
</dt>
|
||||
<dd><var>Term</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JP</span>L
|
||||
representation of the Java boolean value <span
|
||||
style="font-style: italic;">true</span>. No further
|
||||
instantiation of <var>Term</var> will take place; if it is not ground,
|
||||
this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_type"></a><b>jpl_is_type</b>( <var>?Term</var>) </dt>
|
||||
<dd><var>Term</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type, e.g. <code>char_byte</code>,
|
||||
<code>float</code>, <code>array(int)</code>. No further
|
||||
instantiation of <var>Term</var> will take place; if it not ground,
|
||||
this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_is_void"></a><b>jpl_is_void</b>( <var>?Term</var>) </dt>
|
||||
<dd><var>Term</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the (notional but convenient) Java value <span
|
||||
style="font-style: italic;">void</span>, i.e. <code>@(void)</code>.
|
||||
No further instantiation of <var>Term</var> will take place; if it not
|
||||
ground, this predicate fails.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_null"></a><b>jpl_null</b>( <var>-Datum</var>) </dt>
|
||||
<dd><var>Datum</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the Java null reference <span
|
||||
style="font-style: italic;">null</span>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_object_to_class"></a><b>jpl_object_to_class</b>( <var>+Object,
|
||||
-Class</var>) </dt>
|
||||
<dd><var>Object</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object; <var>Class</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java class object (an instance of <span style="font-style: italic;">java.lang.Class</span>)
|
||||
which represents <var>Object</var>'s class.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_object_to_type"></a><b>jpl_object_to_type</b>( <var>+Object,
|
||||
-Type</var>) </dt>
|
||||
<dd><var>Object</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object; <var>Type</var> is its <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type, e.g. <code>array(boolean)</code>,
|
||||
<code>class([javax,sql],['Timestamp'])</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_primitive_type"></a><b>jpl_primitive_type</b>( <var>-Type</var>)
|
||||
</dt>
|
||||
<dd><var>Type</var> is one of the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> primitive
|
||||
types <code>boolean</code>, <code>char</code>, <code>byte</code>, <code>short</code>,
|
||||
<code>int</code>, <code>long</code>, <code>float</code>, <code>double</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_ref_to_type"></a><b>jpl_ref_to_type</b>( <var>+Ref,
|
||||
-Type</var>) </dt>
|
||||
<dd><var>Ref</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object; <var>Typ</var>e is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type of <var>Object</var>,
|
||||
e.g. <code>array(boolean)</code>, <code>class([javax,sql],['Timestamp'])</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_true"></a><b>jpl_true</b>( <var>-Datum</var>) </dt>
|
||||
<dd><var>Datum</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the Java boolean value <span
|
||||
style="font-style: italic;">true</span>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_type_to_class"></a><b>jpl_type_to_class</b>( <var>+Type,
|
||||
-Class</var>) </dt>
|
||||
<dd><var>Type</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> class (or
|
||||
array) type, e.g. <code>class([javax,sql],['Timestamp'])</code> or <code>array(boolean)</code>;
|
||||
<var>Class</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java class object (an instance of <span style="font-style: italic;">java.lang.Class</span>)
|
||||
which corresponds to <var>Type</var>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_type_to_classname"></a><b>jpl_type_to_classname</b>(
|
||||
<var>+Type, -Classname</var>) </dt>
|
||||
<dd><var>Type</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> class (or
|
||||
array) type, e.g. <code>class([javax,sql],['Timestamp'])</code> or <code>array(boolean)</code>;
|
||||
<var>Classname</var> is its canonical dotted name (an atom).<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_void"></a><b>jpl_void</b>( <var>-Datum</var>)
|
||||
</dt>
|
||||
<dd><var>Datum</var> is the <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
representation of the (notional but convenient) Java value <span
|
||||
style="font-style: italic;">void</span>, i.e. <code>@(void)</code>.<br>
|
||||
</dd>
|
||||
</dl>
|
||||
<h2><br>
|
||||
Utilities</h2>
|
||||
<dl>
|
||||
<dt> <a name="jpl_array_to_length"></a><b>jpl_array_to_length</b>(
|
||||
<var>+Array,
|
||||
-Length</var>) </dt>
|
||||
<dd><var>Array</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java array; <var>Length</var> is its length (an integer).<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_array_to_list"></a><b>jpl_array_to_list</b>( <var>+Array,
|
||||
-ListOfDatums</var>) </dt>
|
||||
<dd><var>Array</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java array (of any base type); <var>ListOfDatums</var> is a (Prolog)
|
||||
list of <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
references to, or values of, its respective elements.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_datums_to_array"></a><b>jpl_datums_to_array</b>( <var>+ListOfDatums,
|
||||
-Array</var>) </dt>
|
||||
<dd><var> ListOfDatums</var> is a (Prolog) list of <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> references
|
||||
or values; <var>Array</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java array of corresponding objects or values. The base type of
|
||||
<var>Array</var> is the most specific Java type of which each
|
||||
member of<var> ListOfDatums</var> is (directly or indirectly) an
|
||||
instance. If there is no such type, this predicate fails. Values of
|
||||
Java primitive types are not automatically "boxed". Lists which are
|
||||
mixtures of numbers, booleans and object references cannot be converted
|
||||
to Java arrays with this predicate.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_enumeration_element"></a><b>jpl_enumeration_element</b>(
|
||||
<var>+Enumeration, -Element</var>) </dt>
|
||||
<dd> <var>Enumeration</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object whose class implements the <span
|
||||
style="font-style: italic;">java.util.Enumeration</span> interface; <var>Element</var>
|
||||
is an element of <var>Enumeration</var>. This predicate can
|
||||
generate each element of an enumeration.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_enumeration_to_list"></a><b>jpl_enumeration_to_list</b>(
|
||||
<var>+Enumeration, -ListOfElement</var>) </dt>
|
||||
<dd><var>Enumeration</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object whose class implements the <span
|
||||
style="font-style: italic;">java.util.Enumeration</span>
|
||||
interface; <var>ListOfElement</var> is a list of <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> references
|
||||
to each element of <var>Enumeration</var>.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_hashtable_pair"></a><b>jpl_hashtable_pair</b>(
|
||||
<var>+Hashtable,
|
||||
-KeyValuePair</var>) </dt>
|
||||
<dd><var>Hashtable</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java hashtable object (an instance of <span
|
||||
style="font-style: italic;">java.util.Hashtable</span>); <var>KeyValuePair</var>
|
||||
is a <code>-/2</code> compound term whose first arg is a key (atom or
|
||||
ref) from <var>Hashtable</var>, and whose second arg is its
|
||||
corresponding value (atom or ref), e.g.<code>fred-@'J#0008127852'</code>.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_iterator_element"></a><b>jpl_iterator_element</b>( <var>+Iterator,
|
||||
-Element</var>) </dt>
|
||||
<dd><var>Iterator</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object whose class implements the <span
|
||||
style="font-style: italic;">java.util.Iterator interface</span>; <var>Element</var>
|
||||
is a <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
reference to one of its elements. This predicate can generate all
|
||||
elements.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_list_to_array"></a><b>jpl_list_to_array</b>( <var>+ListOfDatum,
|
||||
-Array</var>) </dt>
|
||||
<dd>This is a synonym for <a href="#jpl_datums_to_array"><span
|
||||
style="font-weight: bold;">jpl_datums_to_array/2</span></a>, in case
|
||||
you forget that <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
values and references are called "datums".<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_map_element"></a><b>jpl_map_element</b>( <var>+Map,
|
||||
-KeyValuePair</var>) </dt>
|
||||
<dd><var>Map</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object whose class implements the <span
|
||||
style="font-style: italic;">java.util.Map</span> interface; <var>KeyValuePair</var>
|
||||
is a <code>-/2</code> compound term whose first arg is a key (atom or
|
||||
ref) from <var>Map</var>, and whose second arg is its corresponding
|
||||
value (atom or ref), e.g.<code> -(fred,@'J#0008127852'</code>), or <code>fred-@'J#0008127852'</code>
|
||||
using conventional operator definitions.<br>
|
||||
</dd>
|
||||
<dt><a name="jpl_set_element"></a><b>jpl_set_element</b>( <var>+Set,
|
||||
-Element</var>) </dt>
|
||||
<dd><var>Set</var> is a <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> reference to
|
||||
a Java object whose class implements the <span
|
||||
style="font-style: italic;">java.util.Set</span> interface; <var>Element</var>
|
||||
is a <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
reference to an object (or null) within <var>Set</var>. This
|
||||
predicate can generate all elements of <var>Set</var></dd>
|
||||
</dl>
|
||||
<h2><br>
|
||||
Miscellaneous</h2>
|
||||
<dl>
|
||||
<dt><a name="jpl_c_lib_version/1"></a><b>jpl_c_lib_version</b>( <i>-Version</i>)
|
||||
</dt>
|
||||
<dd> unifies <i>Version</i> to an atom (e.g. <tt>'3.0.1-alpha'</tt>)
|
||||
whose name is the version identifier of the 'C' library which JPL is
|
||||
using.<br>
|
||||
<br>
|
||||
</dd>
|
||||
<dt> <a name="jpl_c_lib_version/4"></a><b>jpl_c_lib_version</b>( <i>-Major</i>,
|
||||
<i>-Minor</i>, <i>-Patch</i>, <i>-Status</i>) </dt>
|
||||
<dd> unifies <i>Major</i>, <i>Minor</i>, <i>Patch</i> and <i>Status</i>
|
||||
to the corresponding components (e.g. <tt>3</tt>, <tt>0</tt>, <tt>1</tt>
|
||||
and <tt>alpha</tt>) of the version identifier of the 'C' library which
|
||||
JPL is using.<br>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>drafted 18th February 2004<br>
|
||||
</address>
|
||||
</body>
|
||||
</html>
|
@ -1,40 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<title>JPL 3.x Prolog-calls-Java gotchas</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;">
|
||||
JPL 3.x</span> Prolog API gotchas
|
||||
</h1>
|
||||
<hr width="100%">
|
||||
<h2>calling methods with no parameters
|
||||
</h2>
|
||||
<blockquote>you must pass an empty parameter list when calling Java
|
||||
methods which take no parameters, e.g.<br>
|
||||
<pre style="margin-left: 40px;">jpl_call('java.lang.System', gc, [], _)<br></pre>
|
||||
</blockquote>
|
||||
<h2>calling void methods
|
||||
</h2>
|
||||
<blockquote>you must accept an @(void) result when calling void Java
|
||||
methods, e.g. either<br>
|
||||
<pre style="margin-left: 40px;">jpl_call('java.lang.System', gc, [], @(void))</pre>
|
||||
which explicitly matches the expected result, or<br>
|
||||
<pre style="margin-left: 40px;">jpl_call('java.lang.System', gc, [], _)</pre>
|
||||
which uses an anonymous variable to ignore the result.<br>
|
||||
</blockquote>
|
||||
<h2><span style="font-style: italic;">(more to come...)</span><br>
|
||||
</h2>
|
||||
<blockquote></blockquote>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<address><a href="mailto:p.singleton@keele.ac.uk">Paul Singleton</a></address>
|
||||
<address>
|
||||
drafted Wednesday 4th February 2004<br>
|
||||
<br>
|
||||
</address>
|
||||
</body>
|
||||
</html>
|
@ -1,973 +0,0 @@
|
||||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Paul Singleton">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<title>A SWI-Prolog to Java interface</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;"> JPL 3.x</span> Prolog API
|
||||
overview</h1>
|
||||
<hr style="width: 100%; height: 2px;">
|
||||
<ul>
|
||||
<li><a href="#Introduction">Introduction</a></li>
|
||||
<li><a href="#JPL_types_Java_types_as_seen_by">JPL types (Java types,
|
||||
as seen by Prolog)</a><a href="#Java_types_as_seen_by_Prolog"></a></li>
|
||||
<li><a href="#representation_of_Java_values...">representation of
|
||||
Java values and references within Prolog</a></li>
|
||||
<li><a href="#repn_of_Java_types_1_structured">representation of Java
|
||||
types within Prolog (1): <i>structured</i> notation</a></li>
|
||||
<li><a href="#repn_of_Java_types_2_descriptor">representation of Java
|
||||
types within Prolog (2): <i>descriptor</i> notation</a></li>
|
||||
<li><a href="#repn_of_Java_types_3_classname">representation of Java
|
||||
types within Prolog (3): classname notation</a></li>
|
||||
<li><a href="#creating_instances_of_Java_classes">creating instances
|
||||
of Java classes</a></li>
|
||||
<li><a href="#calling_methods_of_Java_objects_...">calling methods of
|
||||
Java objects or classes</a></li>
|
||||
<li><a href="#fetching_field_values_of_Java_objects...">fetching
|
||||
field values of Java objects or classes</a></li>
|
||||
<li><a href="#setting_field_values_of_Java_objects...">setting field
|
||||
values of Java objects or classes</a></li>
|
||||
<li><a href="#a_slightly_longer_example">a slightly longer example</a></li>
|
||||
<li><a href="#jpl_new3">jpl_new/3</a></li>
|
||||
<li><a href="#jpl_call4">jpl_call/4</a></li>
|
||||
<li><a href="#jpl_set3">jpl_set/3</a></li>
|
||||
<li><a href="#jpl_get3">jpl_get/3</a></li>
|
||||
<li><a href="#exceptions">exceptions thrown by Java</a></li>
|
||||
<li><a href="#testing">testing</a></li>
|
||||
<li><a href="#to_do">to do</a><br>
|
||||
</li>
|
||||
</ul>
|
||||
<hr width="100%">
|
||||
<h2><font face="Arial,Helvetica"><a name="Introduction"></a>Introduction</font></h2>
|
||||
<font face="Arial,Helvetica">This is an overview of
|
||||
an interface which allows SWI-Prolog programs to dynamically create and
|
||||
manipulate Java objects.</font>
|
||||
<p><font face="Arial,Helvetica">Here are some significant features of
|
||||
the interface and its implementation:</font> </p>
|
||||
<ul>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><font face="Arial,Helvetica">it is completely dynamic: no
|
||||
precompilation is required to manipulate any Java classes which can be
|
||||
found at run time, and any objects which can be instantiated from them<br>
|
||||
</font></li>
|
||||
</ul>
|
||||
<font face="Arial,Helvetica"></font>
|
||||
<ul>
|
||||
<li><font face="Arial,Helvetica">it is interoperable with <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>'s Java API
|
||||
(which has evolved from Fred Dushin's <span style="font-style: italic;">JPL
|
||||
1.0.1</span>)</font></li>
|
||||
</ul>
|
||||
<font face="Arial,Helvetica"></font>
|
||||
<ul>
|
||||
<li><font face="Arial,Helvetica">it requires a Java 2 JVM and class
|
||||
libraries (although it doesn't depend on any Java 2-specific
|
||||
facilities, and originally was developed for use with both 1.1 and 1.2
|
||||
JVMs, I haven't tested it with 1.1 recently, and don't support this)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">it exploits the <i>Invocation API</i>
|
||||
of the <i>Java Native Interface</i>: this is a mandatory feature of
|
||||
any compliant
|
||||
JVM (even the now defunct "Microsoft Virtual Machine" supported JNI,
|
||||
although they seemed to want to keep that a secret :-)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">it is implemented with a fair
|
||||
amount of
|
||||
Prolog code in one module (<span style="font-style: italic;">jpl.pl</span>)
|
||||
(which I believe to be ISO Standard Prolog compliant
|
||||
and portable) and a SWI-Prolog-specific foreign library (<span
|
||||
style="font-style: italic;">jpl.dll</span> for Windows), implemented
|
||||
in ANSI C but making a lot of use of the SWI-Prolog <i>Foreign
|
||||
Language Interface</i></font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">the foreign-language part has so
|
||||
far been tested only under Windows NT4, but is believed to be readily
|
||||
portable to SWI-Prolog
|
||||
on other platforms</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">as far as is feasible, Java data
|
||||
values and
|
||||
object references are represented within Prolog canonically and without
|
||||
loss
|
||||
of information (minor exceptions: Java <span
|
||||
style="font-style: italic;">float </span>and <span
|
||||
style="font-style: italic;">double</span> values are both converted to
|
||||
Prolog <span style="font-style: italic;">float </span>values; Java <span
|
||||
style="font-style: italic;">byte</span>, <span
|
||||
style="font-style: italic;">char</span>, <span
|
||||
style="font-style: italic;">short</span>, <span
|
||||
style="font-style: italic;">int</span> and <span
|
||||
style="font-style: italic;">long</span> values are all converted to
|
||||
Prolog <span style="font-style: italic;">integer</span> values; the
|
||||
type distinctions which are lost are normally of no significance)<br>
|
||||
</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">references within Prolog to Java
|
||||
objects:</font></li>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">should be treated as opaque
|
||||
handles</font></li>
|
||||
<li> <font face="Arial,Helvetica">are canonical (two references
|
||||
are ==/2
|
||||
equal if-and-only-if they refer to the <span
|
||||
style="font-style: italic;">same
|
||||
object</span> within the JVM)</font></li>
|
||||
<li> <font face="Arial,Helvetica">are represented as structures
|
||||
containing
|
||||
a distinctive atom so as to exploit SWI-Prolog's atom garbage
|
||||
collection: when an object reference is garbage-collected in Prolog,
|
||||
the JVM garbage collector
|
||||
is informed, so there is sound and complete overall garbage collection
|
||||
of
|
||||
Java objects within the combined Prolog+Java system</font></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">Java class methods can be called
|
||||
by name: <i style="font-weight: bold;">JPL</i> invisibly fetches (and
|
||||
caches) essential
|
||||
details of method invocation, exploiting <i>Java Reflection</i>
|
||||
facilities</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">the API is similar to that of
|
||||
XPCE: the
|
||||
four main interface calls are <i>jsp_new</i>, </font><font
|
||||
face="Arial,Helvetica"><i>jsp_call, </i></font><font
|
||||
face="Arial,Helvetica"><i>jsp_set</i> and </font><font
|
||||
face="Arial,Helvetica"><i>jsp_get</i> (there is no <i>jsp_free</i>,
|
||||
since Java's garbage collection
|
||||
is extended transparently into Prolog)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica"><i>jsp_call</i> resolves
|
||||
overloaded methods automatically and dynamically, inferring the types
|
||||
of the call's actual parameters,
|
||||
and identifying the most specific of the applicable method
|
||||
implementations
|
||||
(similarly, <i>jsp_new</i> resolves overloaded constructors)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">Prolog code which uses the API
|
||||
calls is
|
||||
responsible for passing suitably-typed values and references, since the
|
||||
JNI
|
||||
doesn't perform complete dynamic type-checking, and nor currently does <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> (although
|
||||
the <i>overloaded method resolution</i> mechanism could probably be
|
||||
adapted to do this)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">Prolog code can reason about the
|
||||
types
|
||||
of Java data values, object references, fields and methods: <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> supports a
|
||||
canonical
|
||||
representation of all Java types as structured terms (e.g. </font><b><tt>array(array(byte))</tt></b><font
|
||||
face="Arial,Helvetica">) and also as atomic JVM signatures</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">the Prolog-calls-Java (mine) and
|
||||
Java-calls-Prolog (Fred's) parts of <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
are largely independent; mine concentrates on representing all Java
|
||||
data
|
||||
values and objects within Prolog, and supporting manipulation of
|
||||
objects;
|
||||
Fred's concentrates on representing any Prolog term within Java, and
|
||||
supporting
|
||||
the calling of goals within Prolog and the retrieving of results back
|
||||
into
|
||||
Java</font></li>
|
||||
</ul>
|
||||
<ul style="font-family: helvetica,arial,sans-serif;">
|
||||
<li>when called from Prolog, <span style="font-style: italic;">void</span>
|
||||
methods return a <span style="font-style: italic;">void</span> value
|
||||
(which is distinct from all other <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> values and
|
||||
references)</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><font face="Arial,Helvetica">it uses </font><b><tt><font
|
||||
size="+1">@/1</font></tt></b><font face="Arial,Helvetica"> to
|
||||
construct representations of certain Java values; if </font><b><tt><font
|
||||
size="+1">@/1</font></tt></b><font face="Arial,Helvetica"> is defined
|
||||
as a
|
||||
prefix operator (as used by XPCE), then you can write </font><b><tt><font
|
||||
size="+1">@false</font></tt></b><font face="Arial,Helvetica">, </font><b><tt><font
|
||||
size="+1">@true</font></tt></b><font face="Arial,Helvetica">, </font><b><tt><font
|
||||
size="+1">@null</font></tt></b><font face="Arial,Helvetica"> etc. in
|
||||
your
|
||||
source code; </font><font face="Arial,Helvetica">otherwise (and for
|
||||
portability) you'll have to write e.g. </font><b><tt><font size="+1">@(true)</font></tt></b><font
|
||||
face="Arial,Helvetica"> etc.</font></li>
|
||||
</ul>
|
||||
<hr width="100%">
|
||||
<h2><a name="JPL_types_Java_types_as_seen_by"></a>JPL types (Java
|
||||
types, as seen by Prolog)</h2>
|
||||
<blockquote><font face="Arial,Helvetica">All Java values and object
|
||||
references which are passed between Prolog engines and Java VMs via <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>'s Prolog API
|
||||
are seen as instances of types within this simplified <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> type system:<br>
|
||||
<br>
|
||||
a <b><i>datum</i></b> (this term is introduced, out of
|
||||
necessity, to refer jointly to <span style="font-style: italic;">values
|
||||
</span>and <span style="font-style: italic;">refs</span>)</font>
|
||||
<blockquote><font face="Arial,Helvetica">is a <b><i>value</i></b>
|
||||
(values are copied between Prolog and the JVM)</font></blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">is a <b><i>boolean</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>char</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>long</i></b>, <b><i>int</i></b>,
|
||||
<b><i>short</i></b> or <b><i>byte</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>double</i></b>
|
||||
or <b><i>float</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>string</i></b>
|
||||
(an instance of <span style="font-style: italic;">java.lang.String</span>)</font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>void</i></b>
|
||||
(an artificial value returned by calls to Java void methods)</font></blockquote>
|
||||
<font face="Arial,Helvetica">or a <b><i>ref</i></b></font>
|
||||
<blockquote><font face="Arial,Helvetica">is <b><i>null</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or an <b><i>object</i></b>
|
||||
(held within the JVM, and represented in Prolog by a canonical
|
||||
reference)</font>
|
||||
<blockquote><font face="Arial,Helvetica">is an <b><i>array</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">or a <b><i>class
|
||||
instance</i></b> (other than of <span style="font-style: italic;">java.lang.String</span>)<b><i><br>
|
||||
</i></b></font></blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<hr width="100%">
|
||||
<h2><a name="representation_of_Java_values..."></a> representation of
|
||||
Java values and references within Prolog</h2>
|
||||
<span style="font-family: helvetica,arial,sans-serif;">Instances of <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> types are
|
||||
represented within Prolog as follows:</span><br
|
||||
style="font-family: helvetica,arial,sans-serif;">
|
||||
<blockquote><font face="Arial,Helvetica"><b><i>boolean</i></b> has two
|
||||
values,
|
||||
represented by </font><b><tt><font size="+1">@(true)</font></tt></b><font
|
||||
face="Arial,Helvetica"> and </font><b><tt><font size="+1">@(false)</font></tt></b>
|
||||
<p><font face="Arial,Helvetica"><b><i>char</i></b> values are
|
||||
represented by corresponding Prolog <i>integers</i></font> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>int</i></b>, <b><i>short</i></b>
|
||||
and <b><i>byte</i></b> values are represented by corresponding Prolog <i>integers</i></font>
|
||||
</p>
|
||||
<p><font face="Arial,Helvetica"><b><i>long</i></b> values are
|
||||
represented as Prolog <i>integers</i> if possible (32-bit in current
|
||||
SWI-Prolog), else as </font><b><tt><font size="+1">jlong(Hi,Lo)</font></tt></b><font
|
||||
face="Arial,Helvetica"> where </font><b><tt><font size="+1">Hi</font></tt></b><font
|
||||
face="Arial,Helvetica"> is an <i>integer</i> corresponding to the
|
||||
top32
|
||||
bits of the long, and </font><b><tt><font size="+1">Lo</font></tt></b><font
|
||||
face="Arial,Helvetica"> similarly represents the lower 32 bits</font> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>double</i></b> and <b><i>float</i></b>
|
||||
values are represented as Prolog floats (which are equivalent to Java
|
||||
doubles) (there may be minor rounding, normalisation or
|
||||
loss-of-precision issues when
|
||||
a Java float is widened to a Prolog float then narrowed back again, but
|
||||
what
|
||||
the heck)</font> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>string</i></b> values
|
||||
(immutable instances
|
||||
of <span style="font-style: italic;">java.lang.Stri</span>ng) are
|
||||
represented as Prolog <i>atoms</i> (in UTF-8 encoding)</font> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>null</i></b> has only one
|
||||
value, represented
|
||||
as </font><b><tt><font size="+1">@(null)</font></tt></b> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>void</i></b> has only one
|
||||
value, represented
|
||||
as </font><b><tt><font size="+1">@(void)</font></tt></b> </p>
|
||||
<p><font face="Arial,Helvetica"><b><i>array</i></b> and <b><i>class
|
||||
instance</i></b> references are currently represented as </font><b><tt><font
|
||||
size="+1">@(Tag)</font></tt></b><font face="Arial,Helvetica">, where
|
||||
Tag ia an <i>atom</i> whose name encodes
|
||||
a JNI global reference value; this may change, but won't affect Prolog
|
||||
programs
|
||||
which respect the opacity of references</font></p>
|
||||
</blockquote>
|
||||
<hr width="100%">
|
||||
<h2><a name="repn_of_Java_types_1_structured"></a> representation of
|
||||
Java types within Prolog (1): <i>structured</i> notation</h2>
|
||||
<font face="Arial,Helvetica">The <span
|
||||
style="font-weight: bold; font-style: italic;">JPL Prolog API</span>
|
||||
allows Prolog
|
||||
applications to inspect, manipulate, and reason about the types of Java
|
||||
values, references,
|
||||
methods etc., and this section describes how these types themselves (as
|
||||
opposed to instances thereof) are represented. Predicates which
|
||||
pass these type representations include </font><b><a
|
||||
href="api.html#jpl_class_to_type/2">jpl_class_to_type/2</a>, </b><b><a
|
||||
href="api.html#jpl_classname_to_type/2">jpl_classname_to_type/2</a>,
|
||||
</b><b><a href="api.html#jpl_datum_to_type/2">jpl_datum_to_type/2</a>,
|
||||
</b><b><a href="api.html#jpl_is_object_type/1">jpl_is_object_type/1</a>,
|
||||
</b><b><a href="api.html#jpl_is_type/1">jpl_is_type/1</a>, </b><a
|
||||
href="api.html#jpl_object_to_type/2" style="font-weight: bold;">jpl_object_to_type/2</a><b>,
|
||||
</b><b><a href="api.html#jpl_primitive_type/1">jpl_primitive_type/1</a>,
|
||||
</b><b><a href="api.html#jpl_ref_to_type/2">jpl_ref_to_type/2</a>, </b><b><a
|
||||
href="api.html#jpl_type_to_class/2">jpl_type_to_class/2</a>. </b><b><a
|
||||
href="api.html#jpl_type_to_classname/2">jpl_type_to_classname/2</a>.</b>
|
||||
<blockquote><font face="Arial,Helvetica"><b><i>void</i></b> is
|
||||
represented as </font><b><tt><font size="+1">void</font></tt></b></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica"><b><i>null</i></b> is
|
||||
represented as </font><b><tt><font size="+1">null</font></tt></b></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">the primitive types are
|
||||
represented as </font><b><tt><font size="+1">boolean</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">char</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">byte</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">short</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">int</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">long</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">float</font></tt></b><font
|
||||
face="Arial,Helvetica">, </font><b><tt><font size="+1">double</font></tt></b></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica"><b><i>classes</i></b> are
|
||||
represented as </font><b><tt><font size="+1">class(</font></tt></b><i><font
|
||||
face="Arial,Helvetica">package_parts</font></i><b><tt><font size="+1">,</font></tt></b><i><font
|
||||
face="Arial,Helvetica">classname_parts</font></i><b><tt><font size="+1">)</font></tt></b>
|
||||
<blockquote><font face="Arial,Helvetica">e.g. </font><b><tt><font
|
||||
size="+1">class([java,util],['Date'])</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica"><b><i>array</i></b> types are
|
||||
represented as </font><b><tt><font size="+1">array(</font></tt></b><i><font
|
||||
face="Arial,Helvetica">type</font></i><b><tt><font size="+1">)</font></tt></b>
|
||||
<blockquote>e.g. <b><tt><font size="+1">array(boolean)</font></tt></b></blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote>e.g. <b><tt><font size="+1">array(class([java,lang],['String'])<br>
|
||||
</font></tt></b></blockquote>
|
||||
</blockquote>
|
||||
<span style="font-family: helvetica,arial,sans-serif;">This <span
|
||||
style="font-style: italic;">structured </span>notation for Java types
|
||||
is designed to be convenient for composition and decomposition by
|
||||
matching (unification).</span><br>
|
||||
<hr width="100%" style="font-family: helvetica,arial,sans-serif;">
|
||||
<h2><a name="repn_of_Java_types_2_descriptor"></a> representation of
|
||||
Java types within Prolog (2): <i>descriptor</i> notation</h2>
|
||||
<font face="Arial,Helvetica">The <i>descriptor</i> notation for Java
|
||||
types is one of two textual notations employed by the JVM and the Java
|
||||
class libraries; <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
(necessarily)
|
||||
supports both (and supports conversion between all three
|
||||
representations).</font>
|
||||
<p><font face="Arial,Helvetica">Examples:</font> </p>
|
||||
<blockquote><b><tt><font size="+1">'Z'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>boolean</i></b></font>
|
||||
<p><b><tt><font size="+1">'B'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>byte</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'C'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>char</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'S'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>short</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'I'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>int</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'J'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>long</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'F'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>float</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'D'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes <b><i>double</i></b></font> </p>
|
||||
<p><b><tt><font size="+1">'Ljava/util/Date;'</font></tt></b><font
|
||||
face="Arial,Helvetica"> (for example) deno<span
|
||||
style="font-family: helvetica,arial,sans-serif;">tes the Jav</span>a
|
||||
clas<span style="font-family: helvetica,arial,sans-serif;">s </span></font><span
|
||||
style="font-family: helvetica,arial,sans-serif; font-style: italic;">java.util.Date</span>
|
||||
</p>
|
||||
<p><b><tt><font size="+1">'[</font></tt></b><i><font
|
||||
face="Arial,Helvetica">type</font></i><b><tt><font size="+1">'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes an <b><i>array</i></b> of <i>type</i></font>
|
||||
</p>
|
||||
<p><b><tt><font size="+1">'(</font></tt></b><i><font
|
||||
face="Arial,Helvetica">argument_types</font></i><b><tt><font size="+1">)</font></tt></b><i><font
|
||||
face="Arial,Helvetica">return_type</font></i><b><tt><font size="+1">'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes the type of a method</font></p>
|
||||
</blockquote>
|
||||
<hr width="100%">
|
||||
<h2><a name="repn_of_Java_types_3_classname"></a> representation of
|
||||
Java types within Prolog (3): <i>classname</i> notation</h2>
|
||||
<font face="Arial,Helvetica">The <i>classname</i> notation for Java
|
||||
types is the other textual notation employed by the JVM and the Java
|
||||
class libraries. It is a (seemingly unnecessary) variation on the
|
||||
<i>descriptor</i> notation, used by a few JNI routines. It has
|
||||
the slight advantage that, in the
|
||||
case of simple class types only, it resembles the Java source text
|
||||
notation for classes. This representation is supported only
|
||||
because certain JNI functions use it; it is used within <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>'s
|
||||
implementation of <span style="font-weight: bold;">jpl_call/4</span>
|
||||
etc. You may encounter this notation when tracing <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> activity,
|
||||
but otherwise you need not know about it.</font>
|
||||
<p><font face="Arial,Helvetica">Examples:</font> </p>
|
||||
<blockquote><b><tt><font size="+1">'java.util.Vector'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes the Java class </font><tt><font
|
||||
size="+1">java.util.Vector</font></tt></blockquote>
|
||||
<blockquote><b><tt><font size="+1">'[B'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes an <b><i>array</i></b> of <b><i>boolean</i></b></font></blockquote>
|
||||
<blockquote><b><tt><font size="+1">'[Ljava.lang.String;'</font></tt></b><font
|
||||
face="Arial,Helvetica"> denotes an <b><i>array</i></b> of <b><i>string</i></b></font></blockquote>
|
||||
<hr width="100%">
|
||||
<h1>Using the <span style="font-style: italic;">JPL 3.x</span> Prolog
|
||||
API<br>
|
||||
</h1>
|
||||
<h2><a name="creating_instances_of_Java_classes"></a> creating
|
||||
instances of Java classes</h2>
|
||||
<font face="Arial,Helvetica">To create an instance of a Java class from
|
||||
within Prolog,
|
||||
call <b>jpl_new(+Class,+Params,-Ref)</b> with a classname, a list of
|
||||
actual parameters for the
|
||||
constructor, and a variable to be bound to the new reference, e.g.</font>
|
||||
<blockquote><b><tt><font size="+1">jpl_new( 'javax.swing.JFrame',
|
||||
['frame with dialog'], F)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">which binds <b>F</b> to a new object
|
||||
reference, e.g.</font>
|
||||
<blockquote><font face="Arial,Helvetica"> </font><b><tt><font
|
||||
size="+1">@('J#0008272420')</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">(not that the details of this structure
|
||||
are of any necessary concern to the Prolog programmer or to the
|
||||
applications she
|
||||
writes).<br>
|
||||
NB for convenience, this predicate is overloaded: <span
|
||||
style="font-weight: bold;">Class</span> can also be a class type in <span
|
||||
style="font-style: italic;">structured </span>notation, e.g. <code>array(boolean)</code>.<br>
|
||||
</font>
|
||||
<p> </p>
|
||||
<hr width="100%">
|
||||
<h2><a name="calling_methods_of_Java_objects_..."></a> calling methods
|
||||
of Java objects or classes</h2>
|
||||
<font face="Arial,Helvetica">The object reference generated by the <b>jpl_new/3</b>
|
||||
call (above) can be passed to other <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> API
|
||||
predicates such as <br>
|
||||
</font>
|
||||
<blockquote><b><tt><font size="+1">jpl_call( +Ref, +Method, +Params,
|
||||
-Result)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">e.g.</font>
|
||||
<blockquote><b><tt><font size="+1">jpl_call( F, setVisible, [@(true)],
|
||||
_)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">which calls the <b>setVisible</b> method
|
||||
of the object to which <b>F</b> refers, effectively passing it the
|
||||
Java value <span style="font-style: italic;">true.</span></font>
|
||||
<p><font face="Arial,Helvetica">(This call should display the new <b>JFrame</b>
|
||||
in the top left corner of the desktop.)</font> </p>
|
||||
<p><font face="Arial,Helvetica">Note the anonymous variable passed as
|
||||
the fourth argument to <b>jsp_call/4. </b> A variable in this
|
||||
position receives
|
||||
the result of the method call: either a value or a reference.
|
||||
Since
|
||||
</font><b><tt><font size="+1">SetVisible()</font></tt></b><font
|
||||
face="Arial,Helvetica"> is a void method, the call returns the
|
||||
(artificial)
|
||||
reference </font><b><tt><font size="+1">@(void)</font></tt></b><font
|
||||
face="Arial,Helvetica">.</font> </p>
|
||||
<p><font face="Arial,Helvetica">Some may prefer to code this call thus:</font>
|
||||
</p>
|
||||
<blockquote><b><tt><font size="+1">jpl_call( F, setVisible, [@true],
|
||||
@void)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">which documents the programmer's
|
||||
understanding that this is a <span style="font-style: italic;">void </span>method
|
||||
(and fails if it isn't :-).</font><font face="Arial,Helvetica"><br>
|
||||
</font> <br>
|
||||
<font face="Arial,Helvetica">If the <span
|
||||
style="font-family: helvetica,arial,sans-serif; font-weight: bold;">+Ref</span>
|
||||
argument represents a class, then the named static method of that
|
||||
class is called.</font>
|
||||
<p> </p>
|
||||
<hr width="100%">
|
||||
<h2><a name="fetching_field_values_of_Java_objects..."></a> fetching
|
||||
field values of Java objects or classes</h2>
|
||||
<font face="Arial,Helvetica">The <b>jpl_get/3</b> API predicate can
|
||||
retrieve the value of an instance field or a static field, e.g.</font>
|
||||
<blockquote><b><tt><font size="+1">jpl_get( 'java.awt.Color', pink,
|
||||
Pink)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">which binds the Prolog variable </font><b><tt><font
|
||||
size="+1">Pink</font></tt></b><font face="Arial,Helvetica"> to a
|
||||
reference to the predefined <b>java.awt.Color</b>
|
||||
"constant" which is held in the static final <b>.pink</b> field of the
|
||||
<b>java.awt.Color</b>
|
||||
class.</font>
|
||||
<p><font face="Arial,Helvetica">More generally, <b>jpl_get/3</b> has
|
||||
the following
|
||||
interface:</font> </p>
|
||||
<blockquote><b><tt><font size="+1">jpl_get( +Class_or_Object, +Field,
|
||||
-Datum)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">If the first argument represents a class,
|
||||
then
|
||||
a static field of that class with FieldName is accessed.</font>
|
||||
<p> </p>
|
||||
<hr width="100%">
|
||||
<h2><a name="setting_field_values_of_Java_objects..."></a> setting
|
||||
field values of Java objects or classes</h2>
|
||||
<font face="Arial,Helvetica">Object and class fields can be set (i.e.
|
||||
have values or references assigned to them) by the <b>jpl_set/3</b>
|
||||
API procedure, which has the following interface:</font>
|
||||
<blockquote><b><tt><font size="+1">jpl_set( +Class_or_Object, +Field,
|
||||
+Datum)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">where <b>Datum</b> must be a value or
|
||||
reference of a type suitable for assignment to the named field of the
|
||||
class or object.</font>
|
||||
<p> </p>
|
||||
<hr width="100%">
|
||||
<h2><a name="a_slightly_longer_example"></a> a slightly longer example</h2>
|
||||
<font face="Arial,Helvetica">This code fragment</font>
|
||||
<pre><b><tt><font size="+1"> findall(<br> Ar,<br> ( current_prolog_flag( N, V),<br> term_to_atom( V, Va),<br> jpl_new( '[Ljava.lang.String;', [N,Va], Ar)<br> ),<br> Ars<br> ),<br> jpl_new( '[[Ljava.lang.String;', Ars, Ac),<br> jpl_datums_to_array( [name,value], Ah),<br> jpl_new( 'javax.swing.JFrame', ['current_prolog_flag'], F),<br> jpl_call( F, getContentPane, [], CP),<br> jpl_new( 'javax.swing.JTable', [Ac,Ah], T),<br> jpl_new( 'javax.swing.JScrollPane', [T], SP),<br> jpl_call( CP, add, [SP,'Center'], _),<br> jpl_call( F, setSize, [600,400], _),</font></tt></b></pre>
|
||||
<font face="Arial,Helvetica">builds an array of arrays of strings
|
||||
containing the names and values of the current SWI-Prolog "flags", and
|
||||
displays it in
|
||||
a JTable within a ScrollPane within a JFrame:</font>
|
||||
<blockquote><img src="screendump.jpg" height="269" width="524"></blockquote>
|
||||
<font face="Arial,Helvetica">In addition to <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> API calls,
|
||||
this
|
||||
code calls <b>jpl_datums_to_array/2</b>, a utility which converts any
|
||||
list
|
||||
of valid representations of Java values (or objects) into a new Java
|
||||
array,
|
||||
whose base type is the most specialised type of which all list members
|
||||
are
|
||||
instances, and which is defined thus:</font>
|
||||
<blockquote>
|
||||
<pre><b><tt><font size="+1">jpl_datums_to_array( Ds, A) :-<br> ground( Ds),<br> jpl_datums_to_most_specific_common_ancestor_type( Ds, T),<br> jpl_new( array(T), Ds, A).</font></tt></b></pre>
|
||||
</blockquote>
|
||||
<font face="Arial,Helvetica">Having found the "most specific common
|
||||
ancestor type" (my phrase :-), a new array of this type is created,
|
||||
whose elements are initialised to the successive members of the list of
|
||||
datums.</font>
|
||||
<p><font face="Arial,Helvetica">This illustrates another mode of
|
||||
operation of <b>jpl_new/3</b>:</font> </p>
|
||||
<blockquote><b><tt><font size="+1">jpl_new( +ArrayType, +InitialValues,
|
||||
-ArrayRef)</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">See the relevant Appendix for fuller
|
||||
details of the API procedures.</font>
|
||||
<p><font face="Arial,Helvetica">Don't forget the possibility of writing
|
||||
and
|
||||
manipulating new Java classes to serve your Prolog applications: this
|
||||
interface
|
||||
is not designed to make Java programming redundant :-)</font> </p>
|
||||
<p> </p>
|
||||
<hr width="100%"> <br>
|
||||
<b><tt><font size="+2"><a name="jpl_new3"></a>jpl_new( +X, +Argz, -V) :-</font></tt></b>
|
||||
<blockquote><b><tt><font size="+1">X</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a suitable <i>type</i></font></li>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">i.e. any </font><b><tt><font
|
||||
size="+1">class(_,_)</font></tt></b><font face="Arial,Helvetica">, </font><b><tt><font
|
||||
size="+1">array(_)</font></tt></b><font face="Arial,Helvetica"> or
|
||||
primitive
|
||||
type (e.g. </font><b><tt><font size="+1">byte</font></tt></b><font
|
||||
face="Arial,Helvetica"> but not </font><b><tt><font size="+1">void</font></tt></b><font
|
||||
face="Arial,Helvetica">)</font></li>
|
||||
</ul>
|
||||
<li> <font face="Arial,Helvetica">an atomic <i>classname</i></font></li>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">e.g. </font><b><tt><font
|
||||
size="+1">'java.lang.String'</font></tt></b></li>
|
||||
<li> <font face="Arial,Helvetica">e.g. </font><b><tt><font
|
||||
size="+1">'Ljava.lang.String;'</font></tt></b><font
|
||||
face="Arial,Helvetica"> (a redundant but legitimate form)</font></li>
|
||||
</ul>
|
||||
<li> <font face="Arial,Helvetica">an atomic <i>descriptor</i></font></li>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">e.g. </font><b><tt><font
|
||||
size="+1">'[I'</font></tt></b></li>
|
||||
</ul>
|
||||
<li> <font face="Arial,Helvetica">a class object</font></li>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">i.e. an object whose type
|
||||
is </font><b><tt><font size="+1">class([java,lang],['Class'])</font></tt></b></li>
|
||||
</ul>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">if </font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> denotes a
|
||||
primitive
|
||||
type and </font><b><tt><font size="+1">Argz</font></tt></b><font
|
||||
face="Arial,Helvetica"> is castable to a value of that type, then </font><b><tt><font
|
||||
size="+1">V</font></tt></b><font face="Arial,Helvetica"> is that value
|
||||
(a
|
||||
pointless mode of operation, but somehow complete...)</font></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">if </font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> denotes an
|
||||
array
|
||||
type and </font><b><tt><font size="+1">Argz</font></tt></b><font
|
||||
face="Arial,Helvetica"> is a non-negative integer, then </font><b><tt><font
|
||||
size="+1">V</font></tt></b><font face="Arial,Helvetica"> is a new
|
||||
array
|
||||
of that many elements, initialised to the appropriate default value</font></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">if </font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> denotes an
|
||||
array
|
||||
type and </font><b><tt><font size="+1">Argz</font></tt></b><font
|
||||
face="Arial,Helvetica"> is a list of datums, each of which is
|
||||
(independently)
|
||||
castable to the array element type, then </font><b><tt><font size="+1">V</font></tt></b><font
|
||||
face="Arial,Helvetica"> is a new array of as many elements as </font><b><tt><font
|
||||
size="+1">Argz</font></tt></b><font face="Arial,Helvetica"> has
|
||||
members,
|
||||
initialised to the results of casting the respective members of </font><b><tt><font
|
||||
size="+1">Argz</font></tt></b></blockquote>
|
||||
<blockquote><font face="Arial,Helvetica">if </font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> denotes a
|
||||
non-array
|
||||
object type and </font><b><tt><font size="+1">Argz</font></tt></b><font
|
||||
face="Arial,Helvetica"> is a list of datums, then </font><b><tt><font
|
||||
size="+1">V</font></tt></b><font face="Arial,Helvetica"> is the result
|
||||
of
|
||||
an invocation of that type's most specifically-typed constructor to
|
||||
whose
|
||||
respective parameters the members of </font><b><tt><font size="+1">Argz</font></tt></b><font
|
||||
face="Arial,Helvetica"> are assignable</font></blockquote>
|
||||
<hr width="100%"> <br>
|
||||
<b><tt><font size="+2"><a name="jpl_call4"></a>jpl_call( +X, +Method,
|
||||
+Args, -R) :-</font></tt></b>
|
||||
<blockquote><b><tt><font size="+1">X</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font>
|
||||
<blockquote> <li> <font face="Arial,Helvetica">a <i>type</i>, <i>class
|
||||
object</i> or <i>classname</i> (for static methods of the denoted
|
||||
class,
|
||||
or for static or instance methods of java.lang.Class)</font></li>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote> <li> <font face="Arial,Helvetica">a class instance or
|
||||
array
|
||||
(for static or instance methods)</font></li>
|
||||
</blockquote>
|
||||
<b><tt><font size="+1">Method</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font>
|
||||
<blockquote> <li> <font face="Arial,Helvetica">an atomic method
|
||||
name (if this name is ambiguous, as a result of method overloading,
|
||||
then it will be resolved by considering the types of <span
|
||||
style="font-weight: bold;">Args</span>, as far as they can be inferred)</font></li>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote> <li> <font face="Arial,Helvetica">an integral method
|
||||
index
|
||||
(untested: for static overload resolution)</font></li>
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<blockquote> <li> <font face="Arial,Helvetica">a </font><b><tt><font
|
||||
size="+1">methodID/1</font></tt></b><font face="Arial,Helvetica">
|
||||
structure
|
||||
(ditto)</font></li>
|
||||
</blockquote>
|
||||
<b><tt><font size="+1">Args</font></tt></b><font
|
||||
face="Arial,Helvetica"> must be</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a proper list (possibly empty)
|
||||
of ground
|
||||
arguments</font></li>
|
||||
</ul>
|
||||
<font face="Arial,Helvetica">Finally, an attempt will be made to
|
||||
unify </font><b><tt><font size="+1">R</font></tt></b><font
|
||||
face="Arial,Helvetica"> with the returned
|
||||
result.</font></blockquote>
|
||||
<hr width="100%"> <br>
|
||||
<b><tt><font size="+2"><a name="jpl_set3"></a>jpl_set( +X, +Field, +V)
|
||||
:-</font></tt></b>
|
||||
<blockquote><font face="Arial,Helvetica">basically, sets the </font><b><tt><font
|
||||
size="+1">Fspec</font></tt></b><font face="Arial,Helvetica">-th field
|
||||
of
|
||||
object </font><b><tt><font size="+1">X</font></tt></b><font
|
||||
face="Arial,Helvetica"> to value </font><b><tt><font size="+1">V</font></tt></b>
|
||||
<p><b><tt><font size="+1">X</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font> </p>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a <i>class object</i>, a <i>classname</i>,
|
||||
or an (object or array) <i>type</i> (for static fields, or
|
||||
java.lang.Class fields)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a <i>class instance</i> (for
|
||||
non-static
|
||||
fields)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an <i>array</i> (for indexed
|
||||
element or
|
||||
subrange assignment)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">but not a <i>string</i> (no
|
||||
fields to
|
||||
retrieve)</font></li>
|
||||
</ul>
|
||||
<b><tt><font size="+1">Field</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an atomic field name
|
||||
(overloading will
|
||||
be resolved dynamically, by considering the inferred type of <span
|
||||
style="font-family: helvetica,arial,sans-serif; font-weight: bold;">V</span>)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an integral field index (static
|
||||
resolution: not tried yet)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a </font><b><tt><font size="+1">fieldID/1</font></tt></b><font
|
||||
face="Arial,Helvetica"> (static resolution: not tried yet)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a variable (field names, or
|
||||
array indices, are generated)(?!)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an array index </font><b><tt><font
|
||||
size="+1">I</font></tt></b><font face="Arial,Helvetica"> (</font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> must be an
|
||||
array
|
||||
object: </font><b><tt><font size="+1">X[I]</font></tt></b><font
|
||||
face="Arial,Helvetica"> is assigned </font><b><tt><font size="+1">V</font></tt></b><font
|
||||
face="Arial,Helvetica">)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a pair </font><b><tt><font
|
||||
size="+1">I-J</font></tt></b><font face="Arial,Helvetica"> of integers
|
||||
(</font><b><tt><font size="+1">J</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be a variable) (</font><b><tt><font
|
||||
size="+1">X</font></tt></b><font face="Arial,Helvetica"> must be an
|
||||
array
|
||||
object, </font><b><tt><font size="+1">V</font></tt></b><font
|
||||
face="Arial,Helvetica"> must be a list of values: </font><b><tt><font
|
||||
size="+1">X[I-J]</font></tt></b><font face="Arial,Helvetica"> will be
|
||||
assigned </font><b><tt><font size="+1">V</font></tt></b><font
|
||||
face="Arial,Helvetica">)</font></li>
|
||||
</ul>
|
||||
<b><tt><font size="+1">V</font></tt></b><font face="Arial,Helvetica">
|
||||
must be ground (although one day we may pass variables to <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span>?!)</font></blockquote>
|
||||
<hr width="100%"> <br>
|
||||
<b><tt><font size="+2"><a name="jpl_get3"></a>jpl_get( +X, +Field, -V)
|
||||
:-</font></tt></b>
|
||||
<blockquote><b><tt><font size="+1">X</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be:</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a <i>class object</i>, a <i>classname</i>,
|
||||
or an (object or array) <i>type</i> (for static fields, or
|
||||
java.lang.Class fields)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">a <i>class instance</i> (for
|
||||
non-static
|
||||
fields)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an <i>array</i> (for the
|
||||
'length' pseudo
|
||||
field, or for indexed element retrieval)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">but not a String (clashes with
|
||||
classname; anyway, java.lang.String has no fields to retrieve)</font></li>
|
||||
</ul>
|
||||
<b><tt><font size="+1">Field</font></tt></b><font
|
||||
face="Arial,Helvetica"> can be</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">an atomic field name</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">or an integral field index
|
||||
(these are
|
||||
a secret :-)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">or a </font><b><tt><font
|
||||
size="+1">fieldID/1</font></tt></b><font face="Arial,Helvetica"> (not
|
||||
for general consumption :-)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">or an integral array index
|
||||
(high-bound
|
||||
checking is done by JVM, maybe throwing an exception)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">or a variable (field names, or
|
||||
array indices, are generated)</font></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">or a pair </font><b><tt><font
|
||||
size="+1">I-J</font></tt></b><font face="Arial,Helvetica"> of integers
|
||||
or
|
||||
variables (array subranges are generated) (relational or what?!)<br>
|
||||
</font></li>
|
||||
</ul>
|
||||
<font face="Arial,Helvetica">Immediately before <span
|
||||
style="font-weight: bold;">jpl_get/4</span> returns</font><font
|
||||
face="Arial,Helvetica">, an attempt will be made to unify </font><b><tt><font
|
||||
size="+1">V</font></tt></b><font face="Arial,Helvetica"> with the
|
||||
internally computed result.</font></blockquote>
|
||||
<hr width="100%">
|
||||
<h2><a name="exceptions"></a> exceptions thrown by Java<br>
|
||||
</h2>
|
||||
<font face="Arial,Helvetica">Uncaught exceptions thrown by the JVM in
|
||||
the course of
|
||||
handling a <span style="font-weight: bold; font-style: italic;">JPL</span><span
|
||||
style="font-weight: bold;">
|
||||
3.x Prolog API</span> call are mapped onto Standard Prolog exceptions,
|
||||
e.g.</font>
|
||||
<blockquote>
|
||||
<pre><b><tt><font size="+1">jpl_new( 'java.util.Date', [yesterday], D)</font></tt></b></pre>
|
||||
</blockquote>
|
||||
<font face="Arial,Helvetica">raises the Prolog exception</font>
|
||||
<blockquote><b><tt><font size="+1">java_exception('java.lang.IllegalArgumentException',
|
||||
@'J#0008408972')</font></tt></b></blockquote>
|
||||
<font face="Arial,Helvetica">because, as the exception suggests, <span
|
||||
style="font-weight: bold;">yesterday </span>is not a valid
|
||||
constructor argument.</font><br>
|
||||
<br>
|
||||
<span style="font-family: helvetica,arial,sans-serif;">Java exceptions
|
||||
are always returned as Prolog exceptions with this structure:</span><br
|
||||
style="font-family: helvetica,arial,sans-serif;">
|
||||
<blockquote><b><tt><font size="+1">java_exception( <span
|
||||
style="font-style: italic;">classname</span>, <span
|
||||
style="font-style: italic;">reference_to_exception_object</span>)</font></tt></b></blockquote>
|
||||
<hr width="100%">
|
||||
<h2><a name="testing"></a>testing</h2>
|
||||
<font face="Arial,Helvetica">For a rudimentary test, run</font>
|
||||
<blockquote>
|
||||
<pre><b><tt><font size="+1">?- jpl_demo.</font></tt></b></pre>
|
||||
</blockquote>
|
||||
<font face="Arial,Helvetica">and wait patiently for some Swing windows
|
||||
to
|
||||
appear (but not too patiently, in case something is wrong...)</font>
|
||||
<p> </p>
|
||||
<hr width="100%">
|
||||
<h2><a name="to_do"></a> to do</h2>
|
||||
<font face="Arial,Helvetica">Apart from any bugs I don't know about,
|
||||
this interface is usable and useful as it stands. Nevertheless
|
||||
there are some things "to do" at some stage in the future, e.g.</font>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">support non-virtual method calls
|
||||
(i.e.
|
||||
explicitly call a method of some ancestor class despite there being an
|
||||
overriding method (i.e. of the same name etc.) in a "nearer" class).
|
||||
I believe
|
||||
this is a fairly arcane Java feature, but it is needed for
|
||||
completeness;
|
||||
I want to accommodate it without complicating the syntax of regular
|
||||
method
|
||||
calls.</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">map the JVM's </font><b><tt><font
|
||||
size="+1">vprintf()</font></tt></b><font face="Arial,Helvetica">
|
||||
messages
|
||||
onto something in SWI-Prolog (the user_error stream?)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">catch the JVM's </font><b><tt><font
|
||||
size="+1">abort()</font></tt></b><font face="Arial,Helvetica"> and </font><b><tt><font
|
||||
size="+1">exit()</font></tt></b><font face="Arial,Helvetica"> events,
|
||||
and
|
||||
handle them appropriately (e.g. stop a Java <i>abort</i> from killing
|
||||
the
|
||||
SWI-Prolog process)</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">propagate SWI-Prolog's ABORT
|
||||
action into
|
||||
the JVM as appropriate, e.g. to interrupt a pending <span
|
||||
style="font-weight: bold; font-style: italic;">JPL</span> call</font></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li> <font face="Arial,Helvetica">reduce the (extravagant) overheads
|
||||
of
|
||||
each <span style="font-weight: bold; font-style: italic;">JPL</span>
|
||||
call
|
||||
(without compromising functionality or safety)</font></li>
|
||||
</ul>
|
||||
<hr width="100%">
|
||||
<address> <font size="+1"><a href="mailto:paul.singleton@bcs.org.uk">Paul
|
||||
Singleton</a></font></address>
|
||||
<address> <font size="+1">drafted 10th November 2000</font></address>
|
||||
<address> <font size="+1">revised 14th December 2000<br>
|
||||
</font>
|
||||
</address>
|
||||
<address> <font size="+1">revised 11th March 2003<br>
|
||||
revised 18th February 2004<br>
|
||||
<br>
|
||||
</font></address>
|
||||
<br>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 35 KiB |
@ -1,555 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.74 [en] (WinNT; U) [Netscape]">
|
||||
<title>JPL release notes</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><span style="font-style: italic;">
|
||||
JPL</span> release notes</h1>
|
||||
<ul>
|
||||
<li><a href="#JPL_3.0.3_Java_API">JPL 3.0.3 Release Notes</a></li>
|
||||
<li><a href="#JPL_3.0.2_Java_API">JPL 3.0.2 Release Notes</a></li>
|
||||
<li><a href="#JPL_3.0.0_Java_API">JPL 3.0.0 Java API Release Notes</a><br>
|
||||
</li>
|
||||
<li><a href="#JPL_2.0.2_Java_API">JPL 2.0.2 Java API Release Notes</a></li>
|
||||
</ul>
|
||||
<br>
|
||||
<hr style="width: 100%; height: 4px;">
|
||||
<h2><span style="font-style: italic;"><a name="JPL_3.0.3_Java_API"></a>JPL
|
||||
3.0.3</span> Release Notes</h2>
|
||||
<h3>Changes within the distribution</h3>
|
||||
<ul>
|
||||
<li>the <small style="font-weight: bold;"><span
|
||||
style="font-family: helvetica,arial,sans-serif;">demo</span></small>
|
||||
folder has been renamed <small style="font-weight: bold;"><span
|
||||
style="font-family: helvetica,arial,sans-serif;">examples</span></small>
|
||||
(more idiomatic)(?) and its contents have been moved into a new <small><span
|
||||
style="font-family: helvetica,arial,sans-serif; font-weight: bold;">java</span></small>
|
||||
folder, which is accompanied by a new <small><span
|
||||
style="font-family: helvetica,arial,sans-serif; font-weight: bold;">prolog</span></small>
|
||||
folder for Prolog examples</li>
|
||||
</ul>
|
||||
<h3>Java API changes</h3>
|
||||
<ul>
|
||||
<li>to simplify the construction of queries, the <span
|
||||
style="font-weight: bold;">Query(java.lang.String)</span> constructor
|
||||
now parses its string arg as if it were Prolog source text, and
|
||||
constructs a new query whose goal is the resulting term. This is
|
||||
backwards compatible with (all but very unusual) previous usage, e.g.</li>
|
||||
</ul>
|
||||
<pre style="margin-left: 80px;">new Query("statistics")<br></pre>
|
||||
<div style="margin-left: 40px;">and allows arbitrarily complex goals to
|
||||
be created textually, e.g.<br>
|
||||
<pre style="margin-left: 40px;">new Query("setof(_A,current_atom(_A),_As),length(_As,N)")<br></pre>
|
||||
NB <span style="font-family: monospace;">_A</span> and <span
|
||||
style="font-family: monospace;">_As</span> are <span
|
||||
style="font-style: italic;">dont-tell-me</span> variables (this
|
||||
property is determined by their initial underscore), whose bindings are
|
||||
by default not returned when the query is called (saving computational
|
||||
time and space). This behaviour can be overridden (globally) with<br>
|
||||
<pre style="margin-left: 40px;">jpl.JPL.setDTMMode( false)<br></pre>
|
||||
to
|
||||
allow Java+<span style="font-weight: bold; font-style: italic;">JPL</span>+Prolog
|
||||
implementation of a Prolog IDE which emulates the behaviour of the
|
||||
traditional top-level interpreter. <br>
|
||||
</div>
|
||||
<ul>
|
||||
<li>to further simplify construction of queries, the <span
|
||||
style="font-weight: bold;">Query(java.lang.String <span
|
||||
style="font-style: italic;">text</span>, jpl.Term[] <span
|
||||
style="font-style: italic;">args</span>)</span> constructor now parses
|
||||
its <span style="font-weight: bold; font-style: italic;">text</span>
|
||||
argument as a Prolog source text fragment; if it represents an atom,
|
||||
the constructor behaves as before (building a <span
|
||||
style="font-weight: bold;">Compound</span> goal from the given name
|
||||
and args), but if it represents a compound term with one or more atomic
|
||||
subterms whose names are a single <span style="font-style: italic;">questionmark</span>
|
||||
character, e.g.</li>
|
||||
</ul>
|
||||
<pre style="margin-left: 80px;">"setof(P,mypred(?,P,?),Ps), length(Ps,?)"<br></pre>
|
||||
<div style="margin-left: 40px;">and the <span
|
||||
style="font-weight: bold; font-style: italic;">args</span> comprise as
|
||||
many terms as there are questionmarks, then the new query's goal is a
|
||||
rewriting of <span style="font-weight: bold; font-style: italic;">text</span>'s
|
||||
term, with each questionmark replaced by the corresponding element of <span
|
||||
style="font-weight: bold; font-style: italic;">args</span>. This
|
||||
is designed to mimic the established and useful idiom of passing
|
||||
parameters into SQL <span style="font-style: italic;">prepared
|
||||
statements</span>. It allows all the constant parts of a
|
||||
parameterised query to be defined textually.<br>
|
||||
<br>
|
||||
</div>
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>Friday12th March 2004<br>
|
||||
<br>
|
||||
</address>
|
||||
<hr style="width: 100%; height: 4px;">
|
||||
<h2><span style="font-style: italic;"><a name="JPL_3.0.2_Java_API"></a>JPL
|
||||
3.0.2</span> Release Notes</h2>
|
||||
<h3>Changes within the distribution</h3>
|
||||
<ul>
|
||||
<li><span style="font-style: italic;">new classes folder:</span> the
|
||||
root directory of the distribution now contains
|
||||
a classes folder, holding copies of the jpl.* and jpl.fli.* class files</li>
|
||||
<li><span style="font-style: italic;">new demo:</span> in
|
||||
demo/FamilyMT is a new variant of the Family demo which
|
||||
exercises multiple Prolog engines (from a shared pool) called by
|
||||
multiple Java threads.</li>
|
||||
</ul>
|
||||
<h3>C library changes:</h3>
|
||||
<ul>
|
||||
<li>lots of refactoring and tidying in preparation for porting (to
|
||||
Linux+gcc initially)</li>
|
||||
<li>added Prolog "foreign" functions <span style="font-weight: bold;">jpl_c_lib_version/1</span>
|
||||
and <span style="font-weight: bold;">jpl_c_lib_version/4</span> for
|
||||
making library version identification available to Prolog</li>
|
||||
<li>added Java "native" method <span style="font-weight: bold;">get_string_chars()</span>,
|
||||
needed if Prolog returns a string to Java (which it does sometime even
|
||||
if you don't want it to)</li>
|
||||
<li>commented out various unused functions</li>
|
||||
<li>added Java "native" method <span style="font-weight: bold;">action_abort()</span>
|
||||
but it doesn't work yet...</li>
|
||||
<li>added support for new <span style="font-weight: bold;">jpl.JRef</span>
|
||||
type<br>
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Java API changes<br>
|
||||
</h3>
|
||||
<ul>
|
||||
<li>altered the semantics of <span style="font-weight: bold;">Variable</span>
|
||||
to be a purely lexical entity; a <span style="font-weight: bold;">Variable</span>
|
||||
instance should be created with a name which is valid in Prolog source
|
||||
syntax; the argumentless <span style="font-weight: bold;">Variable()</span>
|
||||
constructor is currently deprecated and constructs a variable with a
|
||||
"new" name in the sequence "_1", "_2" etc. so as not to completely
|
||||
break older programs</li>
|
||||
<li>bindings from successful calls are now keyed by the <span
|
||||
style="font-style: italic;">names</span> of the variables, rather than
|
||||
by <span style="font-weight: bold;">Variable</span> objects
|
||||
themselves; this is part of a revamp to allow goals to be defined by
|
||||
source text fragments<br>
|
||||
</li>
|
||||
<li>implemented these methods for <span style="font-style: italic;">all</span>
|
||||
<span style="font-weight: bold;">Term</span> subclasses (to
|
||||
simplify coding of term checking and traversal etc.):</li>
|
||||
<dl>
|
||||
<dt><span style="font-weight: bold;">type()</span></dt>
|
||||
</dl>
|
||||
<dl>
|
||||
<dd>returns <span style="font-weight: bold;">jpl.fli.Prolog.ATOM</span>,
|
||||
<span style="font-weight: bold;">COMPOUND</span>, <span
|
||||
style="font-weight: bold;">FLOAT</span>, <span
|
||||
style="font-weight: bold;">INT</span> or <span
|
||||
style="font-weight: bold;">VARIABLE</span><br>
|
||||
</dd>
|
||||
<dt><span style="font-weight: bold;">hasFunctor( String <span
|
||||
style="font-style: italic;">name</span>, int <span
|
||||
style="font-style: italic;">arity</span>) </span></dt>
|
||||
<dd>fails unless called appropriately; <br>
|
||||
</dd>
|
||||
<dt style="font-weight: bold;">intValue()<br>
|
||||
longValue()<br>
|
||||
floatValue()<br>
|
||||
doubleValue()</dt>
|
||||
<dd><span style="font-weight: normal;">yield
|
||||
the Java int value (or long, float or double value respectively) of an <span
|
||||
style="font-weight: bold;">Integer</span> or <span
|
||||
style="font-weight: bold;">Float</span> instance; each will throw an
|
||||
exception
|
||||
for <span style="font-weight: bold;">Atom</span>, <span
|
||||
style="font-weight: bold;">Compound</span> and <span
|
||||
style="font-weight: bold;">Variable</span> instances; the names of
|
||||
these methods follow the precedent set by <span
|
||||
style="font-weight: bold;">java.lang.Integer</span> etc. and remember
|
||||
that a Prolog integer is not equivalent to a Java int (it may be longer
|
||||
or shorter), nor is a Prolog float equivalent to a Java float (it may
|
||||
have a different precision)</span></dd>
|
||||
<dd><ddstyle ="margin-left: 80px;"> </ddstyle></dd>
|
||||
<dt><span style="font-weight: bold;">arg( int <span
|
||||
style="font-style: italic;">argNo</span>)</span><br>
|
||||
</dt>
|
||||
<dd><span style="font-weight: normal;">calling </span><span
|
||||
style="font-weight: bold;">arg()</span><span
|
||||
style="font-weight: normal;"> inappropriately (i.e. for </span><span
|
||||
style="font-weight: bold;">jpl.Atom</span><span
|
||||
style="font-weight: normal;">, </span><span style="font-weight: bold;">jpl.Integer</span><span
|
||||
style="font-weight: normal;">, </span><span style="font-weight: bold;">jpl.Float</span><span
|
||||
style="font-weight: normal;"> and </span><span
|
||||
style="font-weight: bold;">jpl.Variable</span><span
|
||||
style="font-weight: normal;"> instances) throws a runtime exception
|
||||
but is not a compile-time error; this method considers the args to be
|
||||
numbered from 1 upwards (i.e. Prolog convention, not Java array
|
||||
convention)</span></dd>
|
||||
<dt><span style="font-weight: normal;"><span
|
||||
style="font-weight: bold;">name()</span></span></dt>
|
||||
</dl>
|
||||
<dl>
|
||||
<dd><span style="font-weight: normal;"><span
|
||||
style="font-weight: bold;">Variable.name()</span> returns the
|
||||
variable's lexical name, <span style="font-weight: bold;">Atom.name()</span>
|
||||
and <span style="font-weight: bold;">Compound.name()</span> behave as
|
||||
before, <span style="font-weight: bold;">Integer.name()</span> and <span
|
||||
style="font-weight: bold;">Float.name()</span> each throw an exception
|
||||
if called (but are valid at compile time)<br>
|
||||
</span></dd>
|
||||
</dl>
|
||||
<li>altered these methods for all <span style="font-weight: bold;">Term</span>
|
||||
subclasses:</li>
|
||||
<ul>
|
||||
<li><span style="font-weight: bold;">toString()</span> now yields
|
||||
a valid (quoted if necessary) Prolog source text representation<br>
|
||||
</li>
|
||||
</ul>
|
||||
<li>deprecated <span style="font-weight: bold;">Compound.arg0()</span>
|
||||
and all *<span style="font-weight: bold;">.debugString()</span> methods</li>
|
||||
<li>deprecated <span style="font-weight: bold;">Float.value()</span>
|
||||
(see <span style="font-weight: bold;">floatValue()</span> and <span
|
||||
style="font-weight: bold;">doubleValue()</span>)<br>
|
||||
</li>
|
||||
<li><span style="font-weight: bold;">jpl.Integer</span> now holds a <span
|
||||
style="font-weight: bold;">long</span> value (to allow for
|
||||
other/future Prolog implementations with >32-bit integers) but this
|
||||
is backwards compatible if I understand Java correctly...<br>
|
||||
</li>
|
||||
<li>deprecated <span style="font-weight: bold;">jpl.Halt()</span>
|
||||
pending a rethink about how best to clean up and terminate a hybrid
|
||||
Java+Prolog application<span style="font-weight: bold;"><br>
|
||||
</span></li>
|
||||
<li>added <span style="font-weight: bold;">Query.abort()</span> but
|
||||
it doesn't work yet...<br>
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>Sunday 22nd February 2004<br>
|
||||
|
||||
<br>
|
||||
</address>
|
||||
<hr style="width: 100%; height: 4px;">
|
||||
<h2><span style="font-style: italic;"><a name="JPL_3.0.0_Java_API"></a>JPL
|
||||
3.0.0</span> Release Notes</h2>
|
||||
<span style="font-style: italic;">This
|
||||
release is a
|
||||
work-in-progress, and
|
||||
is being made available only to a few enthusiasts who don't mind the
|
||||
likelihood that the API will change before 3.x becomes stable.</span><br>
|
||||
<h3>Java API: new Variable semantics<br>
|
||||
</h3>
|
||||
<blockquote>A <span style="font-weight: bold;">Variable</span> must be
|
||||
created with a name, e.g.<span style="font-family: monospace;"><br>
|
||||
</span>
|
||||
<pre style="margin-left: 40px;"><span style="font-family: monospace;">new Variable("X")<br></span></pre>
|
||||
or as an anonymous variable<br>
|
||||
<pre style="margin-left: 40px;"><span style="font-family: monospace;">new Variable("_")</span></pre>
|
||||
</blockquote>
|
||||
<div style="margin-left: 40px;">or as a <span
|
||||
style="font-style: italic;">dont-tell-me</span> variable<br>
|
||||
</div>
|
||||
<blockquote>
|
||||
<pre style="margin-left: 40px;"><span style="font-family: monospace;">new Variable("_Q")</span></pre>
|
||||
</blockquote>
|
||||
<div style="margin-left: 40px;">Each binding within a solution is now
|
||||
indexed by the <span
|
||||
style="text-decoration: underline; font-style: italic;">name</span> of
|
||||
its associated <span style="font-weight: bold;">Variable</span>, hence<br>
|
||||
</div>
|
||||
<blockquote>
|
||||
<pre style="margin-left: 40px;">solution.get("X")<br></pre>
|
||||
</blockquote>
|
||||
<div style="margin-left: 40px;">New variables returned in bindings are
|
||||
given new, sequential names, e.g. "_283".<br>
|
||||
<br>
|
||||
Each <span style="font-weight: bold;">Variable </span>instance within
|
||||
a Java application is just a lexical token in the alternative Prolog
|
||||
concrete syntax which <span style="font-weight: bold;">Term </span>and
|
||||
its subclasses comprise. Two instances of <span
|
||||
style="font-family: monospace;">Variable("X")</span> are no different
|
||||
from one shared instance: you are free to reuse such lexical elements,
|
||||
but this has nothing to do with the sharing of variables which can
|
||||
occur within a Prolog engine.<br>
|
||||
<br>
|
||||
The bindings of anonymous and <span style="font-style: italic;">dont-tell-me</span>
|
||||
variables (i.e. those whose names begin with an underscore character)
|
||||
are not returned to Java: use them to avoid the computational time and
|
||||
space costs of constructing <span style="font-weight: bold;">Term</span>
|
||||
representations of bindings in which you are not interested.<br>
|
||||
</div>
|
||||
<h3>Java API: easier Term and Query construction</h3>
|
||||
<blockquote>Now that <span style="font-weight: bold;">Variable</span>s
|
||||
are named, and bindings are keyed by the names of variables, it is
|
||||
easier to construct <span style="font-weight: bold;">Term</span> (and
|
||||
hence <span style="font-weight: bold;">Query</span>) instances.<br>
|
||||
<br>
|
||||
This utility (NB liable to be renamed or moved into a different class)
|
||||
converts a valid Prolog source text representation of a term into a
|
||||
corresponding Term hierarchy:<br>
|
||||
<pre style="margin-left: 40px;">Term jpl.Util.textToTerm( String sourcetext)<br></pre>
|
||||
A new (in JPL 3.0.0) <span style="font-weight: bold;">Query</span>
|
||||
constructor<br>
|
||||
<pre style="margin-left: 40px;">Query( String sourcetext)<br></pre>
|
||||
allows queries to be created from source text, e.g.<br>
|
||||
<pre style="margin-left: 40px;">new Query("findall(_A,current_atom(_A),_As),length(_As,N)")<br></pre>
|
||||
and <span style="font-family: monospace;">oneSolution()</span>, <span
|
||||
style="font-family: monospace;">allSolutions()</span> and <span
|
||||
style="font-family: monospace;">nextSolution()</span> will return
|
||||
bindings of <span style="font-family: monospace; font-weight: bold;">N</span>
|
||||
(but not of the <span style="font-style: italic;">dont-tell-me</span>
|
||||
variables <span style="font-family: monospace; font-weight: bold;">_A</span>
|
||||
and<span style="font-family: monospace; font-weight: bold;"> _As</span>),
|
||||
e.g.<br>
|
||||
<pre style="margin-left: 40px;">q.oneSolution().get("N")<br></pre>
|
||||
returns a <span style="font-weight: bold;">jpl.Integer</span>
|
||||
representing the Prolog integer value to which <span
|
||||
style="font-family: monospace;">N</span> was bound by the successful
|
||||
call of the query.<br>
|
||||
</blockquote>
|
||||
<h3>Java API: deprecated methods<br>
|
||||
</h3>
|
||||
<ul>
|
||||
<li><span style="font-weight: bold;">Query</span>.query()</li>
|
||||
</ul>
|
||||
<div style="margin-left: 80px;">use <span style="font-weight: bold;">Query</span>.hasSolution()
|
||||
instead<br>
|
||||
</div>
|
||||
<ul>
|
||||
<li><span style="font-weight: bold;">Query</span>.rewind()</li>
|
||||
</ul>
|
||||
<div style="margin-left: 80px;">use <span style="font-weight: bold;">Query</span>.close()
|
||||
instead<br>
|
||||
</div>
|
||||
<h3>Java API: fixes</h3>
|
||||
<div style="margin-left: 40px;">array methods inherited from <span
|
||||
style="font-weight: bold;">java.lang.Object</span> are now callable,
|
||||
e.g.<br>
|
||||
</div>
|
||||
<ul>
|
||||
<ul>
|
||||
<pre>jpl_new(array(int), [4,5,6], A),<br>jpl_call(A, hashCode, [], H).</pre>
|
||||
</ul>
|
||||
</ul>
|
||||
<i></i>
|
||||
<h3>Java API: planned or under consideration<br>
|
||||
</h3>
|
||||
<ul>
|
||||
<li>drop <span style="font-weight: bold;">Term.display()</span>,
|
||||
which cutely displays any <span style="font-weight: bold;">Term</span>
|
||||
in a Swing tree view in a new window.</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>support non-virtual method calls, e.g. by</li>
|
||||
</ul>
|
||||
<pre style="margin-left: 80px;">jpl_call(+Obj, +Class:Method, +Args, -Result)<br></pre>
|
||||
<ul>
|
||||
<li>finish the current tidy-up<br>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>passing (or returning) Prolog terms to Java by reference; we
|
||||
might stash them in Prolog's <span style="font-style: italic;">recorded
|
||||
database</span> (see <span style="font-weight: bold;">PL_record</span>
|
||||
in the SWI-Prolog Reference Manual), and return an instance of some
|
||||
yet-to-be-designed JPL class which erases the recorded term when the
|
||||
referring object is garbage-collected<br>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>convenience constructs in Prolog akin to import in Java, allowing
|
||||
us to write e.g.</li>
|
||||
</ul>
|
||||
<pre style="margin-left: 80px;">jpl_new('Timestamp', X, R)<br></pre>
|
||||
<div style="margin-left: 40px;">when we mean</div>
|
||||
<pre style="margin-left: 80px;">jpl_new('javax.sql.Timestamp', X, R)</pre>
|
||||
<ul>
|
||||
<li>renaming the package <span
|
||||
style="font-family: monospace; font-weight: bold;">jpl</span> more
|
||||
globally: unfortunately, <span
|
||||
style="font-family: monospace; font-weight: bold;">org.jpl</span> has
|
||||
already been taken :-)</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>ditching <span style="font-weight: bold;">jpl.Util</span> and
|
||||
moving its (static, utility) methods into <span
|
||||
style="font-weight: bold;">jpl.JPL</span></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>deprecate all <span style="font-family: monospace;">.args()</span>,
|
||||
<span style="font-family: monospace;">.arg0()</span>, <span
|
||||
style="font-family: monospace;">.arg1()</span> methods and replace with</li>
|
||||
</ul>
|
||||
<pre style="margin-left: 80px;">public final Term[] args;<br></pre>
|
||||
<ul>
|
||||
<li>require any <span style="font-weight: bold;">Variable</span>'s
|
||||
name to conform to Prolog source syntax, so that valid source texts can
|
||||
be reconstructed from <span style="font-weight: bold;">Term</span>
|
||||
instances by the <span style="font-family: monospace;">toString()</span>
|
||||
methods</li>
|
||||
</ul>
|
||||
<address><a href="mailto:paul.singleton@bcs.org.uk">Paul Singleton</a></address>
|
||||
<address>Wednesday 4th February 2004<br>
|
||||
<br>
|
||||
</address>
|
||||
<hr style="width: 100%; height: 4px;">
|
||||
<h2><span style="font-style: italic;"><a name="JPL_2.0.2_Java_API"></a>JPL
|
||||
2.0.2</span> Release Notes</h2>
|
||||
<h3>Java API: canonical representation of terms</h3>
|
||||
<blockquote>
|
||||
<h3>rationale</h3>
|
||||
"<b>List</b>" and "<b>Tuple</b>" terms are not recognised as distinct
|
||||
types
|
||||
by the Prolog engine: they are just conventions: it doesn't follow that
|
||||
every <tt><font size="+1">./2</font></tt> or <tt><font size="+1">[]/0</font></tt>
|
||||
should be represented externally as instances of <b>List</b> or <b>Nil</b>,
|
||||
nor that <tt><font size="+1">{}/2</font></tt> should be represented as
|
||||
<b>Tuple</b>.
|
||||
There are many other informal types, and it's not clear which of them
|
||||
deserve
|
||||
the same treatment. The simplest policy is to provide special
|
||||
support
|
||||
for none of them, and this is what <b><i>JPL 2.x.x</i></b> does.
|
||||
This also ensures that there is only one valid representation of a
|
||||
Prolog
|
||||
term as <b><i>JPL</i></b> class instances (otherwise we would have to
|
||||
be
|
||||
careful to recognise every <b>Atom</b> whose name is "[]" as being
|
||||
equivalent
|
||||
to an instance of <b>Nil</b>).</blockquote>
|
||||
<ul>
|
||||
<li>these classes have been dropped (sorry, not deprecated: they
|
||||
don't fit
|
||||
into the new scheme)</li>
|
||||
<ul>
|
||||
<li> <b>Tuple</b> (see above)</li>
|
||||
<li> <b>List</b> (see above)</li>
|
||||
<li> <b>Nil</b> (see above)</li>
|
||||
<li> <b>String</b> (these are obsolete and more-or-less deprecated
|
||||
in
|
||||
recent
|
||||
SWI-Prolog releases)</li>
|
||||
<li> <b>Long</b> (this doesn't have a clear role)</li>
|
||||
</ul>
|
||||
<li>the Term class hierarchy has been rearranged thus:</li>
|
||||
<ul>
|
||||
<pre>Term (abstract)<br> |<br> +--- Compound<br> | |<br> | +--- Atom (special case)<br> |<br> +--- Integer<br> |<br> +--- Float<br> |<br> +--- Variable<br><br>Query</pre>
|
||||
</ul>
|
||||
Note that an <b>Atom</b> is a <b>Compound</b> whose arity is
|
||||
zero.
|
||||
It is naughty to construct a <b>Compound</b> with zero arity (this
|
||||
violates
|
||||
canonicity), and <b><i>JPL</i></b> code never does this when exporting
|
||||
terms from Prolog. Application code written in Java, using <b><i>JPL</i></b>,
|
||||
should avoid doing this. Maybe we should raise an exception if it
|
||||
is attempted (maybe we do, I can't remember :-)
|
||||
<p>Note also that, although a <b>Query</b> contains a <b>Term</b>
|
||||
(among
|
||||
other Prolog-related state), it is not related to it by inheritance.</p>
|
||||
</ul>
|
||||
<h3> Java API: lazy initialisation</h3>
|
||||
<blockquote>It is no longer necessary to explicitly initialise <b><i>JPL</i></b>
|
||||
before calling any of the methods which access the Prolog engine.
|
||||
This allows you to develop Java classes which make use of <b><i>JPL</i></b>,
|
||||
and to make them available as "library" classes for use freely in
|
||||
applications,
|
||||
without placing a burden upon the application programmer to explicitly
|
||||
initialise <b><i>JPL</i></b>.
|
||||
<p>Instead, <b><i>JPL</i></b> (and, if necessary, the Prolog engine)
|
||||
is
|
||||
initialised "lazily", at the first attempt to invoke the Prolog
|
||||
engine.
|
||||
At this point, a "default" sequence of initialisation parameters is
|
||||
used:
|
||||
initial values for these are compiled into <b><i>JPL</i></b>, but they
|
||||
can be redefined at any time up until initialisation occurs. </p>
|
||||
<p>It is also possible for Java applications to discover (as a <b>String[]</b>)
|
||||
exactly what sequence of <b><i>JPL</i></b> initialisation parameters
|
||||
were
|
||||
actually used (this call returns null if Prolog is not yet initialised,
|
||||
and can thus be used as a test of this state). </p>
|
||||
<p>If a Java application needs to use Prolog with, say, a larger than
|
||||
normal
|
||||
heap or stack, it should attempt to redefine the default initialisation
|
||||
parameters, and hope that the Prolog engine is not yet initialised (if
|
||||
it is, there's not much it can do about it) (in newer versions of
|
||||
SWI-Prolog
|
||||
it could restart it, but this is rather drastic, might disrupt other
|
||||
activities,
|
||||
and is not yet supported via <b><i>JPL</i></b>). </p>
|
||||
<p>Finally, the <b><i>JPL 1.0.1</i></b> static <tt><font size="+1">jpl.JPL.init()</font></tt>
|
||||
method is still supported, for backwards compatibility. </p>
|
||||
<p>These changes are not only for convenience, and to allow
|
||||
development
|
||||
of easy-to-use library code, but are part of a plan to combine Fred
|
||||
Dushin's
|
||||
Java-calls-Prolog interface with Paul Singleton's Prolog-calls-Java
|
||||
interface,
|
||||
to support hybrid Prolog+Java application programming in which either </p>
|
||||
<ul>
|
||||
<li>the JVM is alive before Prolog is started</li>
|
||||
<li>the Prolog engine is alive before a JVM is started</li>
|
||||
<li>a C or C++ main() starts both of them.</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<h3>Java API: miscellaneous changes<br>
|
||||
</h3>
|
||||
<ul>
|
||||
<li> <i>new constructors:</i></li>
|
||||
<ul>
|
||||
<pre>new jpl.Query( Term t)</pre>
|
||||
</ul>
|
||||
<li> <i>withdrawn constructors:</i></li>
|
||||
<ul>
|
||||
<br>
|
||||
all the multi-argument convenience constructors for <b>Compound</b>
|
||||
etc., since Java 1.1 onwards supports "anonymous arrays" which can
|
||||
(fairly)
|
||||
conveniently be used to create <b>Compound</b>s of any arity, e.g.
|
||||
<pre>new Compound( "pair", new Term[] { new Atom("one"), new Atom("two") } )</pre>
|
||||
</ul>
|
||||
<li> <i>new accessor methods:</i></li>
|
||||
<ul>
|
||||
<pre>String Compound.name()</pre>
|
||||
<pre>int Compound.arity()</pre>
|
||||
</ul>
|
||||
NB an <b>Atom</b> is a special case of a <b>Compound</b>, and
|
||||
inherits
|
||||
its <tt>name()</tt> and an <tt>arity()</tt> accessors <br>
|
||||
<li><i>deprecated accessor methods:</i></li>
|
||||
<ul>
|
||||
<pre>Compound.atom()</pre>
|
||||
</ul>
|
||||
(although Prolog conventionally, and necessarily, returns the
|
||||
"name"
|
||||
of a term's principal functor as an atom, this "name" is really a
|
||||
string,
|
||||
and in Java we can represent it as such; the best Prolog can return is
|
||||
"the atom whose name is the same as the name of this compound", whereas
|
||||
we can simply return the name). <br>
|
||||
<li><i>deprecated method:</i></li>
|
||||
<ul>
|
||||
<pre>jpl.Query.query() <i>is renamed</i> jpl.Query.hasSolution()</pre>
|
||||
</ul>
|
||||
for consistency with oneSolution() and allSolutions()
|
||||
</ul>
|
||||
<h3>Java API: bug fixes</h3>
|
||||
<blockquote>Only one "bug" has been fixed, and this was already flagged
|
||||
by Fred as an issue: it concerns the conversion, from Prolog into <b><i>JPL</i></b>,
|
||||
of terms which contain shared variables (i.e. several instances of the
|
||||
same variable). Transput of any (non-cyclic) term from Prolog
|
||||
into
|
||||
Java and back, using <b><i>JPL</i></b>, should yield a new term which
|
||||
is
|
||||
identical to the original apart from having all new variables (but in a
|
||||
similar pattern of sharing).</blockquote>
|
||||
<br>
|
||||
<address><a href="mailto:p.singleton@keele.ac.uk">Paul Singleton</a></address>
|
||||
<address>
|
||||
drafted Tuesday 20th February 2001<br>
|
||||
revised Thursday 19th April 2001</address>
|
||||
<address><br>
|
||||
<br>
|
||||
</address>
|
||||
</body>
|
||||
</html>
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1,33 +0,0 @@
|
||||
//tabstop=4
|
||||
|
||||
import jpl.Query; // empirically, we need this, but I don't know why...
|
||||
import jpl.fli.Prolog;
|
||||
import jpl.*;
|
||||
|
||||
public class Exceptions
|
||||
{
|
||||
public static void
|
||||
main( java.lang.String argv[] )
|
||||
{
|
||||
// currently, SWI-Prolog's default args are suited to interactive use with an attached console,
|
||||
// not to embedded use like this, so we override them before they are used
|
||||
// (by JPL, when it necessarily initialises Prolog when .hasSolution() is first called)
|
||||
|
||||
Prolog.set_default_init_args(
|
||||
new String[] {
|
||||
"libpl.dll",
|
||||
"-f", "none",
|
||||
"-g", "set_prolog_flag(debug_on_error,false)",
|
||||
"-q"
|
||||
}
|
||||
);
|
||||
|
||||
System.out.print( "calling\n\n");
|
||||
System.out.print( "?- X is Y.\n\n");
|
||||
System.out.print( "in Prolog to force a Prolog 'instantiation_error' exception,\n" );
|
||||
System.out.print( "which should be returned via Java as an uncaught jpl.PrologException in thread \"main\":\n\n" );
|
||||
|
||||
(new Query("X is Y")).hasSolution();
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
compile.bat
|
||||
will compile this demo
|
||||
|
||||
run.bat
|
||||
will run it
|
||||
|
||||
..\README.txt
|
||||
may explain what is happening
|
||||
|
||||
----
|
||||
|
||||
Paul Singleton (paul.singleton@bcs.org.uk)
|
||||
February 2004
|
||||
|
@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
call ..\env.bat
|
||||
|
||||
if not exist Exceptions.class (
|
||||
echo Compiling Exceptions.java
|
||||
javac Exceptions.java
|
||||
)
|
||||
|
||||
java Exceptions
|
||||
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../env.sh
|
||||
|
||||
run Exceptions
|
||||
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1,34 +0,0 @@
|
||||
//tabstop=4
|
||||
|
||||
import jpl.fli.Prolog;
|
||||
import jpl.*;
|
||||
|
||||
public class Exceptions2
|
||||
{
|
||||
public static void
|
||||
main( java.lang.String argv[] )
|
||||
{
|
||||
|
||||
Prolog.set_default_init_args(
|
||||
new String[] {
|
||||
"libpl.dll",
|
||||
"-f", "none",
|
||||
"-g", "set_prolog_flag(debug_on_error,false)",
|
||||
"-q"
|
||||
}
|
||||
);
|
||||
|
||||
System.out.print( "Calling\n\n");
|
||||
System.out.print( "?- X is Y.\n\n");
|
||||
System.out.print( "in Prolog to force an 'instantiation_error' exception,\n" );
|
||||
System.out.print( "whose getMessage() will be println-ed to System.out.\n\n" );
|
||||
|
||||
try {
|
||||
(new Query("X is Y")).hasSolution();
|
||||
} catch (jpl.PrologException e) {
|
||||
System.out.println( e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
compile.bat
|
||||
will compile this demo
|
||||
|
||||
run.bat
|
||||
will run it
|
||||
|
||||
..\README.txt
|
||||
may explain what is happening
|
||||
|
||||
----
|
||||
|
||||
Paul Singleton (paul.singleton@bcs.org.uk)
|
||||
February 2004
|
||||
|
@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
call ..\env.bat
|
||||
|
||||
if not exist Exceptions2.class (
|
||||
echo Compiling Exceptions2.java
|
||||
javac Exceptions2.java
|
||||
)
|
||||
|
||||
java Exceptions2
|
||||
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../env.sh
|
||||
|
||||
run Exceptions2
|
||||
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1,70 +0,0 @@
|
||||
import java.util.Hashtable;
|
||||
import jpl.*;
|
||||
import jpl.Query;
|
||||
|
||||
public class Family
|
||||
{
|
||||
public static void
|
||||
main( String argv[] )
|
||||
{
|
||||
|
||||
String t1 = "consult('family.pl')";
|
||||
Query q1 = new Query(t1);
|
||||
|
||||
System.out.println( t1 + " " + (q1.hasSolution() ? "succeeded" : "failed") );
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
String t2 = "child_of(joe, ralf)";
|
||||
Query q2 = new Query(t2);
|
||||
|
||||
System.out.println( t2 + " is " + (q2.hasSolution() ? "provable" : "not provable") );
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
String t3 = "descendent_of(steve, ralf)";
|
||||
Query q3 = new Query(t3);
|
||||
|
||||
System.out.println( t3 + " is " +(q3.hasSolution() ? "provable" : "not provable") );
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
String t4 = "descendent_of(X, ralf)";
|
||||
Query q4 = new Query(t4);
|
||||
|
||||
System.out.println( "first solution of " + t4 + ": X = " + q4.oneSolution().get("X"));
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
java.util.Hashtable[] ss4 = q4.allSolutions();
|
||||
|
||||
System.out.println( "all solutions of " + t4);
|
||||
for ( int i=0 ; i<ss4.length ; i++ ) {
|
||||
System.out.println( "X = " + ss4[i].get("X"));
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
System.out.println( "each solution of " + t4);
|
||||
while ( q4.hasMoreSolutions() ){
|
||||
java.util.Hashtable s4 = q4.nextSolution();
|
||||
System.out.println( "X = " + s4.get("X"));
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
String t5 = "descendent_of(X,Y)";
|
||||
Query q5 = new Query(t5);
|
||||
|
||||
System.out.println( "each solution of " + t5 );
|
||||
while ( q5.hasMoreSolutions() ){
|
||||
java.util.Hashtable s5 = q5.nextSolution();
|
||||
System.out.println( "X = " + s5.get("X") + ", Y = " + s5.get("Y"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
compile.bat
|
||||
will compile this demo
|
||||
|
||||
run.bat
|
||||
will run it
|
||||
|
||||
..\README.txt
|
||||
may explain what is happening
|
||||
|
||||
----
|
||||
|
||||
Paul Singleton (paul.singleton@bcs.org.uk)
|
||||
February 2004
|
||||
|
@ -1,12 +0,0 @@
|
||||
% a simple database for Family.java
|
||||
|
||||
child_of(joe, ralf).
|
||||
child_of(mary, joe).
|
||||
child_of(steve, joe).
|
||||
|
||||
descendent_of(X, Y) :-
|
||||
child_of(X, Y).
|
||||
descendent_of(X, Y) :-
|
||||
child_of(Z, Y),
|
||||
descendent_of(X, Z).
|
||||
|
@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
call ..\env.bat
|
||||
|
||||
if not exist Family.class (
|
||||
echo Compiling Family.java
|
||||
javac Family.java
|
||||
)
|
||||
|
||||
java Family
|
||||
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../env.sh
|
||||
|
||||
run Family
|
||||
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1,95 +0,0 @@
|
||||
import jpl.*;
|
||||
|
||||
public class FamilyMT extends Thread {
|
||||
|
||||
int id; // client thread id
|
||||
private static final int delay = 0;
|
||||
private static final Term delayGoal = new Compound("sleep", new Term[] { new jpl.Integer(delay)});
|
||||
|
||||
FamilyMT(int i) {
|
||||
this.id = i;
|
||||
}
|
||||
|
||||
public static void delay() {
|
||||
new Query(delayGoal).hasSolution();
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
Query q1 = new Query("consult(family)");
|
||||
System.err.println("consult " + (q1.hasSolution() ? "succeeded" : "failed"));
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
System.out.println("spawning client[" + i + "]");
|
||||
new FamilyMT(i).start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
java.util.Hashtable solution;
|
||||
Variable X = new Variable("X");
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
Query q2 = new Query("child_of(joe,ralf)");
|
||||
|
||||
System.err.println("child_of(joe,ralf) is " + (q2.hasSolution() ? "provable" : "not provable"));
|
||||
|
||||
new Query("sleep(?)", new Term[] {new jpl.Integer(delay)}).hasSolution();
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
Query q3 = new Query("descendent_of(steve,ralf)");
|
||||
|
||||
System.err.println("descendent_of(steve,ralf) is " + (q3.hasSolution() ? "provable" : "not provable"));
|
||||
|
||||
delay();
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
Query q4 = new Query("descendent_of(X, ralf)");
|
||||
|
||||
solution = q4.oneSolution();
|
||||
|
||||
System.err.println("first solution of descendent_of(X, ralf)");
|
||||
System.err.println("X = " + solution.get("X"));
|
||||
|
||||
delay();
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
java.util.Hashtable[] solutions = q4.allSolutions();
|
||||
|
||||
System.err.println("all solutions of descendent_of(X, ralf)");
|
||||
for (int i = 0; i < solutions.length; i++) {
|
||||
System.err.println("X = " + solutions[i].get("X"));
|
||||
}
|
||||
|
||||
delay();
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
System.err.println("each solution of descendent_of(X, ralf)");
|
||||
while (q4.hasMoreSolutions()) {
|
||||
solution = q4.nextSolution();
|
||||
System.err.println("X = " + solution.get("X"));
|
||||
}
|
||||
|
||||
delay();
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
Query q5 = new Query("descendent_of(X, Y)");
|
||||
|
||||
System.err.println(id + ": each solution of descendent_of(X, Y)");
|
||||
while (q5.hasMoreSolutions()) {
|
||||
solution = q5.nextSolution();
|
||||
System.err.println(id + ": X = " + solution.get("X") + ", Y = " + solution.get("Y"));
|
||||
|
||||
delay();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
compile.bat
|
||||
will compile this demo
|
||||
|
||||
run.bat
|
||||
will run it
|
||||
|
||||
..\README.txt
|
||||
may explain what is happening
|
||||
|
||||
----
|
||||
|
||||
Paul Singleton (paul.singleton@bcs.org.uk)
|
||||
February 2004
|
||||
|
@ -1,12 +0,0 @@
|
||||
% a simple database for Family.java
|
||||
|
||||
child_of(joe, ralf).
|
||||
child_of(mary, joe).
|
||||
child_of(steve, joe).
|
||||
|
||||
descendent_of(X, Y) :-
|
||||
child_of(X, Y).
|
||||
descendent_of(X, Y) :-
|
||||
child_of(Z, Y),
|
||||
descendent_of(X, Z).
|
||||
|
@ -1,438 +0,0 @@
|
||||
#
|
||||
# A fatal error has been detected by the Java Runtime Environment:
|
||||
#
|
||||
# SIGSEGV (0xb) at pc=0x000000011560573e, pid=65279, tid=23299
|
||||
#
|
||||
# JRE version: Java(TM) SE Runtime Environment (7.0_45-b18) (build 1.7.0_45-b18)
|
||||
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.45-b08 mixed mode bsd-amd64 compressed oops)
|
||||
# Problematic frame:
|
||||
# C [libYap.6.dylib+0x1873e] Yap_absmi+0x1788e
|
||||
#
|
||||
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
|
||||
#
|
||||
# If you would like to submit a bug report, please visit:
|
||||
# http://bugreport.sun.com/bugreport/crash.jsp
|
||||
# The crash happened outside the Java Virtual Machine in native code.
|
||||
# See problematic frame for where to report the bug.
|
||||
#
|
||||
|
||||
--------------- T H R E A D ---------------
|
||||
|
||||
Current thread (0x00007fddf391c800): JavaThread "Thread-2" [_thread_in_native, id=23299, stack(0x0000000116f0c000,0x000000011700c000)]
|
||||
|
||||
siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x0000000000400600
|
||||
|
||||
Registers:
|
||||
RAX=0x000000011af1ce78, RBX=0x000000011700a5b8, RCX=0x000000011af1cf20, RDX=0x000000011af1cec0
|
||||
RSP=0x000000011700a4f0, RBP=0x000000011700b6e0, RSI=0x000000011700a5b8, RDI=0x0000000000000106
|
||||
R8 =0x000000011af1cf20, R9 =0x000000011a81d110, R10=0x0000000000400600, R11=0xffff8023217cc5b8
|
||||
R12=0x0000000000000000, R13=0x00000006fb0b1be8, R14=0x00007fddf583e000, R15=0x000000011578d7f8
|
||||
RIP=0x000000011560573e, EFLAGS=0x0000000000010216, ERR=0x0000000000000004
|
||||
TRAPNO=0x000000000000000e
|
||||
|
||||
Top of Stack: (sp=0x000000011700a4f0)
|
||||
0x000000011700a4f0: 000000011700b6f0 000000011560fae4
|
||||
0x000000011700a500: 0000000801000000 4ffffffffffffff9
|
||||
0x000000011700a510: 0ffffffffffffff8 fffffffffb0a16a0
|
||||
0x000000011700a520: fffffffe00000000 0000000200000000
|
||||
0x000000011700a530: 0400000000000000 0200000000000000
|
||||
0x000000011700a540: 00000001fb0a16a0 0000800000000000
|
||||
0x000000011700a550: 8000000000000000 00007fddf583e000
|
||||
0x000000011700a560: 0000000801000000 4ffffffffffffff9
|
||||
0x000000011700a570: 0ffffffffffffff8 ffffffff00000000
|
||||
0x000000011700a580: fffffffee8ff5947 0000000200000000
|
||||
0x000000011700a590: 0400000000000000 0200000000000000
|
||||
0x000000011700a5a0: 0000000100000000 4000000000000001
|
||||
0x000000011700a5b0: 0000000100000000 000000000003ffff
|
||||
0x000000011700a5c0: 000000000003ffff 000000011a81d110
|
||||
0x000000011700a5d0: 000000011af1d000 000000011a71d008
|
||||
0x000000011700a5e0: 000000011af1d048 000000011a81d110
|
||||
0x000000011700a5f0: 000000011af1ce78 4ffffffffffffff9
|
||||
0x000000011700a600: 00007fddf38b7078 000000011af1cf20
|
||||
0x000000011700a610: 000000011af1d000 0000000000000000
|
||||
0x000000011700a620: 00007fddf46bd3f8 000000011af1ce78
|
||||
0x000000011700a630: 0000000000000000 000000011af1cec0
|
||||
0x000000011700a640: 000000011af1d000 000000011b11b000
|
||||
0x000000011700a650: 00007fddf583f200 00007fddf584f200
|
||||
0x000000011700a660: 00007fddf584f200 0000000000000000
|
||||
0x000000011700a670: 00007fddf1f324f1 000000011a81d008
|
||||
0x000000011700a680: 000000011af1d000 000000011af1d008
|
||||
0x000000011700a690: 0000000000000000 0000000000000007
|
||||
0x000000011700a6a0: 00007fddf5832800 0000000000000000
|
||||
0x000000011700a6b0: 0000000000000000 00007fddf46bcf61
|
||||
0x000000011700a6c0: 00007fddf46bc6b1 000000011a81d0c8
|
||||
0x000000011700a6d0: 0000000000000000 0000000000000000
|
||||
0x000000011700a6e0: 0000000000000000 0000000000000000
|
||||
|
||||
Instructions: (pc=0x000000011560573e)
|
||||
0x000000011560571e: e8 f3 0f 7f 42 f0 4d 8b 52 08 48 89 42 a0 48 8d
|
||||
0x000000011560572e: 42 b8 48 89 85 10 ef ff ff 48 89 85 48 ef ff ff
|
||||
0x000000011560573e: 41 ff 22 48 8b 85 00 ef ff ff 48 39 85 68 ef ff
|
||||
0x000000011560574e: ff 0f 82 a6 08 00 00 48 8b 8d 08 ef ff ff 48 8b
|
||||
|
||||
Register to memory mapping:
|
||||
|
||||
RAX=0x000000011af1ce78 is an unknown value
|
||||
RBX=0x000000011700a5b8 is pointing into the stack for thread: 0x00007fddf391c800
|
||||
RCX=0x000000011af1cf20 is an unknown value
|
||||
RDX=0x000000011af1cec0 is an unknown value
|
||||
RSP=0x000000011700a4f0 is pointing into the stack for thread: 0x00007fddf391c800
|
||||
RBP=0x000000011700b6e0 is pointing into the stack for thread: 0x00007fddf391c800
|
||||
RSI=0x000000011700a5b8 is pointing into the stack for thread: 0x00007fddf391c800
|
||||
RDI=0x0000000000000106 is an unknown value
|
||||
R8 =0x000000011af1cf20 is an unknown value
|
||||
R9 =0x000000011a81d110 is an unknown value
|
||||
R10=0x0000000000400600 is an unknown value
|
||||
R11=0xffff8023217cc5b8 is an unknown value
|
||||
R12=0x0000000000000000 is an unknown value
|
||||
R13=0x00000006fb0b1be8 is an oop
|
||||
{method}
|
||||
- klass: {other class}
|
||||
R14=0x00007fddf583e000 is an unknown value
|
||||
R15=0x000000011578d7f8: Yap_yaamregs_key+0 in /usr/local/lib/libYap.6.dylib at 0x00000001155ed000
|
||||
|
||||
|
||||
Stack: [0x0000000116f0c000,0x000000011700c000], sp=0x000000011700a4f0, free space=1017k
|
||||
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
|
||||
C [libYap.6.dylib+0x1873e] Yap_absmi+0x1788e
|
||||
C [libYap.6.dylib+0x16197b] YAP_EnterGoal+0x9b
|
||||
C [libYap.6.dylib+0x12118b] PL_next_solution+0x7b
|
||||
C [libjpl.dylib+0x27e0] Java_jpl_fli_Prolog_next_1solution+0x50
|
||||
j jpl.fli.Prolog.next_solution(Ljpl/fli/qid_t;)Z+0
|
||||
j jpl.Query.get1()Z+4
|
||||
j jpl.Query.hasMoreSolutions()Z+12
|
||||
j jpl.Query.oneSolution()Ljava/util/Hashtable;+18
|
||||
j jpl.Query.hasSolution()Z+1
|
||||
j FamilyMT.run()V+114
|
||||
v ~StubRoutines::call_stub
|
||||
V [libjvm.dylib+0x2d6d90] JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*)+0x22a
|
||||
V [libjvm.dylib+0x2d72a7] JavaCalls::call_virtual(JavaValue*, KlassHandle, Symbol*, Symbol*, JavaCallArguments*, Thread*)+0x11b
|
||||
V [libjvm.dylib+0x2d73e4] JavaCalls::call_virtual(JavaValue*, Handle, KlassHandle, Symbol*, Symbol*, Thread*)+0x4a
|
||||
V [libjvm.dylib+0x3263ca] thread_entry(JavaThread*, Thread*)+0xad
|
||||
V [libjvm.dylib+0x4efb47] JavaThread::thread_main_inner()+0x9b
|
||||
V [libjvm.dylib+0x4f124f] JavaThread::run()+0x1a3
|
||||
V [libjvm.dylib+0x41b1c6] java_start(Thread*)+0x126
|
||||
C [libsystem_pthread.dylib+0x1899] _pthread_body+0x8a
|
||||
C [libsystem_pthread.dylib+0x172a] _pthread_struct_init+0x0
|
||||
C [libsystem_pthread.dylib+0x5fc9] thread_start+0xd
|
||||
|
||||
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
|
||||
j jpl.fli.Prolog.next_solution(Ljpl/fli/qid_t;)Z+0
|
||||
j jpl.Query.get1()Z+4
|
||||
j jpl.Query.hasMoreSolutions()Z+12
|
||||
j jpl.Query.oneSolution()Ljava/util/Hashtable;+18
|
||||
j jpl.Query.hasSolution()Z+1
|
||||
j FamilyMT.run()V+114
|
||||
v ~StubRoutines::call_stub
|
||||
|
||||
--------------- P R O C E S S ---------------
|
||||
|
||||
Java Threads: ( => current thread )
|
||||
0x00007fddf6001800 JavaThread "DestroyJavaVM" [_thread_blocked, id=3335, stack(0x0000000103ef9000,0x0000000103ff9000)]
|
||||
0x00007fddf3059000 JavaThread "Thread-19" [_thread_in_native, id=32003, stack(0x000000011d03f000,0x000000011d13f000)]
|
||||
0x00007fddf20db800 JavaThread "Thread-18" [_thread_in_native, id=31491, stack(0x000000011cf3c000,0x000000011d03c000)]
|
||||
0x00007fddf5002000 JavaThread "Thread-17" [_thread_in_native, id=30979, stack(0x000000011ce39000,0x000000011cf39000)]
|
||||
0x00007fddf3058800 JavaThread "Thread-16" [_thread_in_native, id=30467, stack(0x000000011cd36000,0x000000011ce36000)]
|
||||
0x00007fddf6001000 JavaThread "Thread-15" [_thread_in_native, id=29955, stack(0x000000011cc33000,0x000000011cd33000)]
|
||||
0x00007fddf3920800 JavaThread "Thread-14" [_thread_in_native, id=29443, stack(0x000000011cb30000,0x000000011cc30000)]
|
||||
0x00007fddf4821000 JavaThread "Thread-13" [_thread_in_native, id=28931, stack(0x000000011ca2d000,0x000000011cb2d000)]
|
||||
0x00007fddf391f800 JavaThread "Thread-12" [_thread_in_native, id=28419, stack(0x000000011c92a000,0x000000011ca2a000)]
|
||||
0x00007fddf3057800 JavaThread "Thread-11" [_thread_in_native, id=27907, stack(0x000000011c827000,0x000000011c927000)]
|
||||
0x00007fddf284b800 JavaThread "Thread-10" [_thread_in_native, id=27395, stack(0x000000011c724000,0x000000011c824000)]
|
||||
0x00007fddf3057000 JavaThread "Thread-9" [_thread_in_native, id=26883, stack(0x000000011bc21000,0x000000011bd21000)]
|
||||
0x00007fddf6000000 JavaThread "Thread-8" [_thread_in_Java, id=26371, stack(0x000000011b11e000,0x000000011b21e000)]
|
||||
0x00007fddf4820800 JavaThread "Thread-7" [_thread_in_vm, id=25859, stack(0x000000011a61b000,0x000000011a71b000)]
|
||||
0x00007fddf481f800 JavaThread "Thread-6" [_thread_in_native, id=25347, stack(0x0000000119b18000,0x0000000119c18000)]
|
||||
0x00007fddf391f000 JavaThread "Thread-5" [_thread_in_native, id=24835, stack(0x0000000119015000,0x0000000119115000)]
|
||||
0x00007fddf391e000 JavaThread "Thread-4" [_thread_in_Java, id=24323, stack(0x0000000118512000,0x0000000118612000)]
|
||||
0x00007fddf391d800 JavaThread "Thread-3" [_thread_in_native, id=23811, stack(0x0000000117a0f000,0x0000000117b0f000)]
|
||||
=>0x00007fddf391c800 JavaThread "Thread-2" [_thread_in_native, id=23299, stack(0x0000000116f0c000,0x000000011700c000)]
|
||||
0x00007fddf391c000 JavaThread "Thread-1" [_thread_in_native, id=22787, stack(0x0000000116407000,0x0000000116507000)]
|
||||
0x00007fddf38a3800 JavaThread "Thread-0" [_thread_in_native, id=22275, stack(0x0000000116304000,0x0000000116404000)]
|
||||
0x00007fddf3847800 JavaThread "Service Thread" daemon [_thread_blocked, id=21251, stack(0x00000001152c1000,0x00000001153c1000)]
|
||||
0x00007fddf302e000 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=20739, stack(0x00000001151be000,0x00000001152be000)]
|
||||
0x00007fddf302c800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=20227, stack(0x00000001150bb000,0x00000001151bb000)]
|
||||
0x00007fddf301d000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=19715, stack(0x0000000114fb8000,0x00000001150b8000)]
|
||||
0x00007fddf4802000 JavaThread "Finalizer" daemon [_thread_blocked, id=14595, stack(0x0000000114d69000,0x0000000114e69000)]
|
||||
0x00007fddf2802000 JavaThread "Reference Handler" daemon [_thread_blocked, id=14083, stack(0x0000000114c66000,0x0000000114d66000)]
|
||||
|
||||
Other Threads:
|
||||
0x00007fddf383e800 VMThread [stack: 0x0000000114b63000,0x0000000114c63000] [id=13571]
|
||||
0x00007fddf386a000 WatcherThread [stack: 0x00000001153c4000,0x00000001154c4000] [id=21763]
|
||||
|
||||
VM state:not at safepoint (normal execution)
|
||||
|
||||
VM Mutex/Monitor currently owned by a thread: None
|
||||
|
||||
Heap
|
||||
PSYoungGen total 76800K, used 29064K [0x00000007aaa80000, 0x00000007b0000000, 0x0000000800000000)
|
||||
eden space 66048K, 44% used [0x00000007aaa80000,0x00000007ac6e2310,0x00000007aeb00000)
|
||||
from space 10752K, 0% used [0x00000007af580000,0x00000007af580000,0x00000007b0000000)
|
||||
to space 10752K, 0% used [0x00000007aeb00000,0x00000007aeb00000,0x00000007af580000)
|
||||
ParOldGen total 174592K, used 0K [0x0000000700000000, 0x000000070aa80000, 0x00000007aaa80000)
|
||||
object space 174592K, 0% used [0x0000000700000000,0x0000000700000000,0x000000070aa80000)
|
||||
PSPermGen total 21504K, used 2803K [0x00000006fae00000, 0x00000006fc300000, 0x0000000700000000)
|
||||
object space 21504K, 13% used [0x00000006fae00000,0x00000006fb0bcfe8,0x00000006fc300000)
|
||||
|
||||
Card table byte_map: [0x0000000108b61000,0x000000010938b000] byte_map_base: 0x000000010538a000
|
||||
|
||||
Polling page: 0x0000000103ffb000
|
||||
|
||||
Code Cache [0x0000000105aa1000, 0x0000000105d11000, 0x0000000108aa1000)
|
||||
total_blobs=188 nmethods=4 adapters=139 free_code_cache=48763Kb largest_free_block=49916480
|
||||
|
||||
Compilation events (6 events):
|
||||
Event: 0.067 Thread 0x00007fddf302c800 1 java.lang.String::indexOf (70 bytes)
|
||||
Event: 0.068 Thread 0x00007fddf302e000 2 java.lang.String::hashCode (55 bytes)
|
||||
Event: 0.073 Thread 0x00007fddf302c800 nmethod 1 0x0000000105b061d0 code [0x0000000105b06320, 0x0000000105b064c8]
|
||||
Event: 0.073 Thread 0x00007fddf302e000 nmethod 2 0x0000000105b02a50 code [0x0000000105b02ba0, 0x0000000105b02d18]
|
||||
Event: 0.082 Thread 0x00007fddf302c800 3 sun.nio.cs.UTF_8$Encoder::encode (361 bytes)
|
||||
Event: 0.087 Thread 0x00007fddf302c800 nmethod 3 0x0000000105b00350 code [0x0000000105b004c0, 0x0000000105b009e8]
|
||||
|
||||
GC Heap History (0 events):
|
||||
No events
|
||||
|
||||
Deoptimization events (0 events):
|
||||
No events
|
||||
|
||||
Internal exceptions (10 events):
|
||||
Event: 0.092 Thread 0x00007fddf3001800 Threw 0x00000007aab8f610 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u45/229/hotspot/src/share/vm/prims/jvm.cpp:1244
|
||||
Event: 0.092 Thread 0x00007fddf3001800 Threw 0x00000007aab92458 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u45/229/hotspot/src/share/vm/prims/jvm.cpp:1244
|
||||
Event: 0.092 Thread 0x00007fddf3001800 Threw 0x00000007aab950d8 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u45/229/hotspot/src/share/vm/prims/jvm.cpp:1244
|
||||
Event: 0.093 Thread 0x00007fddf3001800 Threw 0x00000007aab97dc0 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u45/229/hotspot/src/share/vm/prims/jvm.cpp:1244
|
||||
Event: 0.093 Thread 0x00007fddf3001800 Threw 0x00000007aab9ab08 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u45/229/hotspot/src/share/vm/prims/jvm.cpp:1244
|
||||
Event: 0.093 Thread 0x00007fddf3001800 Threw 0x00000007aab9da20 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u45/229/hotspot/src/share/vm/prims/jvm.cpp:1244
|
||||
Event: 0.094 Thread 0x00007fddf3001800 Threw 0x00000007aaba0960 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u45/229/hotspot/src/share/vm/prims/jvm.cpp:1244
|
||||
Event: 0.094 Thread 0x00007fddf3001800 Threw 0x00000007aaba38c8 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u45/229/hotspot/src/share/vm/prims/jvm.cpp:1244
|
||||
Event: 0.095 Thread 0x00007fddf3001800 Threw 0x00000007aaba68b0 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u45/229/hotspot/src/share/vm/prims/jvm.cpp:1244
|
||||
Event: 0.095 Thread 0x00007fddf3001800 Threw 0x00000007aaba9858 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u45/229/hotspot/src/share/vm/prims/jvm.cpp:1244
|
||||
|
||||
Events (10 events):
|
||||
Event: 0.124 Thread 0x00007fddf4820800 Thread added: 0x00007fddf4820800
|
||||
Event: 0.125 Thread 0x00007fddf6000000 Thread added: 0x00007fddf6000000
|
||||
Event: 0.125 Thread 0x00007fddf3057000 Thread added: 0x00007fddf3057000
|
||||
Event: 0.125 Thread 0x00007fddf284b800 Thread added: 0x00007fddf284b800
|
||||
Event: 0.125 Thread 0x00007fddf3057800 Thread added: 0x00007fddf3057800
|
||||
Event: 0.125 Thread 0x00007fddf391f800 Thread added: 0x00007fddf391f800
|
||||
Event: 0.125 Thread 0x00007fddf4821000 Thread added: 0x00007fddf4821000
|
||||
Event: 0.125 Thread 0x00007fddf3920800 Thread added: 0x00007fddf3920800
|
||||
Event: 0.126 Thread 0x00007fddf6001000 Thread added: 0x00007fddf6001000
|
||||
Event: 0.126 Thread 0x00007fddf3058800 Thread added: 0x00007fddf3058800
|
||||
|
||||
|
||||
Dynamic libraries:
|
||||
0x000000000301a000 /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
|
||||
0x000000000301a000 /System/Library/Frameworks/Security.framework/Versions/A/Security
|
||||
0x000000000301a000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
|
||||
0x000000000301a000 /usr/lib/libz.1.dylib
|
||||
0x000000000301a000 /usr/lib/libSystem.B.dylib
|
||||
0x000000000301a000 /usr/lib/libobjc.A.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
|
||||
0x000000000301a000 /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
|
||||
0x000000000301a000 /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/RemoteViewServices.framework/Versions/A/RemoteViewServices
|
||||
0x000000000301a000 /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
|
||||
0x000000000301a000 /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
|
||||
0x000000000301a000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
|
||||
0x000000000301a000 /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
|
||||
0x000000000301a000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
|
||||
0x000000000301a000 /usr/lib/libauto.dylib
|
||||
0x000000000301a000 /usr/lib/libicucore.A.dylib
|
||||
0x000000000301a000 /usr/lib/libxml2.2.dylib
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
|
||||
0x000000000301a000 /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
|
||||
0x000000000301a000 /usr/lib/liblangid.dylib
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
|
||||
0x000000000301a000 /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
|
||||
0x000000000301a000 /usr/lib/libDiagnosticMessagesClient.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/PerformanceAnalysis
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage
|
||||
0x000000000301a000 /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/Sharing.framework/Versions/A/Sharing
|
||||
0x000000000301a000 /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/Backup.framework/Versions/A/Backup
|
||||
0x000000000301a000 /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
|
||||
0x000000000301a000 /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
|
||||
0x000000000301a000 /usr/lib/libCRFSuite.dylib
|
||||
0x000000000301a000 /usr/lib/libc++.1.dylib
|
||||
0x000000000301a000 /usr/lib/libc++abi.dylib
|
||||
0x000000000301a000 /usr/lib/system/libcache.dylib
|
||||
0x000000000301a000 /usr/lib/system/libcommonCrypto.dylib
|
||||
0x000000000301a000 /usr/lib/system/libcompiler_rt.dylib
|
||||
0x000000000301a000 /usr/lib/system/libcopyfile.dylib
|
||||
0x000000000301a000 /usr/lib/system/libcorecrypto.dylib
|
||||
0x000000000301a000 /usr/lib/system/libdispatch.dylib
|
||||
0x000000000301a000 /usr/lib/system/libdyld.dylib
|
||||
0x000000000301a000 /usr/lib/system/libkeymgr.dylib
|
||||
0x000000000301a000 /usr/lib/system/liblaunch.dylib
|
||||
0x000000000301a000 /usr/lib/system/libmacho.dylib
|
||||
0x000000000301a000 /usr/lib/system/libquarantine.dylib
|
||||
0x000000000301a000 /usr/lib/system/libremovefile.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_asl.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_blocks.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_c.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_configuration.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_dnssd.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_info.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_kernel.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_m.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_malloc.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_network.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_notify.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_platform.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_pthread.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_sandbox.dylib
|
||||
0x000000000301a000 /usr/lib/system/libsystem_stats.dylib
|
||||
0x000000000301a000 /usr/lib/system/libunc.dylib
|
||||
0x000000000301a000 /usr/lib/system/libunwind.dylib
|
||||
0x000000000301a000 /usr/lib/system/libxpc.dylib
|
||||
0x000000000301a000 /usr/lib/libbsm.0.dylib
|
||||
0x000000000301a000 /usr/lib/libsqlite3.dylib
|
||||
0x000000000301a000 /usr/lib/libxar.1.dylib
|
||||
0x000000000301a000 /usr/lib/libpam.2.dylib
|
||||
0x000000000301a000 /usr/lib/libOpenScriptingUtil.dylib
|
||||
0x000000000301a000 /usr/lib/libbz2.1.0.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
|
||||
0x000000000301a000 /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
|
||||
0x000000000301a000 /usr/lib/system/libkxld.dylib
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
|
||||
0x000000000301a000 /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
|
||||
0x000000000301a000 /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
|
||||
0x000000000301a000 /usr/lib/libxslt.1.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
|
||||
0x000000000301a000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
|
||||
0x000000000301a000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
|
||||
0x000000000301a000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
|
||||
0x000000000301a000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
|
||||
0x000000000301a000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
|
||||
0x000000000301a000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
|
||||
0x000000000301a000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
|
||||
0x000000000301a000 /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
|
||||
0x000000000301a000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
|
||||
0x000000000301a000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
|
||||
0x000000000301a000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
|
||||
0x000000000301a000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
|
||||
0x000000000301a000 /usr/lib/libcups.2.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
|
||||
0x000000000301a000 /System/Library/Frameworks/GSS.framework/Versions/A/GSS
|
||||
0x000000000301a000 /usr/lib/libresolv.9.dylib
|
||||
0x000000000301a000 /usr/lib/libiconv.2.dylib
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
|
||||
0x000000000301a000 /usr/lib/libheimdal-asn1.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth
|
||||
0x000000000301a000 /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/Bom.framework/Versions/A/Bom
|
||||
0x000000000301a000 /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
|
||||
0x000000000301a000 /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/CoreImage.framework/Versions/A/CoreImage
|
||||
0x000000000301a000 /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/ScalableUserInterface.framework/Versions/A/ScalableUserInterface
|
||||
0x000000000301a000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCVMSPluginSupport.dylib
|
||||
0x000000000301a000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/FaceCore.framework/Versions/A/FaceCore
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport
|
||||
0x000000000301a000 /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/AppleFSCompression.framework/Versions/A/AppleFSCompression
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/Ubiquity.framework/Versions/A/Ubiquity
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/IconServices.framework/Versions/A/IconServices
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/Symbolication.framework/Versions/A/Symbolication
|
||||
0x000000000301a000 /System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols
|
||||
0x0000000105000000 /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre/lib/server/libjvm.dylib
|
||||
0x000000000301a000 /usr/lib/libstdc++.6.dylib
|
||||
0x0000000105a53000 /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre/lib/libverify.dylib
|
||||
0x0000000105a60000 /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre/lib/libjava.dylib
|
||||
0x0000000105a98000 /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre/lib/libzip.dylib
|
||||
0x0000000114e6b000 /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport
|
||||
0x0000000114e83000 /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Versions/A/JavaNativeFoundation
|
||||
0x0000000114e98000 /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM
|
||||
0x000000000301a000 /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
|
||||
0x0000000114ea5000 /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching
|
||||
0x000000000301a000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
|
||||
0x000000000301a000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
|
||||
0x000000000301a000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
|
||||
0x000000000301a000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
|
||||
0x000000000301a000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
|
||||
0x000000000301a000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
|
||||
0x000000011552a000 /usr/local/lib/Yap/libjpl.dylib
|
||||
0x0000000115543000 /usr/local/opt/readline/lib/libreadline.6.dylib
|
||||
0x000000000301a000 /usr/lib/libncurses.5.4.dylib
|
||||
0x000000011557a000 /usr/local/lib/libgmp.10.dylib
|
||||
0x00000001155ed000 /usr/local/lib/libYap.6.dylib
|
||||
|
||||
VM Arguments:
|
||||
jvm_args: -Djava.library.path=/usr/local/lib/Yap
|
||||
java_command: FamilyMT
|
||||
Launcher Type: SUN_STANDARD
|
||||
|
||||
Environment Variables:
|
||||
CLASSPATH=.:/usr/local/share/Yap/jpl/jpl.jar
|
||||
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin
|
||||
LD_LIBRARY_PATH=/usr/local/lib/Yap
|
||||
SHELL=/bin/bash
|
||||
DISPLAY=/tmp/launch-Js9YCZ/org.macosforge.xquartz:0
|
||||
DYLD_FALLBACK_LIBRARY_PATH=/usr/X11/lib:/usr/lib::
|
||||
|
||||
Signal Handlers:
|
||||
SIGSEGV: [libjvm.dylib+0x525415], sa_mask[0]=0xfffefeff, sa_flags=0x00000043
|
||||
SIGBUS: [libjvm.dylib+0x525415], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
|
||||
SIGFPE: [libjvm.dylib+0x41891a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
|
||||
SIGPIPE: [libjvm.dylib+0x41891a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
|
||||
SIGXFSZ: [libjvm.dylib+0x41891a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
|
||||
SIGILL: [libjvm.dylib+0x41891a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
|
||||
SIGUSR1: SIG_DFL, sa_mask[0]=0x63807efb, sa_flags=0x00000000
|
||||
SIGUSR2: [libjvm.dylib+0x41840c], sa_mask[0]=0x00000000, sa_flags=0x00000042
|
||||
SIGHUP: [libjvm.dylib+0x41669b], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
|
||||
SIGINT: [libjvm.dylib+0x41669b], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
|
||||
SIGTERM: [libjvm.dylib+0x41669b], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
|
||||
SIGQUIT: [libjvm.dylib+0x41669b], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
|
||||
|
||||
|
||||
--------------- S Y S T E M ---------------
|
||||
|
||||
OS:Bsduname:Darwin 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
|
||||
rlimit: STACK 8192k, CORE 0k, NPROC 709, NOFILE 10240, AS infinity
|
||||
load average:1.09 1.27 1.38
|
||||
|
||||
CPU:total 8 (4 cores per cpu, 2 threads per core) family 6 model 58 stepping 9, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, aes, erms, ht, tsc, tscinvbit, tscinv
|
||||
|
||||
Memory: 4k page, physical 16777216k(4194304k free)
|
||||
|
||||
/proc/meminfo:
|
||||
|
||||
|
||||
vm_info: Java HotSpot(TM) 64-Bit Server VM (24.45-b08) for bsd-amd64 JRE (1.7.0_45-b18), built on Oct 8 2013 05:54:16 by "java_re" with gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
|
||||
|
||||
time: Mon Oct 13 07:11:42 2014
|
||||
elapsed time: 0 seconds
|
||||
|
@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
call ..\env.bat
|
||||
|
||||
if not exist FamilyMT.class (
|
||||
echo Compiling FamilyMT.java
|
||||
javac FamilyMT.java
|
||||
)
|
||||
|
||||
java FamilyMT
|
||||
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../env.sh
|
||||
|
||||
run FamilyMT
|
||||
|
@ -1,65 +0,0 @@
|
||||
JPL 3.0.0 for Windows
|
||||
=====================
|
||||
|
||||
Tests for the Java-calls-Prolog interface:
|
||||
------------------------------------------
|
||||
|
||||
This directory contains various rudimentary tests for JPL3's
|
||||
Java-calls-Prolog interface, each within a separate folder.
|
||||
|
||||
Exceptions
|
||||
demonstrates how an uncaught Prolog exception is turned
|
||||
into a Java exception (also uncaught, in this example)
|
||||
|
||||
Exceptions2
|
||||
demonstrates how an uncaught Prolog exception is turned
|
||||
into a Java exception, which in this example is caught,
|
||||
converted to a String and printed on System.out (and
|
||||
also shown in a Swing treeview gadget)
|
||||
|
||||
Family
|
||||
consults some parent-child relationship clauses (from
|
||||
family.pl) and runs some simple queries
|
||||
|
||||
FamilyMT
|
||||
consults some parent-child relationship clauses (from
|
||||
family.pl) and then sets off twenty threads, each doing the
|
||||
queries of Family (above). As there are only five available
|
||||
Prolog engines by default, the threads sometimes get to wait.
|
||||
|
||||
Test
|
||||
runs a simple set of tests of the High-Level Interface.
|
||||
You should run this test once you have gotten JPL built,
|
||||
or if you are experiencing any problems with the package.
|
||||
|
||||
Test2
|
||||
recursively computes factorial(10) by alternately calling
|
||||
Prolog from Java and Java from Prolog
|
||||
|
||||
Time
|
||||
runs a set of timing experiments, designed to gauge the speed
|
||||
with which terms are exchanged between Java and Prolog
|
||||
|
||||
Versions
|
||||
tries to discover which versions (e.g. 3.0.3-alpha) of each JPL
|
||||
library (i.e. Prolog, C and Java) are installed, and congratulates
|
||||
you if they are the same
|
||||
|
||||
Zahed
|
||||
creates a trivial-in-Prolog-but-horrible-in-JPL1.x query goal
|
||||
and calls it against a trivial Prolog database; this would be much
|
||||
nicer if it used recent facilities for creating queries from
|
||||
Prolog source text fragments
|
||||
|
||||
NB each folder contains a Java application which should be run within
|
||||
its folder so it can find any corresponding .pl (Prolog source) files:
|
||||
Windows users can use 'compile.bat' to (re)compile each demo, and
|
||||
'run.bat' to run it.
|
||||
|
||||
----
|
||||
|
||||
Paul Singleton (paul.singleton@bcs.org.uk)
|
||||
July 2003
|
||||
January 2004 (revised)
|
||||
December 2004 (not revised much apart from this line)
|
||||
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1,36 +0,0 @@
|
||||
Java calling Prolog semweb library
|
||||
----------------------------------
|
||||
|
||||
This demo is a very simple example of loading and using the SWI-Prolog
|
||||
semantic web library for parsing and querying of RDF data. Its main
|
||||
purpose is actually to illustrate and test access from Prolog to foreign
|
||||
resources. This demo uses sgml2pl.so and rdf_db.so, providing the XML
|
||||
parser and RDF database.
|
||||
|
||||
ELF systems (Linux, Solaris and many more)
|
||||
------------------------------------------
|
||||
|
||||
In the current setup libjpl.so contains the Prolog kernel and therefore
|
||||
the extensions must get the PL_* symbols from this library. Java loads
|
||||
shared objects without making their symbols available to other modules.
|
||||
This problem is avoided by preloading libjpl.so as illustrated in the
|
||||
run_preloaded function defined in env.sh. Below is a portable
|
||||
shell-script skeleton to deal with this situation:
|
||||
|
||||
----------------------------------------------------------------
|
||||
#!/bin/sh
|
||||
|
||||
class=SemWeb
|
||||
|
||||
eval `$PL -dump-runtime-variables`
|
||||
JPLSO="$PLBASE/lib/$PLARCH/libjpl.$PLSOEXT"
|
||||
JPLJAR="$PLBASE/lib/jpl.jar"
|
||||
|
||||
if [ -z "$CLASSPATH" ]; then
|
||||
CLASSPATH=".:$JPLJAR";
|
||||
else
|
||||
CLASSPATH=".:$JPLJAR:$CLASSPATH"
|
||||
fi
|
||||
|
||||
env LD_PRELOAD=$JPLSO java $class
|
||||
----------------------------------------------------------------
|
@ -1,28 +0,0 @@
|
||||
import java.util.Hashtable;
|
||||
import jpl.*;
|
||||
import jpl.Query;
|
||||
|
||||
public class SemWeb
|
||||
{ public static void
|
||||
main(String argv[])
|
||||
{ String t1 = "use_module(library('semweb/rdf_db'))";
|
||||
Query q1 = new Query(t1);
|
||||
|
||||
System.out.println( t1 + " " + (q1.hasSolution() ? "succeeded" : "failed") );
|
||||
|
||||
Query ql = new Query("rdf_load('test.rdf')");
|
||||
System.out.println(ql.hasSolution() ? "loaded" : "load failed");
|
||||
|
||||
String t2 = "rdf(S,P,O)";
|
||||
Query q2 = new Query(t2);
|
||||
while ( q2.hasMoreSolutions() )
|
||||
{ java.util.Hashtable s2 = q2.nextSolution();
|
||||
System.out.println("{" + s2.get("S") +
|
||||
", " + s2.get("P") +
|
||||
", " + s2.get("O") + "}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
call ..\env.bat
|
||||
|
||||
if not exist SemWeb.class (
|
||||
echo Compiling SemWeb.java
|
||||
javac SemWeb.java
|
||||
)
|
||||
|
||||
java SemWeb
|
||||
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../env.sh
|
||||
|
||||
run_preloaded SemWeb
|
||||
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- Example from REC-rdf-syntax, non-binary relations -->
|
||||
|
||||
<rdf:RDF
|
||||
xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:n="http://www.nist.gov/units/">
|
||||
<Description about="John_Smith">
|
||||
<n:weight rdf:parseType="Resource">
|
||||
<rdf:value>200</rdf:value>
|
||||
<n:units rdf:resource="http://www.nist.gov/units/Pounds"/>
|
||||
</n:weight>
|
||||
</Description>
|
||||
</rdf:RDF>
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1,14 +0,0 @@
|
||||
compile.bat
|
||||
will compile this demo
|
||||
|
||||
run.bat
|
||||
will run it
|
||||
|
||||
..\README.txt
|
||||
may explain what is happening
|
||||
|
||||
----
|
||||
|
||||
Paul Singleton (paul.singleton@bcs.org.uk)
|
||||
February 2004
|
||||
|
@ -1,588 +0,0 @@
|
||||
//tabstop=4
|
||||
//*****************************************************************************/
|
||||
// Project: jpl
|
||||
//
|
||||
// File: $Id$
|
||||
// Date: $Date$
|
||||
// Author: Fred Dushin <fadushin@syr.edu>
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// -------------------------------------------------------------------------
|
||||
// Copyright (c) 1998 Fred Dushin
|
||||
// All rights reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Library Public License for more details.
|
||||
//*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
import java.util.Hashtable;
|
||||
import jpl.Query; // empirically, we need this, but I don't know why...
|
||||
import jpl.*;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void
|
||||
main( java.lang.String argv[] )
|
||||
{
|
||||
// JPL.init(); // we don't need this with the current JPL (lazy init-on-demand)
|
||||
|
||||
run_tests();
|
||||
}
|
||||
|
||||
static void
|
||||
run_tests()
|
||||
{
|
||||
test_0();
|
||||
test_1();
|
||||
test_2();
|
||||
test_3();
|
||||
test_4();
|
||||
test_5();
|
||||
test_6();
|
||||
test_7();
|
||||
test_8();
|
||||
test_9();
|
||||
test_10();
|
||||
test_11();
|
||||
|
||||
// test_101();
|
||||
}
|
||||
|
||||
static void
|
||||
test_0()
|
||||
{
|
||||
System.out.print( "test 0..." );
|
||||
|
||||
Query query =
|
||||
new Query("consult('test.pl')");
|
||||
|
||||
if ( !query.hasSolution() ){
|
||||
System.out.println( "consult('test.pl') failed" );
|
||||
System.exit( 1 );
|
||||
}
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static Term a =
|
||||
new Atom( "a" );
|
||||
static Term b =
|
||||
new Atom( "b" );
|
||||
static Term f_a =
|
||||
new Compound(
|
||||
"f",
|
||||
new Term[] {a}
|
||||
);
|
||||
static Term pair_a_b =
|
||||
new Compound(
|
||||
"-",
|
||||
new Term[] {a,b}
|
||||
);
|
||||
|
||||
static void
|
||||
test_1()
|
||||
{
|
||||
System.out.print( "test 1..." );
|
||||
Query query =
|
||||
new Query("p(a)");
|
||||
|
||||
if ( !query.hasSolution() ){
|
||||
System.out.println( "p(a) failed" );
|
||||
System.exit( 1 );
|
||||
}
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_2()
|
||||
{
|
||||
System.out.print( "test 2..." );
|
||||
Query query =
|
||||
new Query(
|
||||
"p",
|
||||
new Term[] {f_a}
|
||||
);
|
||||
|
||||
if ( !query.hasSolution() ){
|
||||
System.out.println( "p(f(a)) failed" );
|
||||
System.exit( 1 );
|
||||
}
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_3()
|
||||
{
|
||||
System.out.print( "test 3..." );
|
||||
Query query =
|
||||
new Query(
|
||||
"p",
|
||||
new Term[] {pair_a_b}
|
||||
);
|
||||
|
||||
if ( !query.hasSolution() ){
|
||||
System.out.println( "p( a-b ) failed" );
|
||||
System.exit( 1 );
|
||||
}
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_4()
|
||||
{
|
||||
System.out.print( "test 4..." );
|
||||
Variable X = new Variable("X");
|
||||
Query query =
|
||||
new Query(
|
||||
"p",
|
||||
new Term[] {X}
|
||||
);
|
||||
|
||||
Term[] target = new Term[] {a,f_a,pair_a_b,new Variable("_")};
|
||||
|
||||
Hashtable[] solutions = query.allSolutions();
|
||||
|
||||
if ( solutions.length != 4 ){
|
||||
System.out.println( "p(X) failed:" );
|
||||
System.out.println( "\tExpected: 4 solutions" );
|
||||
System.out.println( "\tGot: " + solutions.length );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < solutions.length-1; ++i ){
|
||||
Term binding = (Term)solutions[i].get( "X" );
|
||||
if ( ! binding.equals( target[i] ) ){
|
||||
System.out.println( "p(X) failed" );
|
||||
System.out.println( "\tExpected: " + target[i]);
|
||||
System.out.println( "\tGot: " + binding);
|
||||
System.exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_5()
|
||||
{
|
||||
System.out.print( "test 5..." );
|
||||
Variable X = new Variable("X");
|
||||
Variable Y = new Variable("Y");
|
||||
Query query =
|
||||
new Query(
|
||||
"p",
|
||||
new Term[] {X,Y}
|
||||
);
|
||||
|
||||
Term[] x_target = new Term[] {a,a};
|
||||
Term[] y_target = new Term[] {a,b};
|
||||
|
||||
Hashtable[] solutions = query.allSolutions();
|
||||
|
||||
if ( solutions.length != 2 ){
|
||||
System.out.println( "p(X, Y) failed:" );
|
||||
System.out.println( "\tExpected: 2 solutions" );
|
||||
System.out.println( "\tGot: " + solutions.length );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < solutions.length; ++i ){
|
||||
Object x_binding = solutions[i].get("X");
|
||||
if ( ! x_binding.equals( x_target[i] ) ){
|
||||
System.out.println( "p(X, Y) failed:" );
|
||||
System.out.println( "\tExpected: " + x_target[i] );
|
||||
System.out.println( "\tGot: " + x_binding );
|
||||
System.exit( 1 );
|
||||
}
|
||||
Object y_binding = solutions[i].get("Y");
|
||||
if ( ! y_binding.equals( y_target[i] ) ){
|
||||
System.out.println( "p( X, Y ) failed:" );
|
||||
System.out.println( "\tExpected: " + y_target[i] );
|
||||
System.out.println( "\tGot: " + y_binding );
|
||||
System.exit( 1 );
|
||||
}
|
||||
}
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_6()
|
||||
{
|
||||
System.out.print( "test 6..." );
|
||||
Variable X = new Variable("X");
|
||||
Query query =
|
||||
new Query(
|
||||
"p",
|
||||
new Term[] {X,X}
|
||||
);
|
||||
|
||||
Term[] x_target = new Term[] {a};
|
||||
|
||||
Hashtable[] solutions = query.allSolutions();
|
||||
|
||||
if ( solutions.length != 1 ){
|
||||
System.out.println( "p(X, X) failed:" );
|
||||
System.out.println( "\tExpected: 1 solution" );
|
||||
System.out.println( "\tGot: " + solutions.length );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < solutions.length; ++i ){
|
||||
Object x_binding = solutions[i].get("X");
|
||||
if ( ! x_binding.equals( x_target[i] ) ){
|
||||
System.out.println( "p(X, X) failed:" );
|
||||
System.out.println( "\tExpected: " + x_target[i] );
|
||||
System.out.println( "\tGot: " + x_binding );
|
||||
System.exit( 1 );
|
||||
}
|
||||
}
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_7()
|
||||
{
|
||||
System.out.print( "test 7..." );
|
||||
Variable X = new Variable("X");
|
||||
Variable Y = new Variable("Y");
|
||||
Query query =
|
||||
new Query(
|
||||
"r",
|
||||
new Term[] {
|
||||
new Compound(
|
||||
"f",
|
||||
new Term[] {X,X}
|
||||
),
|
||||
Y
|
||||
}
|
||||
);
|
||||
|
||||
Hashtable[] solutions = query.allSolutions();
|
||||
|
||||
if ( solutions.length != 2 ){
|
||||
System.out.println( "r(f(X,X), Y) failed:" );
|
||||
System.out.println( "\tExpected: 2 solutions" );
|
||||
System.out.println( "\tGot: " + solutions.length );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
Object x_binding, y_binding;
|
||||
|
||||
x_binding = solutions[0].get("X");
|
||||
y_binding = solutions[0].get("Y");
|
||||
if ( x_binding != y_binding ){
|
||||
System.out.println( "r(f(X,X), Y) failed:" );
|
||||
System.out.println( Util.toString( solutions[0] ) );
|
||||
System.out.println( "\tThe variables to which X and Y are bound in the first solution should be identical." );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
x_binding = solutions[1].get("X");
|
||||
y_binding = solutions[1].get("Y");
|
||||
if ( x_binding == y_binding ){
|
||||
System.out.println( "r(f(X,X), Y) failed:" );
|
||||
System.out.println( Util.toString( solutions[1] ) );
|
||||
System.out.println( "\tThe variables to which X and Y are bound in the second solution should be distinct." );
|
||||
System.exit( 1 );
|
||||
}
|
||||
if ( x_binding.equals( y_binding ) ){
|
||||
System.out.println( "r(f(X,X), Y) failed:" );
|
||||
System.out.println( Util.toString( solutions[1] ) );
|
||||
System.out.println( "\tThe variables to which X and Y are bound in the second solution should not be \"equal\"." );
|
||||
System.exit( 1 );
|
||||
}
|
||||
/*
|
||||
if ( ! solutions[0].get("X").equals( solutions[1].get("X") ) ){
|
||||
System.out.println( "r(f(X,X), Y) failed:" );
|
||||
System.out.println( Util.toString( solutions[0] ) );
|
||||
System.out.println(
|
||||
"\tThe variable to which X is bound in the first solution (" + solutions[0].get("X") + ")\n" +
|
||||
"\tshould be equal to the variable to which X is bound in the second (" + solutions[1].get("X") + ")");
|
||||
System.exit( 1 );
|
||||
}
|
||||
*/
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_8()
|
||||
{
|
||||
System.out.print( "test 8..." );
|
||||
Variable X = new Variable("X");
|
||||
Query query =
|
||||
new Query(
|
||||
"r",
|
||||
new Term[] {
|
||||
new Compound(
|
||||
"f",
|
||||
new Term[] {X,X}
|
||||
),
|
||||
X
|
||||
}
|
||||
);
|
||||
|
||||
Hashtable[] solutions = query.allSolutions();
|
||||
|
||||
if ( solutions.length != 2 ){
|
||||
System.out.println( "r( f( X, X ), X ) failed:" );
|
||||
System.out.println( "\tExpected: 2 solutions" );
|
||||
System.out.println( "\tGot: " + solutions.length );
|
||||
System.exit( 1 );
|
||||
}
|
||||
/*
|
||||
if ( ! solutions[0].get("X").equals( solutions[1].get("X") ) ){
|
||||
System.out.println( "r( f( X, X ), X ) failed:" );
|
||||
System.out.println( Util.toString( solutions[0] ) );
|
||||
System.out.println(
|
||||
"\tThe variable to which X is bound in the first solution\n" +
|
||||
"\tshould be equal to the variable to which X is bound in the second." );
|
||||
System.exit( 1 );
|
||||
}
|
||||
*/
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
// corresponds with Prolog List: [a-a,a-b]
|
||||
static Term test_9_solution =
|
||||
Util.termArrayToList(
|
||||
new Term[] {
|
||||
new Compound( "-", new Term[] {a,a}),
|
||||
new Compound( "-", new Term[] {a,b})
|
||||
}
|
||||
);
|
||||
|
||||
static void
|
||||
test_9()
|
||||
{
|
||||
System.out.print( "test 9..." );
|
||||
Variable X = new Variable("X");
|
||||
Variable Y = new Variable("Y");
|
||||
Variable XYs = new Variable("XYs");
|
||||
Query query =
|
||||
new Query(
|
||||
"bagof",
|
||||
new Term[] {
|
||||
new Compound(
|
||||
"-",
|
||||
new Term[] {X,Y}
|
||||
),
|
||||
new Compound(
|
||||
"p",
|
||||
new Term[] {X,Y}
|
||||
),
|
||||
XYs
|
||||
}
|
||||
);
|
||||
|
||||
Hashtable[] solutions = query.allSolutions();
|
||||
|
||||
if ( solutions.length != 1 ){
|
||||
System.out.println( "bagof(X-Y, p(X,Y), XYs) failed:" );
|
||||
System.out.println( "\tExpected: 1 solution" );
|
||||
System.out.println( "\tGot: " + solutions.length );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
Term term = (Term) solutions[0].get("XYs");
|
||||
|
||||
// if ( ! (term instanceof List) ){
|
||||
if ( ! (term instanceof Compound && ".".equals(((Compound)term).name()) && ((Compound)term).arity()==2) ){
|
||||
System.out.println( "bagof(X-Y, p(X,Y), XYs) failed:" );
|
||||
System.out.println( "\tExpected: XYs to be a List" );
|
||||
System.out.println( "\tGot: " + term );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
if ( ! term.equals( test_9_solution ) ){
|
||||
System.out.println( "bagof(X-Y, p(X,Y), XYs) failed:" );
|
||||
System.out.println( "\tExpected: " + test_9_solution );
|
||||
System.out.println( "\tGot: " + term );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_10()
|
||||
{
|
||||
System.out.print( "test 10..." );
|
||||
Query query =
|
||||
new Query( "t" );
|
||||
|
||||
try {
|
||||
boolean b = query.hasSolution();
|
||||
System.out.println( "t failed:" );
|
||||
System.out.println( "\tExpected: JPLException" );
|
||||
System.out.println( "\tGot: " + b );
|
||||
System.exit( 1 );
|
||||
} catch ( PrologException e ){
|
||||
}
|
||||
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_11()
|
||||
{
|
||||
System.out.print( "test 11..." );
|
||||
Term tuple =
|
||||
new Compound(
|
||||
"t",
|
||||
new Term[]{
|
||||
new Atom( "a" ),
|
||||
new Atom( "b" ),
|
||||
new Atom( "c" ),
|
||||
new Atom( "d" ),
|
||||
new Atom( "e" )
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
Variable X = new Variable("X");
|
||||
Query query = new Query( "tuple", new Term[] {X} );
|
||||
|
||||
java.util.Hashtable solution = query.oneSolution();
|
||||
|
||||
Term result = (Term) solution.get("X");
|
||||
|
||||
if ( result == null || ! result.equals( tuple ) ){
|
||||
System.out.println( "failed:" );
|
||||
System.out.println( "\tresult: " + result );
|
||||
System.out.println( "\ttuple: " + tuple );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
Term term;
|
||||
|
||||
term = new Atom( "a" );
|
||||
if ( ((Compound)result).arg( 1 ) == null || !((Compound)result).arg( 1 ).equals( term ) ){
|
||||
System.out.println( "failed:" );
|
||||
System.out.println( "\t((Compound)result).arg( 1 ): " + ((Compound)result).arg( 1 ) );
|
||||
System.out.println( "\tterm : " + term );
|
||||
System.exit( 1 );
|
||||
}
|
||||
term = new Atom( "b" );
|
||||
if ( ((Compound)result).arg( 2 ) == null || !((Compound)result).arg( 2 ).equals( term ) ){
|
||||
System.out.println( "failed:" );
|
||||
System.out.println( "\t((Compound)result).arg( 2 ): " + ((Compound)result).arg( 2 ) );
|
||||
System.out.println( "\tterm : " + term );
|
||||
System.exit( 1 );
|
||||
}
|
||||
term = new Atom( "e" );
|
||||
if ( ((Compound)result).arg( 5 ) == null || !((Compound)result).arg( 5 ).equals( term ) ){
|
||||
System.out.println( "failed:" );
|
||||
System.out.println( "\t((Compound)result).arg( 5 ): " + ((Compound)result).arg( 5 ) );
|
||||
System.out.println( "\tterm : " + term );
|
||||
System.exit( 1 );
|
||||
}
|
||||
// arg0(6) throws an exception, as I'd expect it to...
|
||||
// if ( ((Compound)result).arg( 7 ) != null ){
|
||||
// System.out.println( "failed:" );
|
||||
// System.out.println( "\t((Compound)result).arg( 7 ): " + ((Compound)result).arg( 7 ) );
|
||||
// System.out.println( "\tshould be null" );
|
||||
// System.exit( 1 );
|
||||
// }
|
||||
} catch ( PrologException e ){
|
||||
System.out.println( "failed" );
|
||||
e.printStackTrace();
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_101()
|
||||
{
|
||||
System.out.print( "test 101..." );
|
||||
Thread[] threads = new Thread[10];
|
||||
|
||||
for ( int i = 0; i < threads.length; ++i ){
|
||||
threads[i] = new QueryThread( i );
|
||||
}
|
||||
for ( int i = 0; i < threads.length; ++i ){
|
||||
threads[i].start();
|
||||
}
|
||||
for ( int i = 0; i < threads.length; ++i ){
|
||||
try {
|
||||
threads[i].join();
|
||||
} catch ( InterruptedException ie ){
|
||||
ie.printStackTrace();
|
||||
System.exit( 1 );
|
||||
}
|
||||
}
|
||||
System.out.println( "passed." );
|
||||
}
|
||||
|
||||
private static class
|
||||
QueryThread extends Thread
|
||||
{
|
||||
private int id_ = -1;
|
||||
|
||||
public
|
||||
QueryThread( int id )
|
||||
{
|
||||
this.id_ = id;
|
||||
}
|
||||
|
||||
public java.lang.String
|
||||
toString()
|
||||
{
|
||||
return "(QueryThread id=" + id_ + ")";
|
||||
}
|
||||
|
||||
|
||||
public void
|
||||
run()
|
||||
{
|
||||
Query query =
|
||||
new Query(
|
||||
"p",
|
||||
new Term[] {
|
||||
new Atom("a"),
|
||||
new Atom("a")
|
||||
}
|
||||
);
|
||||
|
||||
for ( int i = 0; i < 10; ++i ){
|
||||
try {
|
||||
query.hasSolution();
|
||||
} catch ( jpl.JPLException e ){
|
||||
System.out.println( "Threaded p( a, a ) threw exception: " + e);
|
||||
System.exit( 1 );
|
||||
}
|
||||
System.out.print( id_ );
|
||||
Thread.yield();
|
||||
}
|
||||
for ( int i = 0; i < 10; ++i ){
|
||||
// synchronized ( Query.lock() ){
|
||||
try {
|
||||
while ( query.hasMoreSolutions() ){
|
||||
Thread.yield();
|
||||
query.nextSolution();
|
||||
}
|
||||
} catch ( jpl.JPLException e ){
|
||||
System.out.println( "Threaded p( a, a ) threw exception: " + e);
|
||||
System.exit( 1 );
|
||||
}
|
||||
System.out.print( id_ );
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// more to come??
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
call ..\env.bat
|
||||
|
||||
if not exist Test.class (
|
||||
echo Compiling Test.java
|
||||
javac Test.java
|
||||
)
|
||||
|
||||
java Test
|
||||
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../env.sh
|
||||
|
||||
run Test
|
||||
|
@ -1,39 +0,0 @@
|
||||
% a simple database for Test.java
|
||||
p( a).
|
||||
|
||||
p( f(a)).
|
||||
|
||||
p( a-b).
|
||||
|
||||
p( _X).
|
||||
|
||||
|
||||
p( a, a).
|
||||
|
||||
p( a, b).
|
||||
|
||||
|
||||
q( f(X,X)).
|
||||
|
||||
q( f(_X,_Y)).
|
||||
|
||||
|
||||
r( f(X,X), X).
|
||||
|
||||
r( f(X,X), _Y).
|
||||
|
||||
|
||||
s( X, f(X,X)).
|
||||
|
||||
s( _Y, f(X,X)).
|
||||
|
||||
|
||||
tuple( t(a,b,c,d,e)).
|
||||
|
||||
|
||||
t :-
|
||||
throw( 'this is an error message').
|
||||
|
||||
display( X) :-
|
||||
write( X).
|
||||
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1,14 +0,0 @@
|
||||
compile.bat
|
||||
will compile this demo
|
||||
|
||||
run.bat
|
||||
will run it
|
||||
|
||||
..\README.txt
|
||||
may explain what is happening
|
||||
|
||||
----
|
||||
|
||||
Paul Singleton (paul.singleton@bcs.org.uk)
|
||||
February 2004
|
||||
|
@ -1,26 +0,0 @@
|
||||
//tabstop=4
|
||||
|
||||
import jpl.*;
|
||||
|
||||
public class Test2
|
||||
{ public static int fac(int n)
|
||||
{ if (n == 1)
|
||||
{ return 1;
|
||||
} else
|
||||
{ return n * ((jpl.Integer)
|
||||
new Query(new Compound("jpl_test_fac", new Term[]
|
||||
{ new jpl.Integer(n - 1),
|
||||
new Variable("F")
|
||||
})).oneSolution().get("F")).intValue();
|
||||
}
|
||||
}
|
||||
|
||||
public static void
|
||||
main( java.lang.String argv[] )
|
||||
{ new Query("consult('test2.pl')").oneSolution();
|
||||
|
||||
System.out.print( "calling Prolog to call Java to call Prolog...\n" );
|
||||
|
||||
System.out.println( "factorial(10) = " + fac(10));
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
call ..\env.bat
|
||||
|
||||
if not exist Test2.class (
|
||||
echo Compiling Test2.java
|
||||
javac Test2.java
|
||||
)
|
||||
|
||||
java Test2
|
||||
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../env.sh
|
||||
|
||||
run Test2
|
||||
|
@ -1,13 +0,0 @@
|
||||
% jpl_test_fac(+N, -F) :-
|
||||
% F is the factorial of the positive integer N
|
||||
|
||||
:- use_module(library(jpl)).
|
||||
|
||||
jpl_test_fac(N, F) :-
|
||||
( N == 1
|
||||
-> F = 1
|
||||
; N2 is N-1,
|
||||
jpl_call('Test2', fac, [N2], F2),
|
||||
F is N*F2
|
||||
).
|
||||
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1,14 +0,0 @@
|
||||
compile.bat
|
||||
will compile this demo
|
||||
|
||||
run.bat
|
||||
will run it
|
||||
|
||||
..\README.txt
|
||||
may explain what is happening
|
||||
|
||||
----
|
||||
|
||||
Paul Singleton (paul.singleton@bcs.org.uk)
|
||||
February 2004
|
||||
|
@ -1,338 +0,0 @@
|
||||
//tabstop=4
|
||||
//*****************************************************************************/
|
||||
// Project: jpl
|
||||
//
|
||||
// File: $Id$
|
||||
// Date: $Date$
|
||||
// Author: Fred Dushin <fadushin@syr.edu>
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// -------------------------------------------------------------------------
|
||||
// Copyright (c) 1998 Fred Dushin
|
||||
// All rights reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Library Public License for more details.
|
||||
//*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
import java.util.Hashtable;
|
||||
import jpl.Query; // empirically, we need this, but I don't know why...
|
||||
import jpl.*;
|
||||
|
||||
public class Time
|
||||
{
|
||||
static int tree_depth = 10;
|
||||
static int num_tests = 5;
|
||||
static int num_trials = 10;
|
||||
static long[][] data = null;
|
||||
static Term tree = null;
|
||||
static Atom empty_tree = new Atom("t");
|
||||
static Timer timer = new Timer();
|
||||
|
||||
public static void
|
||||
main( java.lang.String argv[] )
|
||||
{
|
||||
parse_params( argv );
|
||||
|
||||
JPL.init();
|
||||
|
||||
run_tests();
|
||||
}
|
||||
|
||||
static void
|
||||
parse_params( java.lang.String argv[] )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while ( i < argv.length ){
|
||||
if ( argv[i].equals( "-help" ) ){
|
||||
print_help();
|
||||
System.exit( 1 );
|
||||
} else if ( argv[i].equals( "-num_trials" ) ){
|
||||
num_trials = java.lang.Integer.valueOf( argv[i+1] ).intValue();
|
||||
i += 2;
|
||||
} else if ( argv[i].equals( "-tree_depth" ) ){
|
||||
tree_depth = java.lang.Integer.valueOf( argv[i+1] ).intValue();
|
||||
i += 2;
|
||||
} else {
|
||||
System.err.println( "Unrecognized option: " + argv[i] );
|
||||
print_help();
|
||||
System.exit( 1 );
|
||||
}
|
||||
}
|
||||
data = new long[num_tests][num_trials];
|
||||
}
|
||||
|
||||
static void
|
||||
print_help()
|
||||
{
|
||||
System.out.println(
|
||||
"java Time\n" +
|
||||
"\t-help print this screen\n" +
|
||||
"\t-num_trials <num> specify number of trials (default: 10)\n" +
|
||||
"\t-tree_depth <num> specify depth of binary tree (default: 10)\n" +
|
||||
"" );
|
||||
}
|
||||
|
||||
static void
|
||||
run_tests()
|
||||
{
|
||||
test_0();
|
||||
test_1();
|
||||
test_2();
|
||||
test_3();
|
||||
test_4();
|
||||
|
||||
print_results();
|
||||
}
|
||||
|
||||
static void
|
||||
test_0()
|
||||
{
|
||||
System.out.print( "test 0..." );
|
||||
Query query =
|
||||
new Query("consult('time.pl')");
|
||||
|
||||
if ( !query.hasSolution() ){
|
||||
System.out.println( "consult('time.pl') failed" );
|
||||
System.exit( 1 );
|
||||
}
|
||||
System.out.println( "passed." );
|
||||
|
||||
System.out.print( "trees" );
|
||||
for ( int i = 0; i < num_trials; ++i ){
|
||||
timer.start();
|
||||
tree = create_tree();
|
||||
timer.stop();
|
||||
|
||||
data[0][i] = timer.getElapsedTimeInMillis();
|
||||
System.out.print( "." );
|
||||
}
|
||||
System.out.println( "done." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_1()
|
||||
{
|
||||
Query query = new Query( "traverse", new Term[]{tree} );
|
||||
|
||||
System.out.print( "traverse" );
|
||||
for ( int i = 0; i < num_trials; ++i ){
|
||||
|
||||
timer.start();
|
||||
query.hasSolution();
|
||||
timer.stop();
|
||||
|
||||
data[1][i] = timer.getElapsedTimeInMillis();
|
||||
System.out.print( "." );
|
||||
}
|
||||
System.out.println( "done." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_2()
|
||||
{
|
||||
Query query = new Query( "noop", new Term[]{tree} );
|
||||
|
||||
System.out.print( "noop" );
|
||||
for ( int i = 0; i < num_trials; ++i ){
|
||||
|
||||
timer.start();
|
||||
java.util.Hashtable solution = query.oneSolution();
|
||||
timer.stop();
|
||||
|
||||
data[2][i] = timer.getElapsedTimeInMillis();
|
||||
System.out.print( "." );
|
||||
}
|
||||
System.out.println( "done." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_3()
|
||||
{
|
||||
Variable Y = new Variable("Y");
|
||||
Query query = new Query( "noop_nobind", new Term[]{tree,Y} );
|
||||
|
||||
System.out.print( "noop_nobind" );
|
||||
for ( int i = 0; i < num_trials; ++i ){
|
||||
|
||||
timer.start();
|
||||
boolean ok = query.hasSolution();
|
||||
timer.stop();
|
||||
|
||||
data[3][i] = timer.getElapsedTimeInMillis();
|
||||
System.out.print( "." );
|
||||
}
|
||||
System.out.println( "done." );
|
||||
}
|
||||
|
||||
static void
|
||||
test_4()
|
||||
{
|
||||
Variable Y = new Variable("Y");
|
||||
Query query = new Query( "noop_bind", new Term[]{tree,Y} );
|
||||
|
||||
System.out.print( "noop_bind" );
|
||||
for ( int i = 0; i < num_trials; ++i ){
|
||||
|
||||
timer.start();
|
||||
java.util.Hashtable solution = query.oneSolution();
|
||||
timer.stop();
|
||||
|
||||
data[4][i] = timer.getElapsedTimeInMillis();
|
||||
System.out.print( "." );
|
||||
}
|
||||
System.out.println( "done." );
|
||||
}
|
||||
|
||||
static java.text.NumberFormat format =
|
||||
java.text.NumberFormat.getInstance();
|
||||
static {
|
||||
format.setMaximumFractionDigits(3);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_results()
|
||||
{
|
||||
long num_terms = (long)(Math.pow( 2, tree_depth ) + 1);
|
||||
System.out.println();
|
||||
System.out.println( "num_trials: " + num_trials );
|
||||
System.out.println( "tree_depth: " + tree_depth +
|
||||
" (= " + num_terms + " terms)" );
|
||||
System.out.println();
|
||||
|
||||
for ( int j = 0; j < num_tests; ++j ){
|
||||
System.out.print( "test_" + j + "\t\t" );
|
||||
}
|
||||
System.out.println( "\n" );
|
||||
for ( int i = 0; i < num_trials; ++i ){
|
||||
for ( int j = 0; j < num_tests; ++j ){
|
||||
System.out.print( data[j][i] + "\t\t" );
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println( "\n" );
|
||||
|
||||
for ( int j = 0; j < num_tests; ++j ){
|
||||
System.out.println(
|
||||
"test_" + j + ": " +
|
||||
"avg: " + format.format( avg( j ) ) + "ms\t\t" +
|
||||
format.format( avg( j )/num_terms ) + "ms/term"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static double
|
||||
avg( int test )
|
||||
{
|
||||
long min = java.lang.Long.MAX_VALUE,
|
||||
max = java.lang.Long.MIN_VALUE;
|
||||
|
||||
long sum = 0L;
|
||||
for ( int i = 0; i < num_trials; ++i ){
|
||||
sum += data[test][i];
|
||||
if ( min < data[test][i] ){
|
||||
min = data[test][i];
|
||||
}
|
||||
if ( max > data[test][i] ){
|
||||
max = data[test][i];
|
||||
}
|
||||
}
|
||||
//sum -= (min+max);
|
||||
|
||||
return sum/(num_trials/*-2*/);
|
||||
}
|
||||
|
||||
|
||||
static Term
|
||||
create_tree()
|
||||
{
|
||||
return binary_tree( tree_depth );
|
||||
}
|
||||
|
||||
static Term
|
||||
binary_tree( int depth )
|
||||
{
|
||||
if ( depth <= 0 ){
|
||||
return empty_tree;
|
||||
} else {
|
||||
return
|
||||
new Compound(
|
||||
"t",
|
||||
new Term[]{
|
||||
binary_tree( depth - 1 ),
|
||||
binary_tree( depth - 1 )
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class Timer
|
||||
{
|
||||
private java.util.Calendar calendar = java.util.Calendar.getInstance();
|
||||
|
||||
private long start_time = 0L,
|
||||
stop_time = 0L;
|
||||
|
||||
boolean running = false;
|
||||
|
||||
public
|
||||
Timer()
|
||||
{
|
||||
}
|
||||
|
||||
public void
|
||||
start()
|
||||
{
|
||||
if ( !running ){
|
||||
start_time = getMillis();
|
||||
running = true;
|
||||
}
|
||||
}
|
||||
|
||||
private long
|
||||
getMillis()
|
||||
{
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void
|
||||
stop()
|
||||
{
|
||||
if ( running ){
|
||||
stop_time = getMillis();
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
public long
|
||||
getElapsedTimeInMillis()
|
||||
{
|
||||
if ( running ){
|
||||
return getMillis() - start_time;
|
||||
} else {
|
||||
return stop_time - start_time;
|
||||
}
|
||||
}
|
||||
|
||||
public double
|
||||
getElapsedTimeInSeconds()
|
||||
{
|
||||
return getElapsedTimeInMillis()/1000;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
call ..\env.bat
|
||||
|
||||
if not exist Time.class (
|
||||
echo Compiling Time.java
|
||||
javac Time.java
|
||||
)
|
||||
|
||||
java Time
|
||||
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../env.sh
|
||||
|
||||
run Time
|
||||
|
@ -1,17 +0,0 @@
|
||||
% a simple database for Time.java
|
||||
|
||||
traverse( []).
|
||||
|
||||
traverse( [H|T]) :-
|
||||
traverse( H),
|
||||
traverse( T).
|
||||
|
||||
|
||||
noop( _X).
|
||||
|
||||
|
||||
noop_nobind( _X, _Y).
|
||||
|
||||
|
||||
noop_bind( X, X).
|
||||
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1,14 +0,0 @@
|
||||
compile.bat
|
||||
will compile this demo
|
||||
|
||||
run.bat
|
||||
will run it
|
||||
|
||||
..\README.txt
|
||||
may explain what is happening
|
||||
|
||||
----
|
||||
|
||||
Paul Singleton (paul.singleton@bcs.org.uk)
|
||||
February 2004
|
||||
|
@ -1,41 +0,0 @@
|
||||
import java.util.Hashtable;
|
||||
import jpl.*;
|
||||
|
||||
public class Versions
|
||||
{
|
||||
public static void
|
||||
main( String argv[] )
|
||||
{
|
||||
|
||||
Compound goal1 =
|
||||
new Compound("consult",
|
||||
new Term[] {
|
||||
new Compound("library",
|
||||
new Term[] {
|
||||
new Atom("jpl") }
|
||||
)
|
||||
});
|
||||
Query q1 = new Query(goal1);
|
||||
if ( !q1.hasSolution() ) {
|
||||
System.out.println( "consult(library(jpl)) failed" );
|
||||
return;
|
||||
}
|
||||
String prologVersion = ((Term) (new Query("jpl_pl_lib_version(V)")).oneSolution().get("V")).name();
|
||||
String javaVersion = jpl.JPL.version_string();
|
||||
String cVersion = jpl.fli.Prolog.get_c_lib_version();
|
||||
|
||||
System.out.println( "prolog library version; " + prologVersion );
|
||||
System.out.println( " java library version; " + javaVersion );
|
||||
System.out.println( " c library version; " + cVersion );
|
||||
|
||||
if ( prologVersion.equals(javaVersion) && javaVersion.equals(cVersion) ) {
|
||||
System.out.println( "BINGO! you appear to have the same version of each library installed");
|
||||
} else {
|
||||
System.out.println( "WHOOPS! you appear not to have the same version of each library installed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
call ..\env.bat
|
||||
|
||||
if not exist Versions.class (
|
||||
echo Compiling Versions.java
|
||||
javac Versions.java
|
||||
)
|
||||
|
||||
java Versions
|
||||
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../env.sh
|
||||
|
||||
run Versions
|
||||
|
@ -1 +0,0 @@
|
||||
*.class
|
@ -1,14 +0,0 @@
|
||||
compile.bat
|
||||
will compile this demo
|
||||
|
||||
run.bat
|
||||
will run it
|
||||
|
||||
..\README.txt
|
||||
may explain what is happening
|
||||
|
||||
----
|
||||
|
||||
Paul Singleton (paul.singleton@bcs.org.uk)
|
||||
February 2004
|
||||
|
@ -1,66 +0,0 @@
|
||||
//tabstop=4
|
||||
//*****************************************************************************/
|
||||
// Project: jpl
|
||||
//
|
||||
// File: $Id$
|
||||
// Date: $Date$
|
||||
// Author: Fred Dushin <fadushin@syr.edu>
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// -------------------------------------------------------------------------
|
||||
// Copyright (c) 1998 Fred Dushin
|
||||
// All rights reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Library Public License for more details.
|
||||
//*****************************************************************************/
|
||||
|
||||
// calls gen([t(c,q,[]),t(v,[],a)],ANSWER).
|
||||
|
||||
import java.util.Hashtable;
|
||||
import jpl.*;
|
||||
|
||||
public class Zahed
|
||||
{
|
||||
public static void
|
||||
main( java.lang.String argv[] )
|
||||
{
|
||||
|
||||
Compound goal1 = new Compound("consult", new Term[] { new Atom("zahed.pl") });
|
||||
Query q1 = new Query(goal1);
|
||||
System.out.println( "new query..." );
|
||||
if ( !q1.hasSolution() ){
|
||||
System.out.println( "failed" );
|
||||
System.out.println( "consult('zahed.pl') failed" );
|
||||
return;
|
||||
}
|
||||
|
||||
Term t2 = new Compound("t", new Term[] { new Atom("v"), new Atom("[]"), new Atom("a") });
|
||||
Compound list2 = new Compound(".", new Term[] { t2, new Atom("[]") });
|
||||
|
||||
Compound t1 = new Compound("t", new Term[] { new Atom("c"), new Atom("q"), new Atom("[]") });
|
||||
Compound list1 = new Compound(".", new Term[] { t1, list2 });
|
||||
|
||||
Variable answer = new Variable("A");
|
||||
|
||||
Compound goal2 = new Compound("gen", new Term[] { list1, answer });
|
||||
|
||||
Query q2 = new Query(goal2);
|
||||
Hashtable solution = q2.oneSolution();
|
||||
if ( solution == null ) {
|
||||
System.out.println( "failed" );
|
||||
} else {
|
||||
System.out.println( solution.get("A").toString());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
call ..\env.bat
|
||||
|
||||
if not exist Zahed.class (
|
||||
echo Compiling Zahed.java
|
||||
javac Zahed.java
|
||||
)
|
||||
|
||||
java Zahed
|
||||
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ../env.sh
|
||||
|
||||
run Zahed
|
||||
|
@ -1,4 +0,0 @@
|
||||
% simple dummy predicate to test Zahed's goal from Java:
|
||||
|
||||
gen( [t(_,_,_),t(_,_,_)], ok).
|
||||
|
@ -1,21 +0,0 @@
|
||||
@echo off
|
||||
|
||||
REM Set variables needed by the examples
|
||||
REM This script assumes both the bin directories of SWI-Prolog and the Java
|
||||
REM SDK to be in %PATH%. If this is not the case, you may wish to set %PATH%
|
||||
REM in this script.
|
||||
|
||||
REM Find the Prolog coordinates
|
||||
|
||||
swipl.exe -dump-runtime-variables=cmd > %TEMP%\plrtvars.bat
|
||||
call %TEMP%\plrtvars.bat
|
||||
del %TEMP%\plrtvars.bat
|
||||
|
||||
REM Find classpath for jpl.jar. First case holds if we are in the source tree.
|
||||
|
||||
if exist ..\..\..\jpl.jar (
|
||||
set CLASSPATH=.;..\..\..\jpl.jar
|
||||
) else (
|
||||
set CLASSPATH=.;%PLBASE%\lib\jpl.jar
|
||||
)
|
||||
|
@ -1,168 +0,0 @@
|
||||
################################################################
|
||||
# Setup the environment for compiling and running the demos on
|
||||
# Unix like platforms. This script is sourced from the run.sh
|
||||
# scripts in the various example directories.
|
||||
#
|
||||
# You may need to edit this before running the demos
|
||||
#
|
||||
# Required setup
|
||||
#
|
||||
# * The directory holding java and javac must be in $PATH
|
||||
# * JPL must be installed
|
||||
# * Prolog must be available as one of "swi-prolog", "swipl"
|
||||
# or "pl" in $PATH
|
||||
#
|
||||
################################################################
|
||||
|
||||
findexe()
|
||||
{ oldifs="$IFS"
|
||||
IFS=:
|
||||
for d in $PATH; do
|
||||
if [ -x $d/$1 ]; then
|
||||
IFS="$oldifs"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
IFS="$oldifs"
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ "$JPL_COMPILE_ONLY" != "yes" ]; then
|
||||
for f in swi-prolog swipl pl; do
|
||||
if [ -z "$PL" ]; then
|
||||
if findexe $f; then
|
||||
PL="$f"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
if findexe java; then
|
||||
true
|
||||
elif [ -x "$JAVA_HOME"/bin/java ]; then
|
||||
PATH="$PATH:$JAVA_HOME/bin"
|
||||
else
|
||||
echo "ERROR: Cannot find java. Please ensure JAVA_HOME is set"
|
||||
echo "ERROR: properly or java is in $PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if findexe javac; then
|
||||
true
|
||||
else
|
||||
echo "ERROR: Cannot find javac. This demo requires the SDK to"
|
||||
echo "ERROR: be installed and accessible through JAVA_HOME"
|
||||
echo "ERROR: or PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
################################################################
|
||||
# Setup the environment
|
||||
################################################################
|
||||
|
||||
EXEC="$PL"
|
||||
eval `eval $PL -dump-runtime-variables`
|
||||
|
||||
if [ -z "$PLBASE" ]; then
|
||||
PLLIBDIR="$YAP_ROOTDIR/lib/Yap"
|
||||
if [ -z "$JPLJAR" ]; then
|
||||
JPLJAR="$YAP_ROOTDIR/share/Yap/jpl/jpl.jar"
|
||||
fi
|
||||
else
|
||||
PLLIBDIR="$PLBASE/lib/$PLARCH"
|
||||
fi
|
||||
|
||||
if [ -z "$JPLJAR" ]; then
|
||||
JPLJAR="$PLBASE/lib/jpl.jar"
|
||||
fi
|
||||
|
||||
if [ -z "$LD_LIBRARY_PATH" ]; then
|
||||
LD_LIBRARY_PATH="$PLLIBDIR";
|
||||
else
|
||||
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PLLIBDIR"
|
||||
fi
|
||||
|
||||
if [ -z "$CLASSPATH" ]; then
|
||||
CLASSPATH=".:$JPLJAR";
|
||||
else
|
||||
CLASSPATH=".:$JPLJAR:$CLASSPATH"
|
||||
fi
|
||||
|
||||
export LD_LIBRARY_PATH CLASSPATH
|
||||
|
||||
################################################################
|
||||
# compile Class
|
||||
#
|
||||
# Compile the indicated class if necessary
|
||||
################################################################
|
||||
|
||||
compile()
|
||||
{ if test -z $CLASSDIR; then
|
||||
CLASSDIR="."
|
||||
fi
|
||||
if [ ! -f $CLASSDIR/$1.class ]; then
|
||||
echo "Compiling $1"
|
||||
javac $1.java -d $CLASSDIR
|
||||
elif [ $1.java -nt $CLASSDIR/$1.class ]; then
|
||||
echo "Recompiling $1"
|
||||
javac $1.java -d $CLASSDIR
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
################################################################
|
||||
# run Class
|
||||
#
|
||||
# Compiles Class if the .class file does not exsist and runs it
|
||||
# Note that some systems (Linux, ...) find the libjpl.xxx from
|
||||
# LD_LIBRARY_PATH. MacOS finds this only when named libjpl.jnilib
|
||||
# and using -Djava.library.path=<Path>. We pass both, hoping to
|
||||
# satisfy most systems ...
|
||||
################################################################
|
||||
|
||||
run()
|
||||
{ compile $1
|
||||
|
||||
if [ "$JPL_COMPILE_ONLY" != "yes" ]; then
|
||||
echo ""
|
||||
echo "JPL demo: $1"
|
||||
echo ""
|
||||
|
||||
java -Djava.library.path=$PLLIBDIR $1
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################
|
||||
# run_preloaded Class
|
||||
#
|
||||
# As run Class, but preloads libjpl.so to be able to use foreign
|
||||
# extensions to Prolog. See the SemWeb example
|
||||
#
|
||||
# This isn't needed for installations using SWI-Prolog through
|
||||
# the libpl.$PLSOEXT shared object. For the moment this is only
|
||||
# MacOS, which ignores LD_PRELOAD, so we'll ignore this issue for
|
||||
# the moment
|
||||
################################################################
|
||||
|
||||
run_preloaded()
|
||||
{ compile $1
|
||||
|
||||
if [ "$JPL_COMPILE_ONLY" != "yes" ]; then
|
||||
|
||||
if [ -z "$PLBASE" ]; then
|
||||
JPLSO="$YAP_ROOTDIR/lib/Yap/libjpl.$YAP_SHLIB_SUFFIX $YAP_ROOTDIR/lib/libYap.$YAP_SHLIB_SUFFIX"
|
||||
else
|
||||
JPLSO="$PLBASE/lib/$PLARCH/libjpl.$PLSOEXT"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "JPL demo: $1"
|
||||
echo "Using preloaded $JPLSO"
|
||||
echo ""
|
||||
|
||||
|
||||
env LD_PRELOAD="$JPLSO" java -Djava.library.path=$PLLIBDIR $1
|
||||
fi
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user