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 859863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:44:06+00:00 2026-05-15T08:44:06+00:00

When I serialize an object, I can use the serialVersionUID mechanism at the class

  • 0

When I serialize an object, I can use the serialVersionUID mechanism at the class level to ensure the compatibility of the two types.

However, what happens when I serialize fields of enum values? Is there a way to ensure that the enum type has not been manipulated between serialization and deserialization?

Suppose that I have an enum like OperationResult {SUCCESS, FAIL}, and a field called “result” in an object that is being serialized. How do I ensure, when the object is deserialized, that result is still correct even if someone maliciously reversed the two? (Suppose the enum is declared elsewhere as a static enum)

I am wondering out of curiosity – I use jar-level authentication to prevent manipulation.

  • 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-05-15T08:44:06+00:00Added an answer on May 15, 2026 at 8:44 am

    From: http://www.theserverside.com/news/thread.tss?thread_id=50190#265205

    The designers of enum feature decided
    there is no use case to create new
    enum objects at runtime. They took
    great care to not allow it.

    Therefore, it looks like enum objects cannot be serialised and deserialised in their entirety. Also, from http://java.sun.com/javase/6/docs/platform/serialization/spec/serial-arch.html#6469:

    Enum constants are serialized
    differently than ordinary serializable
    or externalizable objects. The
    serialized form of an enum constant
    consists solely of its name; field
    values of the constant are not present
    in the form. To serialize an enum
    constant, ObjectOutputStream writes
    the value returned by the enum
    constant’s name method. To deserialize
    an enum constant, ObjectInputStream
    reads the constant name from the
    stream; the deserialized constant is
    then obtained by calling the
    java.lang.Enum.valueOf method, passing
    the constant’s enum type along with
    the received constant name as
    arguments. Like other serializable or
    externalizable objects, enum constants
    can function as the targets of back
    references appearing subsequently in
    the serialization stream.

    The process by which enum constants
    are serialized cannot be customized:
    any class-specific writeObject,
    readObject, readObjectNoData,
    writeReplace, and readResolve methods
    defined by enum types are ignored
    during serialization and
    deserialization. Similarly, any
    serialPersistentFields or
    serialVersionUID field declarations
    are also ignored–all enum types have
    a fixed serialVersionUID of 0L.
    Documenting serializable fields and
    data for enum types is unnecessary,
    since there is no variation in the
    type of data sent.

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

Sidebar

Related Questions

I have an object I can serialize to XML without a problem. However when
If i try to serialize an object of the following ClassToSerialize class with System.Runtime.Serialization.Json.DataContractJsonSerializer
I'm trying to pass a complex object (that can be serialized, if that helps)
I am using Telerik controls in my webforms and want to serialize object on
I am able to serialize an object into a file and then restore it
I am trying to serialize an object to a sql compact database. I am
Is there any way to de/serialize an object without round-tripping a XmlDocument/temp string? I
Is there a way for me to serialize an object in .NET without the
I had an odd problem today when I was trying to serialize an object.
When serializing, I would like to serialize an object only once, then any references

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.