Skip to content

Commit f7e8b78

Browse files
committed
Update README
1 parent b885b59 commit f7e8b78

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Java Does USB: USB Library for Java
22

3-
> **Development branch for JDK 20**
4-
53
[![javadoc](https://javadoc.io/badge2/net.codecrete.usb/java-does-usb/javadoc.svg)](https://javadoc.io/doc/net.codecrete.usb/java-does-usb)
64

7-
*Java Does USB* is a library for working with USB devices. It allows to query information about all conntected USB devices and to communicate with USB devices using custom / vendor specific protocols. (It is not intended for communication with standard types of USB devices such as mass storage devices, keyboards etc.)
5+
*Java Does USB* is a Java library for working with USB devices. It allows to query information about all conntected USB devices and to communicate with USB devices using custom / vendor specific protocols. (It is not intended for communication with standard types of USB devices such as mass storage devices, keyboards etc.)
6+
7+
The library uses the [Foreign Function & Memory API](https://github.com/openjdk/panama-foreign) to access native APIs of the underlying operating system. It only uses Java code and does not need JNI or any native third-party library. The *Foreign Function & Memory API* (aka as project Panama) is in preview and will be introduced in a future Java version. Currently, it can be used with Java 19 or Java 20 (with preview features enabled).
88

9-
The library uses the [Foreign Function & Memory API](https://github.com/openjdk/panama-foreign) to access native APIs of the underlying operating system. It only uses Java code and does not need JNI or any native third-party library. The *Foreign Function & Memory API* (aka as project Panama) is in preview and will be introduced in a future Java version. Currently, it can be used with Java 19 (with preview features enabled).
9+
*Note: The main branch and published versions ≥ 0.5.0 work with JDK 20 only. For JDK 19, use version 0.4.x.*
1010

1111

1212
## Features
@@ -16,12 +16,12 @@ The library uses the [Foreign Function & Memory API](https://github.com/openjdk/
1616
- Control, bulk and interrupt transfers (optionally with timeout)
1717
- Notifications about connected/disconnected devices
1818
- Descriptive information about interfaces, settings and endpoints
19+
- High-throughput input/output streams
1920
- Support for alternate interface settings, composite devices and interface association
2021
- Published on Maven Central
2122

2223
### Planned
2324

24-
- High-throughput input/output streams
2525
- Isochronous transfer
2626

2727
### Not planned
@@ -41,7 +41,7 @@ If you are using Maven, add the below dependency to your pom.xml:
4141
<dependency>
4242
<groupId>net.codecrete.usb</groupId>
4343
<artifactId>java-does-usb</artifactId>
44-
<version>0.4.1</version>
44+
<version>0.5.0</version>
4545
</dependency>
4646
```
4747

@@ -85,7 +85,7 @@ public class EnumerateDevices {
8585
- Java 20, preview features enabled (available at https://www.azul.com/downloads/?package=jdk)
8686
- Windows (x86 64-bit), macOS (x86 64-bit, ARM 64-bit) or Linux 64 bit (x86 64-bit, ARM 64-bit)
8787

88-
For a version compatible with JDK 20, see the branch `jdk20`.
88+
For JDK 19, use the latest published version 0.4.x.
8989

9090

9191
## Platform-specific Considerations
@@ -126,7 +126,7 @@ The library has not been tested on Windows for ARM64. It might or might not work
126126

127127
### 32-bit versions
128128

129-
The Foreign Function & Memory API has not been implemented for 32-bit operating systems / JDKs. So it does not support them (and likely never will).
129+
The Foreign Function & Memory API has not been implemented for 32-bit operating systems / JDKs (and likely never will be).
130130

131131

132132

java-does-usb/jextract/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ The resulting code is then committed to the source code repository. Before the c
1313

1414
## General limitations
1515

16-
- Binaries of *jextract* can be downloaded from https://jdk.java.net/jextract/. x64 binaries are available but no ARM64 binaries. According to the mailing list, cross-compiling is not possible, i.e. ARM64 binaries are needed on macOS with Apple Silicon. But so far, the x64 binaries (using the Rosetta2 emulation) have worked without problems.
16+
- The binaries for *jextract* on https://jdk.java.net/jextract/ have not been updated for JDK 20. So it must be built from source. Instructions can be found at [Building & Testing](https://github.com/openjdk/jextract#building--testing).
17+
18+
- According to the jextract mailing list, it would be required to create separate code form Intel x64 and ARM64 architecture. And jextract would need to be run on each architecture separately (no cross-compilation). Fortunately, this doesn't seem to be the case. Linux code generated on Intel x64 also runs on ARM64 without change. The same holds for macOS. However, jextract needs to be run on each operating system separately.
19+
20+
- JDK 20 introduced a new feature for saving the thread-specific error values (`GetLastError()` on Windows, `errno` on Linux). To use it, an additional parameter must be added to function calls. Unfortuntely, this is not yet supported by jextract. So with the JDK 20 updates, more code is written manually and less is generated by jextract.
1721

1822
- `typedef` and `struct`:
1923

@@ -64,7 +68,7 @@ SymbolLookup loaderLookup = SymbolLookup.libraryLookup("libudev.so", MemorySessi
6468

6569
## MacOS
6670

67-
Most of the required native functions on macOS are part of a framework. Framework internally have a more complex file organization of header and binary files than appears on the outside. Thus they require a special logic to locate framework header files. *clang* supports it with the `-F`. *jextract* allows to specify the options via `compiler_flags.txt` file. Since the file must be in the local directory and since it does not apply to Linux and Windows, separate directories must be used for the operating systems.
71+
Most of the required native functions on macOS are part of a framework. Frameworks internally have a more complex file organization of header and binary files than appears from the outside. Thus they require a special logic to locate framework header files. *clang* supports it with the `-F`. *jextract* allows to specify the options via `compiler_flags.txt` file. Since the file must be in the local directory and since it does not apply to Linux and Windows, separate directories must be used for the operating systems.
6872

6973
The generated code has the same problem as the Linux code for *udev*. It must be manually changed to use `SymbolLookup.libraryLookup()` for the libraries `CoreFoundation.framework/CoreFoundation` and `IOKit.framework/IOKit` respectively.
7074

@@ -73,6 +77,8 @@ The generated code has the same problem as the Linux code for *udev*. It must be
7377

7478
Most Windows SDK header files are not independent. They require that `Windows.h` is included first. So instead of specifying the target header files directly, a helper header file (`windows_headers.h` in this directory) is specified.
7579

80+
Compared to Linux and macOS, the code generation on Windows is very slow (about 1 min vs 3 seconds). And jextract crashes sometimes.
81+
7682
The known limitations are:
7783

7884
- Variable size `struct`: Several Windows struct are of variable size. The last member is an array. The `struct` definition specifies array length 1. But you are expected to allocate more space depending on the actual array size you need. *jextract* generates code for array length 1 and when access array members, the length is checked. So the generated code is difficult to use. Variable size `struct`s are a pain - in any language.

0 commit comments

Comments
 (0)