Uploaded image for project: 'ProtoStream'
  1. ProtoStream
  2. IPROTO-184

Improve annotation processor error messages

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 4.4.0.Alpha4
    • None
    • False
    • False
    • Undefined

      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

      [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)
      ...
      

      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:

      [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
      

      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.

              anistor Adrian Nistor (Inactive)
              dberinde@redhat.com Dan Berindei (Inactive)
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: