Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7808629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:11:26+00:00 2026-06-02T03:11:26+00:00

I am learning google protocol buffer since yesterday and have a question : Can

  • 0

I am learning google protocol buffer since yesterday and have a question :

Can i use a user-defined java class as a field type in a .proto file?

Let me clarify my questions with the details below:

1 – I have following java class “MyComplexClass.java”:

package mypackage;

import another.package1.ClassA;
import another.package2.ClassB;

public class MyComplexClass {

private ClassA var1;
private ClassB var2;

public MyComplexClass(ClassA X, ClassB Y)
 this.var1 = X;
 this.var2 = Y;
}

2- Now I would like to serialize an instance of the class “MyComplexClass.java”. For that purpose, I would like to describe a message like the following in a .proto file:

message myMessageToBeSerialized {

 required ***MyComplexClass*** intanceOfComplexClass = 1;

}

Is it possible to use the user-defined class MyComplexClass as a field type ? Or is it only allowed to use scalar types?

Any help would be appreciated. Thanks in advance.

Horace

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:11:28+00:00Added an answer on June 2, 2026 at 3:11 am

    No. It’s only possible to use types defined as protocol buffers. (That said, it’s common to implement your own complex classes as wrappers around protocol buffer classes, when you need to add more functionality.)

    If you were really, really keen on it, you could use normal Java serialization (an ObjectOutputStream wrapped around a ByteArrayOutputStream), and then send the byte[] through the protocol buffers, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi I started learning google data api. I have one question What will be
I'm learning to use google task api rest. i have succeed getting access tokken.
I am learning how to use the Google App Engine. My question is on
I'm learning how to use google geocoding API in java. I've decided to use
I have looked on Google, and everywhere in the forums. Just learning JavaScript, so
Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
I'm working on learning GWT (total newb) and have a question regarding the Visualiztion
I'm learning to write custom type conversions in C# and I have a question
I'm learning how to make a google appengine app in Java now, and in
I am learning how to use Google App Engine / Python. (webapp) I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.