2016-09-21 7 views
1

Googleのプロトコルバッファバージョン3.0.0(リリースバージョン)、コンパイラエラーでMavenの結果によって、次の生成されたJavaクラスのコンパイル使用:いるProtobuf生成されたコードのためのMaven Javaコンパイラのエラー:互換性のない戻り値の型

のJavaをクラス(生成されたクラスの1つ)は、フィールドを持たない単純なメッセージ "PBReset"です。

// Generated by the protocol buffer compiler. DO NOT EDIT! 
// source: PBMessages.proto 

package at.fhhagenberg.nemo.traffsim.remote.messages; 

/** 
* Protobuf type {@code messages.PBReset} 
*/ 
public final class PBReset extends 
    com.google.protobuf.GeneratedMessageV3 implements 
    // @@protoc_insertion_point(message_implements:messages.PBReset) 
    PBResetOrBuilder { 
    // Use PBReset.newBuilder() to construct. 
    private PBReset(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { 
    super(builder); 
    } 
    private PBReset() { 
    } 

    @java.lang.Override 
    public final com.google.protobuf.UnknownFieldSet 
    getUnknownFields() { 
    return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); 
    } 
    private PBReset(
     com.google.protobuf.CodedInputStream input, 
     com.google.protobuf.ExtensionRegistryLite extensionRegistry) 
     throws com.google.protobuf.InvalidProtocolBufferException { 
    this(); 
    try { 
     boolean done = false; 
     while (!done) { 
     int tag = input.readTag(); 
     switch (tag) { 
      case 0: 
      done = true; 
      break; 
      default: { 
      if (!input.skipField(tag)) { 
       done = true; 
      } 
      break; 
      } 
     } 
     } 
    } catch (com.google.protobuf.InvalidProtocolBufferException e) { 
     throw e.setUnfinishedMessage(this); 
    } catch (java.io.IOException e) { 
     throw new com.google.protobuf.InvalidProtocolBufferException(
      e).setUnfinishedMessage(this); 
    } finally { 
     makeExtensionsImmutable(); 
    } 
    } 
    public static final com.google.protobuf.Descriptors.Descriptor 
     getDescriptor() { 
    return at.fhhagenberg.nemo.traffsim.remote.messages.PBMessages.internal_static_messages_PBReset_descriptor; 
    } 

    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 
     internalGetFieldAccessorTable() { 
    return at.fhhagenberg.nemo.traffsim.remote.messages.PBMessages.internal_static_messages_PBReset_fieldAccessorTable 
     .ensureFieldAccessorsInitialized(
      at.fhhagenberg.nemo.traffsim.remote.messages.PBReset.class, at.fhhagenberg.nemo.traffsim.remote.messages.PBReset.Builder.class); 
    } 

    private byte memoizedIsInitialized = -1; 
    public final boolean isInitialized() { 
    byte isInitialized = memoizedIsInitialized; 
    if (isInitialized == 1) return true; 
    if (isInitialized == 0) return false; 

    memoizedIsInitialized = 1; 
    return true; 
    } 

    public void writeTo(com.google.protobuf.CodedOutputStream output) 
         throws java.io.IOException { 
    } 

    public int getSerializedSize() { 
    int size = memoizedSize; 
    if (size != -1) return size; 

    size = 0; 
    memoizedSize = size; 
    return size; 
    } 

    private static final long serialVersionUID = 0L; 
    @java.lang.Override 
    public boolean equals(final java.lang.Object obj) { 
    if (obj == this) { 
    return true; 
    } 
    if (!(obj instanceof at.fhhagenberg.nemo.traffsim.remote.messages.PBReset)) { 
     return super.equals(obj); 
    } 
    at.fhhagenberg.nemo.traffsim.remote.messages.PBReset other = (at.fhhagenberg.nemo.traffsim.remote.messages.PBReset) obj; 

    boolean result = true; 
    return result; 
    } 

    @java.lang.Override 
    public int hashCode() { 
    if (memoizedHashCode != 0) { 
     return memoizedHashCode; 
    } 
    int hash = 41; 
    hash = (19 * hash) + getDescriptorForType().hashCode(); 
    hash = (29 * hash) + unknownFields.hashCode(); 
    memoizedHashCode = hash; 
    return hash; 
    } 

    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parseFrom(
     com.google.protobuf.ByteString data) 
     throws com.google.protobuf.InvalidProtocolBufferException { 
    return PARSER.parseFrom(data); 
    } 
    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parseFrom(
     com.google.protobuf.ByteString data, 
     com.google.protobuf.ExtensionRegistryLite extensionRegistry) 
     throws com.google.protobuf.InvalidProtocolBufferException { 
    return PARSER.parseFrom(data, extensionRegistry); 
    } 
    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parseFrom(byte[] data) 
     throws com.google.protobuf.InvalidProtocolBufferException { 
    return PARSER.parseFrom(data); 
    } 
    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parseFrom(
     byte[] data, 
     com.google.protobuf.ExtensionRegistryLite extensionRegistry) 
     throws com.google.protobuf.InvalidProtocolBufferException { 
    return PARSER.parseFrom(data, extensionRegistry); 
    } 
    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parseFrom(java.io.InputStream input) 
     throws java.io.IOException { 
    return com.google.protobuf.GeneratedMessageV3 
     .parseWithIOException(PARSER, input); 
    } 
    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parseFrom(
     java.io.InputStream input, 
     com.google.protobuf.ExtensionRegistryLite extensionRegistry) 
     throws java.io.IOException { 
    return com.google.protobuf.GeneratedMessageV3 
     .parseWithIOException(PARSER, input, extensionRegistry); 
    } 
    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parseDelimitedFrom(java.io.InputStream input) 
     throws java.io.IOException { 
    return com.google.protobuf.GeneratedMessageV3 
     .parseDelimitedWithIOException(PARSER, input); 
    } 
    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parseDelimitedFrom(
     java.io.InputStream input, 
     com.google.protobuf.ExtensionRegistryLite extensionRegistry) 
     throws java.io.IOException { 
    return com.google.protobuf.GeneratedMessageV3 
     .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 
    } 
    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parseFrom(
     com.google.protobuf.CodedInputStream input) 
     throws java.io.IOException { 
    return com.google.protobuf.GeneratedMessageV3 
     .parseWithIOException(PARSER, input); 
    } 
    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parseFrom(
     com.google.protobuf.CodedInputStream input, 
     com.google.protobuf.ExtensionRegistryLite extensionRegistry) 
     throws java.io.IOException { 
    return com.google.protobuf.GeneratedMessageV3 
     .parseWithIOException(PARSER, input, extensionRegistry); 
    } 

    public Builder newBuilderForType() { return newBuilder(); } 
    public static Builder newBuilder() { 
    return DEFAULT_INSTANCE.toBuilder(); 
    } 
    public static Builder newBuilder(at.fhhagenberg.nemo.traffsim.remote.messages.PBReset prototype) { 
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 
    } 
    public Builder toBuilder() { 
    return this == DEFAULT_INSTANCE 
     ? new Builder() : new Builder().mergeFrom(this); 
    } 

    @java.lang.Override 
    protected Builder newBuilderForType(
     com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 
    Builder builder = new Builder(parent); 
    return builder; 
    } 
    /** 
    * Protobuf type {@code messages.PBReset} 
    */ 
    public static final class Builder extends 
     com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements 
     // @@protoc_insertion_point(builder_implements:messages.PBReset) 
     at.fhhagenberg.nemo.traffsim.remote.messages.PBResetOrBuilder { 
    public static final com.google.protobuf.Descriptors.Descriptor 
     getDescriptor() { 
     return at.fhhagenberg.nemo.traffsim.remote.messages.PBMessages.internal_static_messages_PBReset_descriptor; 
    } 

    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 
     internalGetFieldAccessorTable() { 
     return at.fhhagenberg.nemo.traffsim.remote.messages.PBMessages.internal_static_messages_PBReset_fieldAccessorTable 
      .ensureFieldAccessorsInitialized(
       at.fhhagenberg.nemo.traffsim.remote.messages.PBReset.class, at.fhhagenberg.nemo.traffsim.remote.messages.PBReset.Builder.class); 
    } 

    // Construct using at.fhhagenberg.nemo.traffsim.remote.messages.PBReset.newBuilder() 
    private Builder() { 
     maybeForceBuilderInitialization(); 
    } 

    private Builder(
     com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 
     super(parent); 
     maybeForceBuilderInitialization(); 
    } 
    private void maybeForceBuilderInitialization() { 
     if (com.google.protobuf.GeneratedMessageV3 
       .alwaysUseFieldBuilders) { 
     } 
    } 
    public Builder clear() { 
     super.clear(); 
     return this; 
    } 

    public com.google.protobuf.Descriptors.Descriptor 
     getDescriptorForType() { 
     return at.fhhagenberg.nemo.traffsim.remote.messages.PBMessages.internal_static_messages_PBReset_descriptor; 
    } 

    public at.fhhagenberg.nemo.traffsim.remote.messages.PBReset getDefaultInstanceForType() { 
     return at.fhhagenberg.nemo.traffsim.remote.messages.PBReset.getDefaultInstance(); 
    } 

    public at.fhhagenberg.nemo.traffsim.remote.messages.PBReset build() { 
     at.fhhagenberg.nemo.traffsim.remote.messages.PBReset result = buildPartial(); 
     if (!result.isInitialized()) { 
     throw newUninitializedMessageException(result); 
     } 
     return result; 
    } 

    public at.fhhagenberg.nemo.traffsim.remote.messages.PBReset buildPartial() { 
     at.fhhagenberg.nemo.traffsim.remote.messages.PBReset result = new at.fhhagenberg.nemo.traffsim.remote.messages.PBReset(this); 
     onBuilt(); 
     return result; 
    } 

    public Builder clone() { 
     return (Builder) super.clone(); 
    } 
    public Builder setField(
     com.google.protobuf.Descriptors.FieldDescriptor field, 
     Object value) { 
     return (Builder) super.setField(field, value); 
    } 
    public Builder clearField(
     com.google.protobuf.Descriptors.FieldDescriptor field) { 
     return (Builder) super.clearField(field); 
    } 
    public Builder clearOneof(
     com.google.protobuf.Descriptors.OneofDescriptor oneof) { 
     return (Builder) super.clearOneof(oneof); 
    } 
    public Builder setRepeatedField(
     com.google.protobuf.Descriptors.FieldDescriptor field, 
     int index, Object value) { 
     return (Builder) super.setRepeatedField(field, index, value); 
    } 
    public Builder addRepeatedField(
     com.google.protobuf.Descriptors.FieldDescriptor field, 
     Object value) { 
     return (Builder) super.addRepeatedField(field, value); 
    } 
    public Builder mergeFrom(com.google.protobuf.Message other) { 
     if (other instanceof at.fhhagenberg.nemo.traffsim.remote.messages.PBReset) { 
     return mergeFrom((at.fhhagenberg.nemo.traffsim.remote.messages.PBReset)other); 
     } else { 
     super.mergeFrom(other); 
     return this; 
     } 
    } 

    public Builder mergeFrom(at.fhhagenberg.nemo.traffsim.remote.messages.PBReset other) { 
     if (other == at.fhhagenberg.nemo.traffsim.remote.messages.PBReset.getDefaultInstance()) return this; 
     onChanged(); 
     return this; 
    } 

    public final boolean isInitialized() { 
     return true; 
    } 

    public Builder mergeFrom(
     com.google.protobuf.CodedInputStream input, 
     com.google.protobuf.ExtensionRegistryLite extensionRegistry) 
     throws java.io.IOException { 
     at.fhhagenberg.nemo.traffsim.remote.messages.PBReset parsedMessage = null; 
     try { 
     parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 
     } catch (com.google.protobuf.InvalidProtocolBufferException e) { 
     parsedMessage = (at.fhhagenberg.nemo.traffsim.remote.messages.PBReset) e.getUnfinishedMessage(); 
     throw e.unwrapIOException(); 
     } finally { 
     if (parsedMessage != null) { 
      mergeFrom(parsedMessage); 
     } 
     } 
     return this; 
    } 
    public final Builder setUnknownFields(
     final com.google.protobuf.UnknownFieldSet unknownFields) { 
     return this; 
    } 

    public final Builder mergeUnknownFields(
     final com.google.protobuf.UnknownFieldSet unknownFields) { 
     return this; 
    } 


    // @@protoc_insertion_point(builder_scope:messages.PBReset) 
    } 

    // @@protoc_insertion_point(class_scope:messages.PBReset) 
    private static final at.fhhagenberg.nemo.traffsim.remote.messages.PBReset DEFAULT_INSTANCE; 
    static { 
    DEFAULT_INSTANCE = new at.fhhagenberg.nemo.traffsim.remote.messages.PBReset(); 
    } 

    public static at.fhhagenberg.nemo.traffsim.remote.messages.PBReset getDefaultInstance() { 
    return DEFAULT_INSTANCE; 
    } 

    private static final com.google.protobuf.Parser<PBReset> 
     PARSER = new com.google.protobuf.AbstractParser<PBReset>() { 
    public PBReset parsePartialFrom(
     com.google.protobuf.CodedInputStream input, 
     com.google.protobuf.ExtensionRegistryLite extensionRegistry) 
     throws com.google.protobuf.InvalidProtocolBufferException { 
     return new PBReset(input, extensionRegistry); 
    } 
    }; 

    public static com.google.protobuf.Parser<PBReset> parser() { 
    return PARSER; 
    } 

    @java.lang.Override 
    public com.google.protobuf.Parser<PBReset> getParserForType() { 
    return PARSER; 
    } 

    public at.fhhagenberg.nemo.traffsim.remote.messages.PBReset getDefaultInstanceForType() { 
    return DEFAULT_INSTANCE; 
    } 

} 

プロトファイルのソース(抜粋):

message PBReset { 

} 

これは、Mavenのエラーがすべてのクラスの同じで、以下のように、一つだけ生成されたクラスのである:

[ERROR] C:\Users\Christian\Documents\FuE\Dissertation\Java\workspace\at.fhhagenberg.nemo.traffsim.remote\src\at\fhhagenberg\nemo\traffsim\remote\messages\PBReset.java:[9] 
[ERROR] public final class PBReset extends 
[ERROR] ^^^^^^^ 
[ERROR] The return types are incompatible for the inherited methods MessageOrBuilder.getAllFields(), GeneratedMessageV3.getAllFields() 

これらのクラスは、クラスパス上にprotobuf-java-3.0.0.jarを持つ、動作中のMaven-Tycho-Buildコンフィグレーションに含まれています。 Eclipse内でコードをコンパイルするときにコンパイルエラーは発生しません。

さらに、また、クラスパス上hereからいるProtobuf-のjava-3.0.0.jarで、コマンドラインからのjavacを呼び出すときに、生成されたソースがエラーなしでコンパイルします。もちろん

、また、Javaソースがprotocバージョン3.0.0

で生成された私はまた、両方が同じ戻り値の型を持っているMessageOrBuilderクラスとGeneratedMessageV3クラスと宣言getAllFields()メソッドで見て、持っていましたつまり、public Map < FieldDescriptor、Object>です。ただし、MessageOrBuilderインターフェイスではMap < Descriptors.FieldDescriptor、Object>として宣言されているため、唯一の違いは異なる表記です。

誰かがmaven javaコンパイラがこれらの戻り値の型を同じ型として認識せず、エラーを表示する理由を教えてもらえますか?

興味深い詳細:EclipseのJavaコンパイラでは、この(すでに固定)バグは非常に同じ問題が生じているようだ:https://bugs.eclipse.org/bugs/show_bug.cgi?id=496591

答えて

0

私はEclipseのネオンと同じ問題がありました。私はバージョン4.6.1に私の日食を更新し、問題は解決されました。

@Christian:あなたの興味深い詳細が私を助けました。先端に感謝します。

関連する問題