Releases: MarkusJx/node-java-bridge
Release v2.2.2-rc.1
Release v2.2.0
Core changes
Generate Typescript definitions for Java classes in bulk
A new class, TypescriptBulkDefinitionGenerator has been added in order to generate a lot of Typescript definitions for Java classes more easily:
import { TypescriptBulkDefinitionGenerator } from 'java-bridge';
const generator = new TypescriptBulkDefinitionGenerator();
// Generate definitions for the named classes
await generator.generate([
'java.io.FileOutputStream',
'java.io.FileInputStream',
'java.io.File',
'java.lang.System',
]);
// Retrieve the generated code
const definitions = generator.moduleDeclarations;
// Save the definitions to a directory
await generator.save('javaDefinitions');Change the classpath at startup more easily
In order to make changing the classpath before starting the JVM more easy, two new options have been added to ensureJvm:
classpath: string[]- Single files or glob patterns to add to the classpathignoreUnreadableClassPathEntries: boolean- Whether to ignore unreadable files in the classpath
With these new options, the classpath can be altered more easily, making sure some libraries like Spring Boot, which use a custom class loader can access all required dependencies at runtime, which is not guaranteed when using appendClasspath.
import { ensureJvm } from 'java-bridge';
ensureJvm({
classpath: [
'/path/to/your/lib.jar',
// Glob patterns for adding directories are supported
'/path/to/a/directory/*',
// This also allows for adding only files of a specific type
'/path/to/files/*.jar',
],
// Don't throw an error if a file is unreadable
ignoreUnreadableClassPathEntries: true,
});Additionally, ensureJvm now returns a boolean representing if the JVM has already been started by a previous call to java-bridge.
It returns true if the JVM has not already been started and this call to ensureJvm was responsible for creating the JVM, if the call returns false, the JVM has already been started by another call to java-bridge and this call to ensureJvm was basically a no-op.
import { ensureJvm } from 'java-bridge';
const started = ensureJvm();
if (!started) {
throw new Error('Failed to start the JVM as it is already running');
}Glob patterns for appendClasspath
As with ensureJvm, appendClasspath now supports glob patterns to add directories more easily:
import { appendClasspath } from 'java-bridge';
// Import a directory recursively
appendClasspath('/path/to/files/**/*');
// Import multiple files at once
appendClasspath([
'/path/to/your/file.jar',
// Again, this allows for only adding files of a specific type
'/path/to/some/files/*.jar',
]);This of course also works with classpath.append:
import { classpath } from 'java-bridge';
// Import all jars inside directories recursively
classpath.append('/path/to/many/files/**/*.jar')What's Changed
- fix(tsDefGen): add methods of superclasses to typescript definitions by @MarkusJx in #41
- fix(win32+arm64): fix win32 and arm64 build by @MarkusJx in #43
- feat(tsDefGen): add bulk typescript definition generator by @MarkusJx in #42
- feat(ci): add ci test reports by @MarkusJx in #45
- fix(classpath): IndexOutOfBounds when appending multiple files by @MarkusJx in #46
- feat(classpath): allow adding directories to the classpath by @MarkusJx in #47
- feat(startup): add convenience methods for altering the classpath by @MarkusJx in #49
Full Changelog: v2.1.7...v2.2.0
Release v2.1.7
What's Changed
- fix(win32): prevent the program from crashing when using the package on win32 by @MarkusJx in #34
- feat(cli): add field declarations by @MarkusJx in #35
Full Changelog: v2.1.6...v2.1.7
Release v2.1.6
What's Changed
- fix: method arguments not being parsed properly by @MarkusJx in #30
- fixed constructor arguments getting truncated
- fixed fields containing null values throwing errors
- fixed an issue where passing class instances representing primitives caused the method/constructor to not be found
- fixed public properties not being added to class instances
- made long return types always return bigint
Full Changelog: v2.1.5...v2.1.6
Release v2.1.5
What's Changed
Full Changelog: v2.1.4...v2.1.5
Release v2.1.5-beta.1
What's Changed
Full Changelog: v2.1.4...v2.1.5-beta.1
Release v2.1.4
What's Changed
- fix: class not found error when using Thread.getContextClassLoader by @MarkusJx in #23
- fix: improve imported class types by @MarkusJx in #24
Full Changelog: v2.1.3...v2.1.4
Release v2.1.3
Release v2.1.2
What's Changed
- Fixed a runtime error when calling the typescript definition generator
Full Changelog: v2.1.1...v2.1.2
Release v2.1.1
What's Changed
- Fixed an issue which caused the program execution to halt when multiple interface proxies are in use
Full Changelog: v2.1.0...v2.1.1