[Git][java-team/jnr-enxio][upstream] New upstream version 0.32.3
Louis-Philippe Véronneau
gitlab at salsa.debian.org
Wed Dec 30 20:11:10 GMT 2020
Louis-Philippe Véronneau pushed to branch upstream at Debian Java Maintainers / jnr-enxio
Commits:
34d54028 by Louis-Philippe Véronneau at 2020-12-30T14:39:42-05:00
New upstream version 0.32.3
- - - - -
9 changed files:
- + .github/workflows/ci.yml
- − .travis.yml
- pom.xml
- src/main/java/jnr/enxio/channels/KQSelector.java
- src/main/java/jnr/enxio/channels/Native.java
- src/main/java/jnr/enxio/channels/NativeDeviceChannel.java
- + src/main/java/jnr/enxio/channels/NativeFileSelectorProvider.java
- src/main/java/jnr/enxio/channels/PollSelector.java
- + src/main/java/jnr/enxio/channels/WinLibCAdapter.java
Changes:
=====================================
.github/workflows/ci.yml
=====================================
@@ -0,0 +1,37 @@
+# This workflow will build a Java project with Maven
+# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
+
+name: Java CI with Maven
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ jdk8:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout at v2
+ - name: Set up JDK 8
+ uses: actions/setup-java at v1.4.3
+ with:
+ java-version: 8
+ - name: Build with Maven
+ run: mvn -B package --file pom.xml
+
+ jdk11:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout at v2
+ - name: Set up JDK 11
+ uses: actions/setup-java at v1.4.3
+ with:
+ java-version: 11
+ - name: Build with Maven
+ run: mvn -B package --file pom.xml
=====================================
.travis.yml deleted
=====================================
@@ -1,15 +0,0 @@
-language: java
-jdk:
- - oraclejdk7
- - openjdk6
-os:
- - linux
-# - osx
-notifications:
- irc:
- channels:
- - "irc.freenode.org#jnr"
- on_success: change
- on_failure: always
- template:
- - "%{repository} (%{branch}:%{commit} by %{author}): %{message} (%{build_url})"
=====================================
pom.xml
=====================================
@@ -10,7 +10,7 @@
<groupId>com.github.jnr</groupId>
<artifactId>jnr-enxio</artifactId>
<packaging>jar</packaging>
- <version>0.16</version>
+ <version>0.32.3</version>
<name>jnr-enxio</name>
<description>Native I/O access for java</description>
<url>http://github.com/jnr/jnr-enxio</url>
@@ -39,26 +39,26 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>1.5</maven.compiler.source>
- <maven.compiler.target>1.5</maven.compiler.target>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.11</version>
+ <version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-constants</artifactId>
- <version>0.9.8</version>
+ <version>0.10.1</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
- <version>2.1.4</version>
+ <version>2.2.1</version>
</dependency>
</dependencies>
@@ -72,6 +72,7 @@
<instructions>
<_nouses>true</_nouses>
<Import-Package>*,jnr.ffi.mapper,jnr.ffi.provider.converters,com.kenai.jffi</Import-Package>
+ <Automatic-Module-Name>jnr.enxio</Automatic-Module-Name>
</instructions>
</configuration>
<executions>
@@ -91,6 +92,9 @@
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ <manifestEntries>
+ <Automatic-Module-Name>org.jnrproject.enxio</Automatic-Module-Name>
+ </manifestEntries>
</archive>
</configuration>
</plugin>
@@ -110,6 +114,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
+ <version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
@@ -119,26 +124,32 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.1</version>
+ </plugin>
</plugins>
</build>
<profiles>
-
<profile>
- <id>old-jdk</id>
+ <id>java9</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!-- Use -release compiler option rather than source/target if 9+ -->
+ <release>${maven.compiler.target}</release>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<activation>
- <jdk>(,1.6]</jdk>
+ <jdk>[9,)</jdk>
</activation>
-
- <dependencies>
- <dependency>
- <groupId>com.github.jnr</groupId>
- <artifactId>jnr-enxio-protocolfamily</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- </dependencies>
</profile>
</profiles>
</project>
=====================================
src/main/java/jnr/enxio/channels/KQSelector.java
=====================================
@@ -107,11 +107,8 @@ class KQSelector extends java.nio.channels.spi.AbstractSelector {
protected SelectionKey register(AbstractSelectableChannel ch, int ops, Object att) {
KQSelectionKey k = new KQSelectionKey(this, (NativeSelectableChannel) ch, ops);
synchronized (regLock) {
- Descriptor d = descriptors.get(k.getFD());
- if (d == null) {
- d = new Descriptor(k.getFD());
- descriptors.put(k.getFD(), d);
- }
+ Descriptor d = new Descriptor(k.getFD());
+ descriptors.put(k.getFD(), d);
d.keys.add(k);
handleChangedKey(d);
}
@@ -217,13 +214,13 @@ class KQSelector extends java.nio.channels.spi.AbstractSelector {
synchronized (regLock) {
for (SelectionKey k : cancelled) {
KQSelectionKey kqs = (KQSelectionKey) k;
- Descriptor d = descriptors.get(kqs.getFD());
deregister(kqs);
synchronized (selected) {
selected.remove(kqs);
}
- d.keys.remove(kqs);
- if (d.keys.isEmpty()) {
+ Descriptor d = descriptors.get(kqs.getFD());
+ if (d != null) d.keys.remove(kqs);
+ if (d == null || d.keys.isEmpty()) {
io.put(changebuf, nchanged++, kqs.getFD(), EVFILT_READ, EV_DELETE);
io.put(changebuf, nchanged++, kqs.getFD(), EVFILT_WRITE, EV_DELETE);
descriptors.remove(kqs.getFD());
=====================================
src/main/java/jnr/enxio/channels/Native.java
=====================================
@@ -19,7 +19,9 @@
package jnr.enxio.channels;
import jnr.constants.platform.Errno;
+import jnr.enxio.channels.WinLibCAdapter.LibMSVCRT;
import jnr.ffi.*;
+import jnr.ffi.Platform.OS;
import jnr.ffi.Runtime;
import jnr.ffi.annotations.IgnoreError;
import jnr.ffi.annotations.In;
@@ -32,7 +34,7 @@ import jnr.ffi.Platform;
import java.io.IOException;
import java.nio.ByteBuffer;
-final class Native {
+public final class Native {
public static interface LibC {
public static final int F_GETFL = jnr.constants.platform.Fcntl.F_GETFL.intValue();
@@ -62,8 +64,25 @@ final class Native {
}
private static final class SingletonHolder {
- static final LibC libc = LibraryLoader.create(LibC.class).load(Platform.getNativePlatform().getStandardCLibraryName());
- static final jnr.ffi.Runtime runtime = Runtime.getRuntime(libc);
+ static final LibC libc;
+ static final jnr.ffi.Runtime runtime;
+
+ static {
+ Platform platform = Platform.getNativePlatform();
+ LibraryLoader<LibC> loader = LibraryLoader.create(LibC.class);
+ loader.library(platform.getStandardCLibraryName());
+ if (platform.getOS() == OS.SOLARIS) {
+ loader.library("socket");
+ }
+ LibC straight = loader.load();
+ if (platform.getOS() == OS.WINDOWS) {
+ LibMSVCRT mslib = LibraryLoader.create(LibMSVCRT.class).load(platform.getStandardCLibraryName());
+ libc = new WinLibCAdapter(mslib);
+ } else {
+ libc = straight;
+ }
+ runtime = Runtime.getRuntime(libc);
+ }
}
static LibC libc() {
@@ -145,7 +164,7 @@ final class Native {
return libc().strerror(LastError.getLastError(getRuntime()));
}
- static Errno getLastError() {
+ public static Errno getLastError() {
return Errno.valueOf(LastError.getLastError(getRuntime()));
}
=====================================
src/main/java/jnr/enxio/channels/NativeDeviceChannel.java
=====================================
@@ -30,16 +30,27 @@ public class NativeDeviceChannel extends AbstractSelectableChannel implements By
private final int fd;
private final int validOps;
+ private final boolean isFile;
public NativeDeviceChannel(int fd) {
- this(NativeSelectorProvider.getInstance(), fd, SelectionKey.OP_READ | SelectionKey.OP_WRITE);
+ this(fd, false);
}
- public NativeDeviceChannel(SelectorProvider provider, int fd, int ops) {
+
+ public NativeDeviceChannel(int fd, boolean isFile) {
+ this(selectorProvider(isFile), fd, SelectionKey.OP_READ | SelectionKey.OP_WRITE, isFile);
+ }
+
+ public NativeDeviceChannel(SelectorProvider provider, int fd, int ops, boolean isFile) {
super(provider);
this.fd = fd;
this.validOps = ops;
+ this.isFile = isFile;
}
-
+
+ private static SelectorProvider selectorProvider(boolean isFile) {
+ return (isFile) ? NativeFileSelectorProvider.getInstance() : NativeSelectorProvider.getInstance();
+ }
+
@Override
protected void implCloseSelectableChannel() throws IOException {
int n = Native.close(fd);
=====================================
src/main/java/jnr/enxio/channels/NativeFileSelectorProvider.java
=====================================
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2008 Wayne Meissner
+ *
+ * This file is part of the JNR project.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jnr.enxio.channels;
+
+import jnr.ffi.Platform;
+
+import java.io.IOException;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.Pipe;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.nio.channels.spi.AbstractSelector;
+import java.nio.channels.spi.SelectorProvider;
+
+
+public final class NativeFileSelectorProvider extends SelectorProvider {
+ private static final class SingletonHolder {
+ static NativeFileSelectorProvider INSTANCE = new NativeFileSelectorProvider();
+ }
+
+ public static final SelectorProvider getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+ @Override
+ public DatagramChannel openDatagramChannel() throws IOException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public DatagramChannel openDatagramChannel(java.net.ProtocolFamily family) throws IOException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Pipe openPipe() throws IOException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public AbstractSelector openSelector() throws IOException {
+ return new PollSelector(this);
+ }
+
+ @Override
+ public ServerSocketChannel openServerSocketChannel() throws IOException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SocketChannel openSocketChannel() throws IOException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
=====================================
src/main/java/jnr/enxio/channels/PollSelector.java
=====================================
@@ -116,7 +116,7 @@ class PollSelector extends java.nio.channels.spi.AbstractSelector {
@Override
public Set<SelectionKey> keys() {
- return new HashSet<SelectionKey>(Arrays.asList(keyArray).subList(0, nfds));
+ return new HashSet<SelectionKey>(Arrays.asList(keyArray).subList(1, nfds));
}
@Override
=====================================
src/main/java/jnr/enxio/channels/WinLibCAdapter.java
=====================================
@@ -0,0 +1,117 @@
+/*
+ * This file is part of the JNR project.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jnr.enxio.channels;
+
+import java.nio.ByteBuffer;
+
+import jnr.enxio.channels.Native.LibC;
+import jnr.enxio.channels.Native.Timespec;
+import jnr.ffi.Pointer;
+import jnr.ffi.Runtime;
+import jnr.ffi.annotations.IgnoreError;
+import jnr.ffi.annotations.In;
+import jnr.ffi.annotations.Out;
+import jnr.ffi.provider.LoadedLibrary;
+import jnr.ffi.types.size_t;
+import jnr.ffi.types.ssize_t;
+
+/**
+ * MSVCRT.DLL only supports some LibC functions, but the symbols are different.
+ * This adapter maps the MSVCRT.DLL names to standard LibC names
+ */
+public final class WinLibCAdapter implements LibC, LoadedLibrary {
+
+ public static interface LibMSVCRT {
+
+ public int _close(int fd);
+ public @ssize_t int _read(int fd, @Out ByteBuffer data, @size_t long size);
+ public @ssize_t int _read(int fd, @Out byte[] data, @size_t long size);
+ public @ssize_t int _write(int fd, @In ByteBuffer data, @size_t long size);
+ public @ssize_t int _write(int fd, @In byte[] data, @size_t long size);
+ public int _pipe(@Out int[] fds);
+
+ @IgnoreError String _strerror(int error);
+
+ // These functions don't exist:
+
+ //public int shutdown(int s, int how);
+ //public int fcntl(int fd, int cmd, int data);
+ //public int poll(@In @Out ByteBuffer pfds, int nfds, int timeout);
+ //public int poll(@In @Out Pointer pfds, int nfds, int timeout);
+ //public int kqueue();
+ //public int kevent(int kq, @In ByteBuffer changebuf, int nchanges,
+ // @Out ByteBuffer eventbuf, int nevents,
+ // @In @Transient Timespec timeout);
+ //public int kevent(int kq,
+ // @In Pointer changebuf, int nchanges,
+ // @Out Pointer eventbuf, int nevents,
+ // @In @Transient Timespec timeout);
+ }
+
+ private LibMSVCRT win;
+ public WinLibCAdapter(LibMSVCRT winlibc) { this.win = winlibc; }
+
+ @Override public int close(int fd) { return win._close(fd); }
+ @Override public int read(int fd, ByteBuffer data, long size) { return win._read(fd, data, size); }
+ @Override public int read(int fd, byte[] data, long size) { return win._read(fd, data, size); }
+ @Override public int write(int fd, ByteBuffer data, long size) { return win._write(fd, data, size); }
+ @Override public int write(int fd, byte[] data, long size) { return win._write(fd, data, size); }
+ @Override public int pipe(int[] fds) { return win._pipe(fds); }
+ @Override public String strerror(int error) { return win._strerror(error); }
+
+ @Override
+ public Runtime getRuntime() {
+ return Runtime.getRuntime(win);
+ }
+
+ // Unsupported Operations. Some may be implementable, others like fcntl may not be.
+
+ @Override
+ public int fcntl(int fd, int cmd, int data) {
+ throw new UnsupportedOperationException("fcntl isn't supported on Windows");
+ }
+
+ @Override
+ public int poll(ByteBuffer pfds, int nfds, int timeout) {
+ throw new UnsupportedOperationException("poll isn't supported on Windows");
+ }
+
+ @Override
+ public int poll(Pointer pfds, int nfds, int timeout) {
+ throw new UnsupportedOperationException("poll isn't supported on Windows");
+ }
+
+ @Override
+ public int kqueue() {
+ throw new UnsupportedOperationException("kqueue isn't supported on Windows");
+ }
+
+ @Override
+ public int kevent(int kq, ByteBuffer changebuf, int nchanges, ByteBuffer eventbuf, int nevents, Timespec timeout) {
+ throw new UnsupportedOperationException("kevent isn't supported on Windows");
+ }
+
+ @Override
+ public int kevent(int kq, Pointer changebuf, int nchanges, Pointer eventbuf, int nevents, Timespec timeout) {
+ throw new UnsupportedOperationException("kevent isn't supported on Windows");
+ }
+
+ @Override
+ public int shutdown(int s, int how) {
+ throw new UnsupportedOperationException("shutdown isn't supported on Windows");
+ }
+}
\ No newline at end of file
View it on GitLab: https://salsa.debian.org/java-team/jnr-enxio/-/commit/34d54028177f3cd42397fd7bf92e74af89868241
--
View it on GitLab: https://salsa.debian.org/java-team/jnr-enxio/-/commit/34d54028177f3cd42397fd7bf92e74af89868241
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20201230/e7806f34/attachment.html>
More information about the pkg-java-commits
mailing list