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 07:28:23 UTC

[avro] branch avro-3306-fix-build-with-jdk18 created (now 0cb2a77)

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a change to branch avro-3306-fix-build-with-jdk18
in repository https://gitbox.apache.org/repos/asf/avro.git.


      at 0cb2a77  AVRO-3306: Java: Build failure with JDK 18+

This branch includes the following new commits:

     new 0cb2a77  AVRO-3306: Java: Build failure with JDK 18+

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[avro] 01/01: AVRO-3306: Java: Build failure with JDK 18+

Posted by mg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch avro-3306-fix-build-with-jdk18
in repository https://gitbox.apache.org/repos/asf/avro.git

commit 0cb2a7790e8d6ece00ef03db96737c598b2df0bf
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Fri Jan 14 09:26:41 2022 +0200

    AVRO-3306: Java: Build failure with JDK 18+
    
    Ignore compilation warnings that member fields are not Serializable
    
    Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
 .github/workflows/test-lang-java.yml                    |  1 +
 .../apache/avro/compiler/specific/SpecificCompiler.java |  2 +-
 .../avro/compiler/specific/TestSpecificCompiler.java    | 17 ++++++++++++++---
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/test-lang-java.yml b/.github/workflows/test-lang-java.yml
index 91a01f3..2cadc1c 100644
--- a/.github/workflows/test-lang-java.yml
+++ b/.github/workflows/test-lang-java.yml
@@ -39,6 +39,7 @@ jobs:
         - '8'
         - '11'
         - '17'
+        - '19-ea'
     steps:
       - uses: actions/checkout@v2
 
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: