You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/01/14 21:17:04 UTC
[avro] branch branch-1.11 updated: AVRO-3306: Java: Build failure with JDK 18+ (#1459)
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/branch-1.11 by this push:
new ed74ad9 AVRO-3306: Java: Build failure with JDK 18+ (#1459)
ed74ad9 is described below
commit ed74ad96676ee98372d660a902460aaabc30210d
Author: Martin Grigorov <ma...@users.noreply.github.com>
AuthorDate: Fri Jan 14 23:12:52 2022 +0200
AVRO-3306: Java: Build failure with JDK 18+ (#1459)
Ignore compilation warnings that member fields are not Serializable
Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
(cherry picked from commit 006f7c5ac462ab300747e367983a7223c4aa1365)
---
.github/workflows/test-lang-java.yml | 5 +++--
.../apache/avro/compiler/specific/SpecificCompiler.java | 2 +-
.../avro/compiler/specific/TestSpecificCompiler.java | 17 ++++++++++++++---
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/test-lang-java.yml b/.github/workflows/test-lang-java.yml
index 91a01f3..663f6f6 100644
--- a/.github/workflows/test-lang-java.yml
+++ b/.github/workflows/test-lang-java.yml
@@ -39,6 +39,7 @@ jobs:
- '8'
- '11'
- '17'
+ - '18-ea'
steps:
- uses: actions/checkout@v2
@@ -53,7 +54,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v2
with:
- distribution: 'adopt'
+ distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Lint
@@ -85,7 +86,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v2
with:
- distribution: 'adopt'
+ distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Setup Python for Generating Input Data
diff --git a/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java b/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
index 94fb0e2..b517cbc 100644
--- a/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
+++ b/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
@@ -857,7 +857,7 @@ public class SpecificCompiler {
/**
* Utility for template use. Returns the unboxed java type for a Schema.
*
- * @deprecated use javaUnbox(Schema, boolean), kept for backward compatibiliby
+ * @deprecated use javaUnbox(Schema, boolean), kept for backward compatibility
* of custom templates
*/
@Deprecated
diff --git a/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java b/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
index d789779..89d773e 100644
--- a/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
+++ b/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
@@ -43,6 +43,7 @@ import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import org.apache.avro.AvroTypeException;
+import java.util.Locale;
import java.util.Map;
import org.apache.avro.LogicalType;
@@ -66,6 +67,13 @@ import org.slf4j.LoggerFactory;
public class TestSpecificCompiler {
private static final Logger LOG = LoggerFactory.getLogger(TestSpecificCompiler.class);
+ /**
+ * JDK 18+ generates a warning for each member field which does not implement
+ * java.io.Serializable. Since Avro is an alternative serialization format, we
+ * can just ignore this warning.
+ */
+ private static final String NON_TRANSIENT_INSTANCE_FIELD_MESSAGE = "non-transient instance field of a serializable class declared with a non-serializable type";
+
@Rule
public TemporaryFolder OUTPUT_DIR = new TemporaryFolder();
@@ -107,13 +115,16 @@ public class TestSpecificCompiler {
DiagnosticListener<JavaFileObject> diagnosticListener = diagnostic -> {
switch (diagnostic.getKind()) {
case ERROR:
- // Do not add these to warnings because they will fail the compile, anyway.
+ // Do not add these to warnings because they will fail the compilation, anyway.
LOG.error("{}", diagnostic);
break;
case WARNING:
case MANDATORY_WARNING:
- LOG.warn("{}", diagnostic);
- warnings.add(diagnostic);
+ String message = diagnostic.getMessage(Locale.ROOT);
+ if (!NON_TRANSIENT_INSTANCE_FIELD_MESSAGE.equals(message)) {
+ LOG.warn("{}", diagnostic);
+ warnings.add(diagnostic);
+ }
break;
case NOTE:
case OTHER: