RingJavafor Ring

Testing

samples/UsingJava/tests has the automated tests.

samples/UsingJava/tests has the automated tests. A test file is a Ring program that loads testlib.ring and calls jtCheck("name", actual, expected), jtRaises(code, words) and jtSummary().

powershell samples/UsingJava/tests/run.ps1 [-Ring path\to\ring.exe] [-JavaHome C:\PL\Java\jdk-25.0.5.1]
sh samples/UsingJava/tests/run.sh [path/to/ring]
FileWhat it tests
t01_basicsstatic methods and fields, StringBuilder, String, Unicode, Random
t02_collectionsArrayList, HashMap, TreeMap, TreeSet, ArrayDeque, iterators, Ring lists as Java collections
t03_conversionstyped values, arrays, bytes, varargs, enums by name, null, instanceof
t04_callbacksComparator, streams, a thread, the other methods of an interface, errors in a callback, an executor
t05_errorsJava exceptions as Ring errors, the messages, jLastException()
t06_time_iojava.time, files, readers and writers, regex, BigDecimal, BigInteger, system properties
t07_dynamicjNew, jStatic, jClass, fields, boxing, automatic import
t08_memorythe release of Java objects when Ring drops them
t09_classpathjClasspath with a jar of your own, its interface as a callback, the classes made by the generator for the jar
t10_namednamed values, NULL, a list of values, @New, @toString
t11_guiSwing without a display (headless): listeners, events inside calls, models, timers, jInvokeLater
t12_maventhe Maven resolver on an offline repository: POM parents, BOMs, profiles, exclusions, ranges, cache
t13_jdbcJDBC helpers with a fake driver (data/fakedb.jar)
t14_staticsthe global objects System, Math, Integer, String ... and the lazy start of the JVM
t15_bundlebundle.ring: the generated classes next to a program made by ring2exe
t19_appsthe buttons of the applications do what they say (a copy of the program presses them and prints what it sees)
t18_speedthe caches and shortcuts do not change what a call does: the overload for each kind of values, prototype objects, deferred default objects, the release of handles
t17_mixinsan object that is several interfaces at once: the combined Ring class (a compiled class that implements Runnable, Comparable and Supplier), List.of
t20_queryjQuery: every operator, stable and multi-key sorts, Java collections, arrays, maps and streams as sources, objects by equals and compareTo, the errors
t21_swingthe window builders without a display: controls and handlers, layouts, menus, colours, JCanvas drawing, pixels in bulk, saving and the mouse
t22_dataJavaDatabase on H2 and on SQLite: the model, keys, parameters, queries as data, aggregates, relations, transactions, the errors
t26_chartsthe shapes of JCanvas (arcs, polygons, round rectangles), the axis scale, and each kind of JChart by counting the pixels of its colors
t23_webJavaWebServer with jHttpGet and jHttpPost in one program: routes, parameters, forms, JSON, errors, headers
t24_maven_centralten packages of Maven Central (Gson, Guava, commons-io, ...) downloaded and called; skipped when offline
t27_maven_central2ten more packages of Maven Central (commons-math3, commons-compress, ICU4J, Bouncy Castle, OkHttp, ...) downloaded and called; skipped when offline
t25_selftestevery application started with --selftest: its own checks pass and its status is 0
t16_tutorialsevery tutorial and every application runs without an error (the windows close by themselves; needs the package installed and a display)

The windows of the samples are checked by samples/UsingJava/gui/run_all.ps1 or run_all.sh (needs a display; each window closes by itself).

Linux#

The same tests run on Linux (tried on Ubuntu with Ring 1.28 and JDK 21: 27 files, all checks pass, about two minutes). JAVA_HOME names the JDK, and libring.so (and libring_java.so) must be found by the loader when Ring is built as a shared library:

export JAVA_HOME=$HOME/jdk/jdk-21
export LD_LIBRARY_PATH=$HOME/ring/lib:$JAVA_HOME/lib/server
sh samples/UsingJava/tests/run.sh

The GUI tests need no display (t11_gui is headless), but t16_tutorials and the windows of t19_apps need one: on WSL2 with WSLg (Windows 11) DISPLAY is already set; on a server use xvfb-run sh run.sh. The tests wait with the wall clock (java_now()), because clock() of Ring is processor time on Linux.

The generator is checked by tools/javatools/checkgenerated.ring, which loads every generated package.

Samples and tests#

The samples (introduction, gui, ecosystem) start with load "java.ring": the package must be installed in the Ring folder. The tests load libraries/javalib of the clone by a relative path (testlib.ring), so they also run before the package is installed. ringdoc shoot and ringdoc build --refresh run the samples, so they need the installed package too.

The manual and its screenshots#

The manual is made with ringdoc (cd docs):

ringdoc shoot          the screenshots: every window of the galleries, and the windows in a later state (docs/tools/shots.ring)
ringdoc build --refresh   the site, the output of the console programs is made by running them
ringdoc check          links, files, outputs
ringdoc pdf            the PDF

ringdoc shoot starts each GUI sample, waits for its window and photographs it with the Windows API (Windows only; it needs ringpm install ring-cffi from ysdragon). A shot of a window in a later state is a temporary copy of the sample with a few lines put before jAutoClose(): the list is in docs/tools/shots.ring. The pictures are in docs/site/img/shots.

RingJava - use Java classes and methods from Ring programs.