[Red Hat JIRA] (IPROTO-184) Improve annotation processor error messages
by Dan Berindei (Jira)
Dan Berindei created IPROTO-184:
-----------------------------------
Summary: Improve annotation processor error messages
Key: IPROTO-184
URL: https://issues.redhat.com/browse/IPROTO-184
Project: Infinispan ProtoStream
Issue Type: Enhancement
Affects Versions: 4.4.0.Alpha4
Reporter: Dan Berindei
Simplify the error message when a class doesn't have any protostream annotations and also doesn't have a no-argument constructor.
Currently the processor says
{noformat}
[ERROR] /home/dan/Work/infinispan/spring/spring5/spring5-common/src/main/java/org/infinispan/spring/common/provider/PersistenceContextInitializer.java:[24,8] org.infinispan.protostream.annotations.ProtoSchemaBuilderException: The class java.time.Duration must be instantiable using an accessible no-argument constructor.
[ERROR] at org.infinispan.protostream.annotations.impl.ProtoMessageTypeMetadata.checkInstantiability(ProtoMessageTypeMetadata.java:305)
[ERROR] at org.infinispan.protostream.annotations.impl.ProtoMessageTypeMetadata.<init>(ProtoMessageTypeMetadata.java:75)
[ERROR] at org.infinispan.protostream.annotations.impl.processor.CompileTimeProtoMessageTypeMetadata.<init>(CompileTimeProtoMessageTypeMetadata.java:16)
[ERROR] at org.infinispan.protostream.annotations.impl.processor.CompileTimeProtoSchemaGenerator.makeMessageTypeMetadata(CompileTimeProtoSchemaGenerator.java:57)
...
{noformat}
Since class java.time.Duration doesn't have any Protostream annotations, I believe the processor error message should only say that the class is not marshallable with Protostream, without going into more details. After all, the user can't change JDK classes, so they would have to write {{@ProtoAdapter}} class instead of adding a no-argument constructor.
----
Hide the exception when an annotation value is unavailable
Infinispan modules all allocate type ids in a commons class, {{ProtostreamTypeIds}}. When I add a new type id but I forget to recompile the commons module, Javac's compilation error is preceded by an internal protostream-processor error:
{noformat}
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project infinispan-spring5-common: Compilation failure: Compilation failure:
[ERROR] @AutoProtoSchemaBuilder processor threw a fatal exception: java.lang.annotation.AnnotationTypeMismatchException: Incorrectly typed data found for annotation element public abstract int org.infinispan.protostream.annotations.ProtoTypeId.value() (Found data of type <any>)
[ERROR] at jdk.compiler/com.sun.tools.javac.model.AnnotationProxyMaker$ValueVisitor$1AnnotationTypeMismatchExceptionProxy.generateException(AnnotationProxyMaker.java:271)
[ERROR] at java.base/sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:88)
[ERROR] at com.sun.proxy.$Proxy288.value(Unknown Source)
[ERROR] at org.infinispan.protostream.annotations.impl.ProtoTypeMetadata.getProtoTypeId(ProtoTypeMetadata.java:67)
[ERROR] at org.infinispan.protostream.annotations.impl.ProtoTypeMetadata.getDocumentation(ProtoTypeMetadata.java:46)
[ERROR] at org.infinispan.protostream.annotations.impl.ProtoMessageTypeMetadata.generateProto(ProtoMessageTypeMetadata.java:134)
...
[ERROR] /home/dan/Work/infinispan/spring/spring5/spring5-common/src/main/java/org/infinispan/spring/common/session/MapSessionProtoAdapter.java:[17,32] cannot find symbol
[ERROR] symbol: variable SPRING_SESSION
[ERROR] location: interface org.infinispan.commons.marshall.ProtoStreamTypeIds
{noformat}
It would be great if the processor could recognize data type {{<any>}} and skip logging an error, since Javac is going to fail the compilation anyway.
--
This message was sent by Atlassian Jira
(v8.13.1#813001)
5 years, 3 months
[Red Hat JIRA] (IPROTO-182) Enhance java.time.Instant default value support
by Nistor Adrian (Jira)
[ https://issues.redhat.com/browse/IPROTO-182?page=com.atlassian.jira.plugi... ]
Nistor Adrian commented on IPROTO-182:
--------------------------------------
How did you set the default value [~dan.berindei] ? In proto schema or java?
> Enhance java.time.Instant default value support
> -----------------------------------------------
>
> Key: IPROTO-182
> URL: https://issues.redhat.com/browse/IPROTO-182
> Project: Infinispan ProtoStream
> Issue Type: Enhancement
> Reporter: Dan Berindei
> Assignee: Nistor Adrian
> Priority: Minor
> Fix For: 4.4.0.Final
>
>
> Because of IPROTO-114, I had to set a default value for {{java.time.Instant}} fields.
> The {{defaultValue}} javadoc says {{The value is given in the form of a string that must obey correct syntax (as defined by Protobuf spec.)}}, but the protobuf documentation isn't very clear on what the default value for a {{Timestamp}} field should look like, and {{java.time.Instant}} isn't exactly a {{Timestamp}} anyway.
> The correct default value format is a positive number, representing milliseconds since the UNIX epoch, but this format is not documented.
> But negative values should also be supported, because {{java.time.Instant}} can represent timestamps before the UNIX epoch.
> It would be even better to support the RFC 3339 format ({{"1972-01-01T10:00:20.021Z"}}) that protobuf uses when mapping a {{Timestamp}} to JSON.
--
This message was sent by Atlassian Jira
(v8.13.1#813001)
5 years, 3 months
[Red Hat JIRA] (IPROTO-182) Enhance java.time.Instant default value support
by Nistor Adrian (Jira)
[ https://issues.redhat.com/browse/IPROTO-182?page=com.atlassian.jira.plugi... ]
Nistor Adrian updated IPROTO-182:
---------------------------------
Fix Version/s: 4.4.0.Final
> Enhance java.time.Instant default value support
> -----------------------------------------------
>
> Key: IPROTO-182
> URL: https://issues.redhat.com/browse/IPROTO-182
> Project: Infinispan ProtoStream
> Issue Type: Enhancement
> Reporter: Dan Berindei
> Assignee: Nistor Adrian
> Priority: Minor
> Fix For: 4.4.0.Final
>
>
> Because of IPROTO-114, I had to set a default value for {{java.time.Instant}} fields.
> The {{defaultValue}} javadoc says {{The value is given in the form of a string that must obey correct syntax (as defined by Protobuf spec.)}}, but the protobuf documentation isn't very clear on what the default value for a {{Timestamp}} field should look like, and {{java.time.Instant}} isn't exactly a {{Timestamp}} anyway.
> The correct default value format is a positive number, representing milliseconds since the UNIX epoch, but this format is not documented.
> But negative values should also be supported, because {{java.time.Instant}} can represent timestamps before the UNIX epoch.
> It would be even better to support the RFC 3339 format ({{"1972-01-01T10:00:20.021Z"}}) that protobuf uses when mapping a {{Timestamp}} to JSON.
--
This message was sent by Atlassian Jira
(v8.13.1#813001)
5 years, 3 months
[Red Hat JIRA] (IPROTO-182) Enhance java.time.Instant default value support
by Nistor Adrian (Jira)
[ https://issues.redhat.com/browse/IPROTO-182?page=com.atlassian.jira.plugi... ]
Nistor Adrian reassigned IPROTO-182:
------------------------------------
Assignee: Nistor Adrian
> Enhance java.time.Instant default value support
> -----------------------------------------------
>
> Key: IPROTO-182
> URL: https://issues.redhat.com/browse/IPROTO-182
> Project: Infinispan ProtoStream
> Issue Type: Enhancement
> Reporter: Dan Berindei
> Assignee: Nistor Adrian
> Priority: Minor
>
> Because of IPROTO-114, I had to set a default value for {{java.time.Instant}} fields.
> The {{defaultValue}} javadoc says {{The value is given in the form of a string that must obey correct syntax (as defined by Protobuf spec.)}}, but the protobuf documentation isn't very clear on what the default value for a {{Timestamp}} field should look like, and {{java.time.Instant}} isn't exactly a {{Timestamp}} anyway.
> The correct default value format is a positive number, representing milliseconds since the UNIX epoch, but this format is not documented.
> But negative values should also be supported, because {{java.time.Instant}} can represent timestamps before the UNIX epoch.
> It would be even better to support the RFC 3339 format ({{"1972-01-01T10:00:20.021Z"}}) that protobuf uses when mapping a {{Timestamp}} to JSON.
--
This message was sent by Atlassian Jira
(v8.13.1#813001)
5 years, 3 months
[Red Hat JIRA] (IPROTO-182) Enhance java.time.Instant default value support
by Nistor Adrian (Jira)
[ https://issues.redhat.com/browse/IPROTO-182?page=com.atlassian.jira.plugi... ]
Nistor Adrian updated IPROTO-182:
---------------------------------
Status: Open (was: New)
> Enhance java.time.Instant default value support
> -----------------------------------------------
>
> Key: IPROTO-182
> URL: https://issues.redhat.com/browse/IPROTO-182
> Project: Infinispan ProtoStream
> Issue Type: Enhancement
> Reporter: Dan Berindei
> Priority: Minor
>
> Because of IPROTO-114, I had to set a default value for {{java.time.Instant}} fields.
> The {{defaultValue}} javadoc says {{The value is given in the form of a string that must obey correct syntax (as defined by Protobuf spec.)}}, but the protobuf documentation isn't very clear on what the default value for a {{Timestamp}} field should look like, and {{java.time.Instant}} isn't exactly a {{Timestamp}} anyway.
> The correct default value format is a positive number, representing milliseconds since the UNIX epoch, but this format is not documented.
> But negative values should also be supported, because {{java.time.Instant}} can represent timestamps before the UNIX epoch.
> It would be even better to support the RFC 3339 format ({{"1972-01-01T10:00:20.021Z"}}) that protobuf uses when mapping a {{Timestamp}} to JSON.
--
This message was sent by Atlassian Jira
(v8.13.1#813001)
5 years, 3 months
[Red Hat JIRA] (IPROTO-183) Annotation based marshalling adapter fails for array classes (in runtime mode)
by Nistor Adrian (Jira)
[ https://issues.redhat.com/browse/IPROTO-183?page=com.atlassian.jira.plugi... ]
Nistor Adrian updated IPROTO-183:
---------------------------------
Fix Version/s: 4.4.0.Alpha5
> Annotation based marshalling adapter fails for array classes (in runtime mode)
> ------------------------------------------------------------------------------
>
> Key: IPROTO-183
> URL: https://issues.redhat.com/browse/IPROTO-183
> Project: Infinispan ProtoStream
> Issue Type: Bug
> Affects Versions: 4.4.0.Alpha1
> Reporter: Nistor Adrian
> Assignee: Nistor Adrian
> Priority: Major
> Fix For: 4.4.0.Alpha5
>
>
> Marshaller generation fails in runtime mode annotation processing but succeeds at compile time annotation processing:
>
> {code}
> Caused by: javassist.CannotCompileException: [source error] syntax error near "\{ return [I.class; }"
> at javassist.CtNewMethod.make(CtNewMethod.java:84)
> at javassist.CtNewMethod.make(CtNewMethod.java:50)
> at org.infinispan.protostream.annotations.impl.MarshallerByteCodeGenerator.generateMessageMarshaller(MarshallerByteCodeGenerator.java:173)
> at org.infinispan.protostream.annotations.impl.MarshallerByteCodeGenerator.generateMarshaller(MarshallerByteCodeGenerator.java:100)
> at org.infinispan.protostream.annotations.impl.BaseProtoSchemaGenerator.generateMarshallers(BaseProtoSchemaGenerator.java:203)
> at org.infinispan.protostream.annotations.impl.BaseProtoSchemaGenerator.generateAndRegister(BaseProtoSchemaGenerator.java:174)
> ... 28 more
> Caused by: compile error: syntax error near "\{ return [I.class; }"
> at javassist.compiler.Parser.parsePrimaryExpr(Parser.java:1268)
> at javassist.compiler.Parser.parsePostfix(Parser.java:1045)
> at javassist.compiler.Parser.parseUnaryExpr(Parser.java:900)
> at javassist.compiler.Parser.parseBinaryExpr(Parser.java:790)
> at javassist.compiler.Parser.parseConditionalExpr(Parser.java:735)
> at javassist.compiler.Parser.parseExpression(Parser.java:715)
> at javassist.compiler.Parser.parseReturn(Parser.java:524)
> at javassist.compiler.Parser.parseStatement(Parser.java:287)
> at javassist.compiler.Parser.parseBlock(Parser.java:307)
> at javassist.compiler.Parser.parseMethod2(Parser.java:172)
> at javassist.compiler.Javac.compileMethod(Javac.java:156)
> at javassist.compiler.Javac.compile(Javac.java:102)
> at javassist.CtNewMethod.make(CtNewMethod.java:79)
> ... 33 more
> {code}
--
This message was sent by Atlassian Jira
(v8.13.1#813001)
5 years, 3 months
[Red Hat JIRA] (IPROTO-183) Annotation based marshalling adapter fails for array classes (in runtime mode)
by Nistor Adrian (Jira)
[ https://issues.redhat.com/browse/IPROTO-183?page=com.atlassian.jira.plugi... ]
Work on IPROTO-183 started by Nistor Adrian.
--------------------------------------------
> Annotation based marshalling adapter fails for array classes (in runtime mode)
> ------------------------------------------------------------------------------
>
> Key: IPROTO-183
> URL: https://issues.redhat.com/browse/IPROTO-183
> Project: Infinispan ProtoStream
> Issue Type: Bug
> Affects Versions: 4.4.0.Alpha1
> Reporter: Nistor Adrian
> Assignee: Nistor Adrian
> Priority: Major
>
> Marshaller generation fails in runtime mode annotation processing but succeeds at compile time annotation processing:
>
> {code}
> Caused by: javassist.CannotCompileException: [source error] syntax error near "\{ return [I.class; }"
> at javassist.CtNewMethod.make(CtNewMethod.java:84)
> at javassist.CtNewMethod.make(CtNewMethod.java:50)
> at org.infinispan.protostream.annotations.impl.MarshallerByteCodeGenerator.generateMessageMarshaller(MarshallerByteCodeGenerator.java:173)
> at org.infinispan.protostream.annotations.impl.MarshallerByteCodeGenerator.generateMarshaller(MarshallerByteCodeGenerator.java:100)
> at org.infinispan.protostream.annotations.impl.BaseProtoSchemaGenerator.generateMarshallers(BaseProtoSchemaGenerator.java:203)
> at org.infinispan.protostream.annotations.impl.BaseProtoSchemaGenerator.generateAndRegister(BaseProtoSchemaGenerator.java:174)
> ... 28 more
> Caused by: compile error: syntax error near "\{ return [I.class; }"
> at javassist.compiler.Parser.parsePrimaryExpr(Parser.java:1268)
> at javassist.compiler.Parser.parsePostfix(Parser.java:1045)
> at javassist.compiler.Parser.parseUnaryExpr(Parser.java:900)
> at javassist.compiler.Parser.parseBinaryExpr(Parser.java:790)
> at javassist.compiler.Parser.parseConditionalExpr(Parser.java:735)
> at javassist.compiler.Parser.parseExpression(Parser.java:715)
> at javassist.compiler.Parser.parseReturn(Parser.java:524)
> at javassist.compiler.Parser.parseStatement(Parser.java:287)
> at javassist.compiler.Parser.parseBlock(Parser.java:307)
> at javassist.compiler.Parser.parseMethod2(Parser.java:172)
> at javassist.compiler.Javac.compileMethod(Javac.java:156)
> at javassist.compiler.Javac.compile(Javac.java:102)
> at javassist.CtNewMethod.make(CtNewMethod.java:79)
> ... 33 more
> {code}
--
This message was sent by Atlassian Jira
(v8.13.1#813001)
5 years, 3 months