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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:13:28+00:00 2026-06-13T08:13:28+00:00

Can a class annotation affect its default serialization? Java docs say Annotations do not

  • 0

Can a class annotation affect its default serialization? Java docs say

Annotations do not directly affect program semantics, but they do affect the way programs are treated by tools and libraries, which can in turn affect the semantics of the running program. Annotations can be read from source files, class files, or reflectively at run time.

This would lead me to guess no, but I have not found a conclusive statement.

Edit: I meant to ask “Can an annotation affect Java default serialization?” So, I am changing the question text and accepting the less popular answer. My apologies to the person who answered what I asked previously (“Can an annotation affect serialization?”). 🙂 Yes, you can construct cases that affect serialization. However, I think the changed question will be of more practical value, certainly to me.

  • 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-13T08:13:29+00:00Added an answer on June 13, 2026 at 8:13 am

    Annotations with RETENTION=RUNTIME are in byte code, but not serialized themselves. Serialization works with object fields, not with classes.

    Annotations can be used by serializer. However, the standard java serialization mechanism does not use them: it was created for java 1.0, 10 years before annotations.

    However, custom mechanisms can use annotations. For example, you can create a @Transient annotation and use it to mark fields that should not be serialized.

    Serialization can be customized using a writeObject() method or with a third party library like xstream.

    There are a lot of serialization libraries. You can think about JAXB or XStream as libraries that serialize object to XML. Both support a large set of annotations.

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

Sidebar

Related Questions

A class can be a subclass of itself if its inner class extend the
In JUnit 4 you can declare expected exception using @Test(expected = SomeException.class) annotation. However,
I am looking JAXB annotation class which can be serialized the following json format.
If a class defined an annotation, is it somehow possible to force its subclass
I have a java class, for some field (not all field), I will put
I've never written an annotation in Java. I've got a simple Java class for
What I'm looking for is some sort of class or annotation I can add
I am trying to use Doctrine Common to create my own annotation. http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html does
Can a class return an object of itself. In my example I have a
Can a class extend two or more classes in Objective-C?

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.