Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.10.2
Description
Java 14 introduced 'record' as a restricted type name and cannot be used for type declarations. So Avro should not generate code that uses this in its name for example classes based on a schema with name 'record'. It is probably a good idea that we reject uses of Java keywords including reserved identifiers.
This can be reproduced easily in Avro's current codebase running the `TestSpecificCompiler` test with JDK 16.
public class record extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
^
as of release 14, 'record' is a restricted type name and cannot be used for type declarations
[main] ERROR org.apache.avro.compiler.specific.TestSpecificCompiler - /tmp/junit6626196665903310578/testInvalidParameterCounts1/sample/record.java:23: error: 'record' is not allowed here
private static final BinaryMessageEncoder<record> ENCODER =
^
[main] ERROR org.apache.avro.compiler.specific.TestSpecificCompiler - /tmp/junit6626196665903310578/testInvalidParameterCounts1/sample/record.java:24: error: 'record' is not allowed here
new BinaryMessageEncoder<record>(MODEL$, SCHEMA$);
^
[main] ERROR org.apache.avro.compiler.specific.TestSpecificCompiler - /tmp/junit6626196665903310578/testInvalidParameterCounts1/sample/record.java:26: error: 'record' is not allowed here
private static final BinaryMessageDecoder<record> DECODER =
^
[main] ERROR org.apache.avro.compiler.specific.TestSpecificCompiler - /tmp/junit6626196665903310578/testInvalidParameterCounts1/sample/record.java:27: error: 'record' is not allowed here
new BinaryMessageDecoder<record>(MODEL$, SCHEMA$);
^
[main] ERROR org.apache.avro.compiler.specific.TestSpecificCompiler - /tmp/junit6626196665903310578/testInvalidParameterCounts1/sample/record.java:33: error: 'record' is not allowed here
public static BinaryMessageEncoder<record> getEncoder() {
^
[main] ERROR org.apache.avro.compiler.specific.TestSpecificCompiler - /tmp/junit6626196665903310578/testInvalidParameterCounts1/sample/record.java:41: error: 'record' is not allowed here
public static BinaryMessageDecoder<record> getDecoder() {
^
[main] ERROR org.apache.avro.compiler.specific.TestSpecificCompiler - /tmp/junit6626196665903310578/testInvalidParameterCounts1/sample/record.java:50: error: 'record' is not allowed here
public static BinaryMessageDecoder<record> createDecoder(SchemaStore resolver) {
^
[main] ERROR org.apache.avro.compiler.specific.TestSpecificCompiler - /tmp/junit6626196665903310578/testInvalidParameterCounts1/sample/record.java:51: error: 'record' is not allowed here
return new BinaryMessageDecoder<record>(MODEL$, SCHEMA$, resolver);
Attachments
Issue Links
- is related to
-
AVRO-3120 Support Next Java LTS (Java 17)
- Resolved
- links to