diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..afc342e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.DS_Store +*.iml +target +.idea +*.jfr +.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8449620 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +# Prepare environment +FROM fedora:latest +RUN dnf -y install file findutils unzip zip libXtst-devel libXt-devel libXrender-devel libXrandr-devel \ + libXi-devel cups-devel fontconfig-devel alsa-lib-devel make autoconf diffutils git clang \ + java-latest-openjdk-devel + +# Build panama-foreign openjdk +WORKDIR /home/build +RUN git clone https://github.com/openjdk/panama-foreign.git panama-foreign +WORKDIR /home/build/panama-foreign +RUN chmod +x configure +RUN ./configure --with-debug-level=fastdebug \ + --with-toolchain-type=clang \ + --with-vendor-name=jackalope \ + --enable-warnings-as-errors=no +RUN make images +ENV JAVA_HOME="/home/build/panama-foreign/build/linux-x86_64-server-fastdebug/images/jdk" + +# Prepare our own build environment +WORKDIR /home/build +RUN curl https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | tar -xz +ENV PATH=/home/build/apache-maven-3.6.3/bin:$PATH + +# Prepare a snapshot of Netty 5 +RUN git clone -b master https://github.com/netty/netty.git netty +WORKDIR /home/build/netty +RUN mvn install -DskipTests -T1C -B -am -pl buffer +WORKDIR /home/build + +# Prepare our own build +COPY pom.xml pom.xml +RUN mvn dependency:go-offline surefire:test -ntp + +# Copy over the project code and run our build +COPY . . +CMD mvn verify -o -B -C -T1C -fae -nsu -npu diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..45d0808 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +.PHONY: image test dbg clean build + +image: + docker build --tag netty-incubator-buffer:build . + +test: image + docker run --rm --name build-container netty-incubator-buffer:build + +dbg: + docker create --name build-container-dbg --entrypoint /bin/bash -t netty-incubator-buffer:build + docker start build-container-dbg + docker exec -it build-container-dbg bash + +clean: + docker rm -fv build-container-dbg + +build: image + docker create --name build-container netty-incubator-buffer:build + docker start -a build-container + docker wait build-container + docker cp build-container:/home/build/target . + docker rm build-container diff --git a/pom.xml b/pom.xml index 931d102..3fa799a 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,7 @@ 28 16 5.7.0 + 3.0.0-M5 false @@ -110,6 +111,10 @@ -Xlint:-options 256m 1024m + + --add-modules + jdk.incubator.foreign + **/package-info.java @@ -154,16 +159,77 @@ maven-surefire-plugin - 2.22.1 + ${surefire.version} **/*Test*.java random - ${argLine.common} ${argLine.printGC} ${argLine.java9} + ${argLine.common} ${argLine.printGC} ${argLine.java9} --add-modules jdk.incubator.foreign false + + + + org.codehaus.plexus + plexus-utils + 1.1 + + + org.apache.maven.surefire + surefire-junit-platform + ${surefire.version} + + + org.junit.jupiter + junit-jupiter-engine + 5.3.2 + pom + + + org.junit.jupiter + junit-jupiter-params + 5.3.2 + pom + + + org.mockito + mockito-core + 2.28.2 + pom + + + org.hamcrest + hamcrest-library + 1.3 + pom + + + junit + junit + 4.13 + pom + + + org.powermock + powermock-reflect + 2.0.5 + pom + + + org.assertj + assertj-core + 3.9.1 + pom + + + org.easytesting + fest-assert + 1.4 + pom + + @@ -270,20 +336,6 @@ - - maven-jar-plugin - 3.2.0 - - - default-jar - - - META-INF/native/** - - - - - diff --git a/src/main/java/io/netty/buffer/api/memseg/package-info.java b/src/main/java/io/netty/buffer/api/memseg/package-info.java new file mode 100644 index 0000000..429d64a --- /dev/null +++ b/src/main/java/io/netty/buffer/api/memseg/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2020 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * https://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. + */ + +/** + * Experimental {@code Buf} implementation, based on the MemorySegment API from OpenJDK Panama Foreign. + */ +package io.netty.buffer.api.memseg; diff --git a/src/main/java/io/netty/buffer/api/package-info.java b/src/main/java/io/netty/buffer/api/package-info.java index 20b2256..7ef007b 100644 --- a/src/main/java/io/netty/buffer/api/package-info.java +++ b/src/main/java/io/netty/buffer/api/package-info.java @@ -15,6 +15,6 @@ */ /** - * Experimental {@code Buf} implementation, based on MemorySegment, as a potential alternative to {@code ByteBuf}. + * Incubating {@code Buf} API, as a proposed alternative to {@code ByteBuf}. */ package io.netty.buffer.api; diff --git a/src/test/java/io/netty/buffer/api/BufTest.java b/src/test/java/io/netty/buffer/api/BufTest.java index 6ae13aa..ba95926 100644 --- a/src/test/java/io/netty/buffer/api/BufTest.java +++ b/src/test/java/io/netty/buffer/api/BufTest.java @@ -42,6 +42,11 @@ import java.util.function.Function; import java.util.stream.Stream; import java.util.stream.Stream.Builder; +import static io.netty.buffer.api.Fixture.Properties.CLEANER; +import static io.netty.buffer.api.Fixture.Properties.COMPOSITE; +import static io.netty.buffer.api.Fixture.Properties.DIRECT; +import static io.netty.buffer.api.Fixture.Properties.HEAP; +import static io.netty.buffer.api.Fixture.Properties.POOLED; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -86,12 +91,12 @@ public class BufTest { return Arrays.stream(fxs); } List initFixtures = List.of( - new Fixture("heap", Allocator::heap, Properties.HEAP), - new Fixture("direct", Allocator::direct, Properties.DIRECT), - new Fixture("directWithCleaner", Allocator::directWithCleaner, Properties.DIRECT, Properties.CLEANER), - new Fixture("pooledHeap", Allocator::pooledHeap, Properties.POOLED, Properties.HEAP), - new Fixture("pooledDirect", Allocator::pooledDirect, Properties.POOLED, Properties.DIRECT), - new Fixture("pooledDirectWithCleaner", Allocator::pooledDirectWithCleaner, Properties.POOLED, Properties.DIRECT, Properties.CLEANER)); + new Fixture("heap", Allocator::heap, HEAP), + new Fixture("direct", Allocator::direct, DIRECT), + new Fixture("directWithCleaner", Allocator::directWithCleaner, DIRECT, CLEANER), + new Fixture("pooledHeap", Allocator::pooledHeap, POOLED, HEAP), + new Fixture("pooledDirect", Allocator::pooledDirect, POOLED, DIRECT), + new Fixture("pooledDirectWithCleaner", Allocator::pooledDirectWithCleaner, POOLED, DIRECT, CLEANER)); Builder builder = Stream.builder(); initFixtures.forEach(builder); @@ -117,7 +122,7 @@ public class BufTest { b.close(); } }; - }, Properties.COMPOSITE)); + }, COMPOSITE)); } } @@ -140,7 +145,7 @@ public class BufTest { alloc.close(); } }; - }, Properties.COMPOSITE)); + }, COMPOSITE)); for (Fixture fixture : initFixtures) { builder.add(new Fixture(fixture + ".ensureWritable", () -> { @@ -180,7 +185,7 @@ public class BufTest { allocator.close(); } }; - }, Properties.COMPOSITE)); + }, COMPOSITE)); } return builder.build().flatMap(f -> {