BridJ is an innovative native bindings library that lets Java programmers use native libraries (written in C, C++, ObjectiveC and more) in a very natural way (inspired by the great JNA, with better performance, C++ and generics added).

Here’s a summary of the changes between version 0.5 and this new version 0.6 (see full change log here) :

  • Added errno/GetLastError() mechanism : declare methods to throw org.bridj.LastError and it’s all handled automatically (issue #74)
  • Added protected mode (-Dbridj.protected=true / BRIDJ_PROTECTED=1), to prevent native crashes (makes BridJ bindings slower + disables optimized raw calls).
  • Added proxy-based Objective-C delegates support (forwards unknown methods to a Java instance) (issue #188)
  • Added Objective-C 2.0 blocks support (similar to callbacks, inherit from ObjCBlock instead of Callback) (issue #192)
  • Added Pointer.asList() and .asList(ListType) to get a List view of the pointed memory
    • depending on the ListType, the view can be mutable / resizeable
    • removed the List interface from Pointer (which is now just an Iterable)
    • added Pointer.allocateList(type, capacity) to create a NativeList from scratch (has a .getPointer method to grab the resulting memory at the end)
  • Added Pointer.moveBytesTo(Pointer)
  • Added support for embedded libraries extraction from “lib/arch” paths (along with “org/bridj/lib/arch”, where arch uses BridJ’s convention)
  • Added TimeT (time_t), timeval classes (issue #72)
  • Added Platform.getMachine() (same result as `uname -m`)
  • Added support for multiarch Linux distributions (issue #2)
  • Added support for versioned library file names (issue #72)
  • Added global allocated memory alignment setting (BRIDJ_DEFAULT_ALIGNMENT env. var. & bridj.defaultAlignment property), + Pointer.allocateAlignedArray
  • Added basic calls log mechanism (disables direct mode) : -Dbridj.logCalls=true or BRIDJ_LOG_CALLS=1 (only logs the method name & signature, not the arguments or returned values)
  • Added BridJ.setMinLogLevel(Level) (issue #190)
  • Added Platform.addEmbeddedLibraryResourceRoot(root) to use & customize the embedded library extraction feature in user projects
  • Added support for packed structs (@Struct(pack = 1), or any other pack value)
  • Added check of BridJ environment variables and Java properties : if any BRIDJ_* env. var. or bridj.* property does not exist, it will log warnings + full list of valid options
  • Added @JNIBound annotation to mark native methods that should not be bound by BridJ but by plain old JNI
  • Fixed Pointer.next/.offset methods (used to throw errors a the end of iteration)
  • Fixed Pointer.getNativeObjectAtOffset(long byteOffset, Type type)
  • Fixed struct fields implemented as Java fields
  • Fixed resolution of MacOS X “ApplicationServices” framework binaries, such as CoreGraphics
  • Fixed some COM bugs with IUnknown
  • Fixed demangling/matching of CLong & SizeT
  • Fixed CLong & SizeT arguments
  • Fixed Objective-C runtime (basic features), added NSString constructor & NSDictionary (with conversion to/from Map<NSString, NSObject>)
  • Fixed crashes on Win32 (when using Pointer class in bound function arguments)
  • Fixed crash during deallocation of Callbacks + fixed leak of Callbacks (now need to retain a reference to callbacks or use BridJ.protectFromGC / unprotectFromGC)
  • Made the StructIO customization mechanism more flexible
  • Made JawtLibrary public
  • Various Javadoc tweaks

Special thanks to the users, contributors and bug reporters that helped getting this version out !

You can contribute to the project by reporting bugs here and joining the NativeLibs4Java Community.

Wait no longer : download and use BridJ now !