diff --git a/lang/java/avro/src/main/java/org/apache/avro/specific/AvroInternal.java b/lang/java/avro/src/main/java/org/apache/avro/specific/AvroInternal.java new file mode 100644 index 00000000000..c71f689b456 --- /dev/null +++ b/lang/java/avro/src/main/java/org/apache/avro/specific/AvroInternal.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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. + */ +package org.apache.avro.specific; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Indicates that an annotated accessor is part of the Avro API of a class, not + * part of a schema, and should be ignored when introspecting @AvroGenerated + * classes. + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface AvroInternal { +} diff --git a/lang/java/avro/src/test/java/org/apache/avro/FooBarSpecificRecord.java b/lang/java/avro/src/test/java/org/apache/avro/FooBarSpecificRecord.java index 7c2d5c57339..2df56c4132a 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/FooBarSpecificRecord.java +++ b/lang/java/avro/src/test/java/org/apache/avro/FooBarSpecificRecord.java @@ -124,6 +124,7 @@ public FooBarSpecificRecord(java.lang.Integer id, java.lang.String name, java.ut } @Override + @org.apache.avro.specific.AvroInternal public org.apache.avro.Schema getSchema() { return SCHEMA$; } diff --git a/lang/java/avro/src/test/java/org/apache/avro/TypeEnum.java b/lang/java/avro/src/test/java/org/apache/avro/TypeEnum.java index 0d9617bfc00..13bb23af2c6 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/TypeEnum.java +++ b/lang/java/avro/src/test/java/org/apache/avro/TypeEnum.java @@ -33,6 +33,7 @@ public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + @org.apache.avro.specific.AvroInternal public org.apache.avro.Schema getSchema() { return SCHEMA$; } diff --git a/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithLogicalTypes.java b/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithLogicalTypes.java index 1763a73144c..8e036971581 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithLogicalTypes.java +++ b/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithLogicalTypes.java @@ -133,6 +133,7 @@ public TestRecordWithLogicalTypes(java.lang.Boolean b, java.lang.Integer i32, ja } @Override + @org.apache.avro.specific.AvroInternal public org.apache.avro.Schema getSchema() { return SCHEMA$; } diff --git a/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithMapsAndArrays.java b/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithMapsAndArrays.java index 81572bc22c5..836425e6d42 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithMapsAndArrays.java +++ b/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithMapsAndArrays.java @@ -45,7 +45,7 @@ public static org.apache.avro.Schema getClassSchema() { /** * Return the BinaryMessageEncoder instance used by this class. - * + * * @return the message encoder used by this class */ public static BinaryMessageEncoder getEncoder() { @@ -54,7 +54,7 @@ public static BinaryMessageEncoder getEncoder() { /** * Return the BinaryMessageDecoder instance used by this class. - * + * * @return the message decoder used by this class */ public static BinaryMessageDecoder getDecoder() { @@ -64,7 +64,7 @@ public static BinaryMessageDecoder getDecoder() { /** * Create a new BinaryMessageDecoder instance for this class that uses the * specified {@link SchemaStore}. - * + * * @param resolver a {@link SchemaStore} used to find schemas by fingerprint * @return a BinaryMessageDecoder instance for this class backed by the given * SchemaStore @@ -75,7 +75,7 @@ public static BinaryMessageDecoder createDecoder(Sc /** * Serializes this TestRecordWithMapsAndArrays to a ByteBuffer. - * + * * @return a buffer holding the serialized data for this instance * @throws java.io.IOException if this instance could not be serialized */ @@ -85,7 +85,7 @@ public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { /** * Deserializes a TestRecordWithMapsAndArrays from a ByteBuffer. - * + * * @param b a byte buffer holding serialized data for an instance of this class * @return a TestRecordWithMapsAndArrays instance decoded from the given buffer * @throws java.io.IOException if the given bytes could not be deserialized into @@ -110,7 +110,7 @@ public TestRecordWithMapsAndArrays() { /** * All-args constructor. - * + * * @param arr The new value for arr * @param map The new value for map * @param nested_arr The new value for nested_arr @@ -126,11 +126,13 @@ public TestRecordWithMapsAndArrays(java.util.List arr, java.util.Map getArr() { @@ -185,7 +187,7 @@ public java.util.List getArr() { /** * Sets the value of the 'arr' field. - * + * * @param value the value to set. */ public void setArr(java.util.List value) { @@ -194,7 +196,7 @@ public void setArr(java.util.List value) { /** * Gets the value of the 'map' field. - * + * * @return The value of the 'map' field. */ public java.util.Map getMap() { @@ -203,7 +205,7 @@ public java.util.Map getMap() { /** * Sets the value of the 'map' field. - * + * * @param value the value to set. */ public void setMap(java.util.Map value) { @@ -212,7 +214,7 @@ public void setMap(java.util.Map value) { /** * Gets the value of the 'nested_arr' field. - * + * * @return The value of the 'nested_arr' field. */ public java.util.List> getNestedArr() { @@ -221,7 +223,7 @@ public java.util.List> getNestedArr() { /** * Sets the value of the 'nested_arr' field. - * + * * @param value the value to set. */ public void setNestedArr(java.util.List> value) { @@ -230,7 +232,7 @@ public void setNestedArr(java.util.List> value) { /** * Gets the value of the 'nested_map' field. - * + * * @return The value of the 'nested_map' field. */ public java.util.Map> getNestedMap() { @@ -239,7 +241,7 @@ public java.util.Map> getNestedMap() { /** * Sets the value of the 'nested_map' field. - * + * * @param value the value to set. */ public void setNestedMap(java.util.Map> value) { @@ -248,7 +250,7 @@ public void setNestedMap(java.util.Map> valu /** * Creates a new TestRecordWithMapsAndArrays RecordBuilder. - * + * * @return A new TestRecordWithMapsAndArrays RecordBuilder */ public static Builder newBuilder() { @@ -258,7 +260,7 @@ public static Builder newBuilder() { /** * Creates a new TestRecordWithMapsAndArrays RecordBuilder by copying an * existing Builder. - * + * * @param other The existing builder to copy. * @return A new TestRecordWithMapsAndArrays RecordBuilder */ @@ -273,7 +275,7 @@ public static Builder newBuilder(Builder other) { /** * Creates a new TestRecordWithMapsAndArrays RecordBuilder by copying an * existing TestRecordWithMapsAndArrays instance. - * + * * @param other The existing instance to copy. * @return A new TestRecordWithMapsAndArrays RecordBuilder */ @@ -304,7 +306,7 @@ private Builder() { /** * Creates a Builder by copying an existing Builder. - * + * * @param other The existing Builder to copy. */ private Builder(Builder other) { @@ -329,7 +331,7 @@ private Builder(Builder other) { /** * Creates a Builder by copying an existing TestRecordWithMapsAndArrays instance - * + * * @param other The existing instance to copy. */ private Builder(TestRecordWithMapsAndArrays other) { @@ -354,7 +356,7 @@ private Builder(TestRecordWithMapsAndArrays other) { /** * Gets the value of the 'arr' field. - * + * * @return The value. */ public java.util.List getArr() { @@ -363,7 +365,7 @@ public java.util.List getArr() { /** * Sets the value of the 'arr' field. - * + * * @param value The value of 'arr'. * @return This builder. */ @@ -376,7 +378,7 @@ public Builder setArr(java.util.List value) { /** * Checks whether the 'arr' field has been set. - * + * * @return True if the 'arr' field has been set, false otherwise. */ public boolean hasArr() { @@ -385,7 +387,7 @@ public boolean hasArr() { /** * Clears the value of the 'arr' field. - * + * * @return This builder. */ public Builder clearArr() { @@ -396,7 +398,7 @@ public Builder clearArr() { /** * Gets the value of the 'map' field. - * + * * @return The value. */ public java.util.Map getMap() { @@ -405,7 +407,7 @@ public java.util.Map getMap() { /** * Sets the value of the 'map' field. - * + * * @param value The value of 'map'. * @return This builder. */ @@ -418,7 +420,7 @@ public Builder setMap(java.util.Map value) { /** * Checks whether the 'map' field has been set. - * + * * @return True if the 'map' field has been set, false otherwise. */ public boolean hasMap() { @@ -427,7 +429,7 @@ public boolean hasMap() { /** * Clears the value of the 'map' field. - * + * * @return This builder. */ public Builder clearMap() { @@ -438,7 +440,7 @@ public Builder clearMap() { /** * Gets the value of the 'nested_arr' field. - * + * * @return The value. */ public java.util.List> getNestedArr() { @@ -447,7 +449,7 @@ public java.util.List> getNestedArr() { /** * Sets the value of the 'nested_arr' field. - * + * * @param value The value of 'nested_arr'. * @return This builder. */ @@ -460,7 +462,7 @@ public Builder setNestedArr(java.util.List> value) { /** * Checks whether the 'nested_arr' field has been set. - * + * * @return True if the 'nested_arr' field has been set, false otherwise. */ public boolean hasNestedArr() { @@ -469,7 +471,7 @@ public boolean hasNestedArr() { /** * Clears the value of the 'nested_arr' field. - * + * * @return This builder. */ public Builder clearNestedArr() { @@ -480,7 +482,7 @@ public Builder clearNestedArr() { /** * Gets the value of the 'nested_map' field. - * + * * @return The value. */ public java.util.Map> getNestedMap() { @@ -489,7 +491,7 @@ public java.util.Map> getNestedMap() { /** * Sets the value of the 'nested_map' field. - * + * * @param value The value of 'nested_map'. * @return This builder. */ @@ -502,7 +504,7 @@ public Builder setNestedMap(java.util.Map> v /** * Checks whether the 'nested_map' field has been set. - * + * * @return True if the 'nested_map' field has been set, false otherwise. */ public boolean hasNestedMap() { @@ -511,7 +513,7 @@ public boolean hasNestedMap() { /** * Clears the value of the 'nested_map' field. - * + * * @return This builder. */ public Builder clearNestedMap() { diff --git a/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithoutLogicalTypes.java b/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithoutLogicalTypes.java index f53f1537ffd..2413dccff75 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithoutLogicalTypes.java +++ b/lang/java/avro/src/test/java/org/apache/avro/specific/TestRecordWithoutLogicalTypes.java @@ -76,6 +76,7 @@ public TestRecordWithoutLogicalTypes(java.lang.Boolean b, java.lang.Integer i32, this.dec = dec; } + @org.apache.avro.specific.AvroInternal public org.apache.avro.Schema getSchema() { return SCHEMA$; } diff --git a/lang/java/avro/src/test/java/org/apache/avro/specific/TestUnionRecord.java b/lang/java/avro/src/test/java/org/apache/avro/specific/TestUnionRecord.java index 57c86a96ffc..758e342e966 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/specific/TestUnionRecord.java +++ b/lang/java/avro/src/test/java/org/apache/avro/specific/TestUnionRecord.java @@ -117,11 +117,13 @@ public TestUnionRecord(java.math.BigDecimal amount) { } @Override + @org.apache.avro.specific.AvroInternal public SpecificData getSpecificData() { return MODEL$; } @Override + @org.apache.avro.specific.AvroInternal public org.apache.avro.Schema getSchema() { return SCHEMA$; } diff --git a/lang/java/avro/src/test/java/org/apache/avro/specific/int$.java b/lang/java/avro/src/test/java/org/apache/avro/specific/int$.java index 586d4219124..6e8d7240d10 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/specific/int$.java +++ b/lang/java/avro/src/test/java/org/apache/avro/specific/int$.java @@ -28,7 +28,7 @@ public static org.apache.avro.Schema getClassSchema() { /** * Return the BinaryMessageEncoder instance used by this class. - * + * * @return the message encoder used by this class */ public static BinaryMessageEncoder getEncoder() { @@ -37,7 +37,7 @@ public static org.apache.avro.Schema getClassSchema() { /** * Return the BinaryMessageDecoder instance used by this class. - * + * * @return the message decoder used by this class */ public static BinaryMessageDecoder getDecoder() { @@ -47,7 +47,7 @@ public static org.apache.avro.Schema getClassSchema() { /** * Create a new BinaryMessageDecoder instance for this class that uses the * specified {@link SchemaStore}. - * + * * @param resolver a {@link SchemaStore} used to find schemas by fingerprint * @return a BinaryMessageDecoder instance for this class backed by the given * SchemaStore @@ -58,7 +58,7 @@ public static org.apache.avro.Schema getClassSchema() { /** * Serializes this int to a ByteBuffer. - * + * * @return a buffer holding the serialized data for this instance * @throws java.io.IOException if this instance could not be serialized */ @@ -68,7 +68,7 @@ public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { /** * Deserializes a int from a ByteBuffer. - * + * * @param b a byte buffer holding serialized data for an instance of this class * @return a int instance decoded from the given buffer * @throws java.io.IOException if the given bytes could not be deserialized into @@ -78,10 +78,12 @@ public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { return DECODER.decode(b); } + @org.apache.avro.specific.AvroInternal public SpecificData getSpecificData() { return MODEL$; } + @org.apache.avro.specific.AvroInternal public org.apache.avro.Schema getSchema() { return SCHEMA$; } @@ -105,7 +107,7 @@ public void put(int field$, Object value$) { /** * Creates a new int$ RecordBuilder. - * + * * @return A new int$ RecordBuilder */ public static Builder newBuilder() { @@ -114,7 +116,7 @@ public static Builder newBuilder() { /** * Creates a new int$ RecordBuilder by copying an existing Builder. - * + * * @param other The existing builder to copy. * @return A new int$ RecordBuilder */ @@ -128,7 +130,7 @@ public static Builder newBuilder(Builder other) { /** * Creates a new int$ RecordBuilder by copying an existing int$ instance. - * + * * @param other The existing instance to copy. * @return A new int$ RecordBuilder */ @@ -154,7 +156,7 @@ private Builder() { /** * Creates a Builder by copying an existing Builder. - * + * * @param other The existing Builder to copy. */ private Builder(Builder other) { @@ -163,7 +165,7 @@ private Builder(Builder other) { /** * Creates a Builder by copying an existing int$ instance - * + * * @param other The existing instance to copy. */ private Builder(int$ other) { diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm index c15b7ecd124..136180a7e93 100644 --- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm +++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm @@ -32,5 +32,6 @@ public enum ${this.mangleTypeIdentifier($schema.getName())} implements org.apach public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } @Override + @org.apache.avro.specific.AvroInternal public org.apache.avro.Schema getSchema() { return SCHEMA$; } } diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/fixed.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/fixed.vm index dbbef6ffb12..e73f7f34a86 100644 --- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/fixed.vm +++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/fixed.vm @@ -30,6 +30,7 @@ public class ${this.mangleTypeIdentifier($schema.getName())} extends org.apache. private static final long serialVersionUID = ${this.fingerprint64($schema)}L; public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("${this.javaEscape($schema.toString())}"); public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } + @org.apache.avro.specific.AvroInternal public org.apache.avro.Schema getSchema() { return SCHEMA$; } /** Creates a new ${this.mangleTypeIdentifier($schema.getName())} */ diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm index ec1e6c3ca7a..2e0ec7ce6ae 100755 --- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm +++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm @@ -177,9 +177,11 @@ public class ${this.mangleTypeIdentifier($schema.getName())} extends ${this.getS #end @Override + @org.apache.avro.specific.AvroInternal public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } @Override + @org.apache.avro.specific.AvroInternal public org.apache.avro.Schema getSchema() { return SCHEMA$; } // Used by DatumWriter. Applications should not call. diff --git a/lang/java/tools/src/test/compiler/output-string/Position.java b/lang/java/tools/src/test/compiler/output-string/Position.java index a4504bbc4c9..4df5b24b1ec 100644 --- a/lang/java/tools/src/test/compiler/output-string/Position.java +++ b/lang/java/tools/src/test/compiler/output-string/Position.java @@ -9,5 +9,6 @@ public enum Position implements org.apache.avro.generic.GenericEnumSymbol