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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:27:16+00:00 2026-05-28T21:27:16+00:00

I am using JAXB to marshall. I have noticed that when I am marshaling

  • 0

I am using JAXB to marshall.
I have noticed that when I am marshaling an object inside another object, the method for the inner object (for example: object A has a field of type B. Object B has a getter for a String) – this method is called twice (the getter for the String). Once for checking if not null (via hasValue method) and another time for getting the actual value (via writeLeafElememnt).

This seems awfully inefficient. Any thoughts on how to bypass this functionality?

Thank you very much.

  • 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-28T21:27:16+00:00Added an answer on May 28, 2026 at 9:27 pm

    Firstly, if all the getter method is doing is returning a field value, then it has almost zero performance impact. The JVM is extremely good at optimising this sort of thing.

    If you really want to avoid it, though, you can annotate the fields directly, rather than annotating the getter methods. It won’t make any difference to the performance, though.

    This is a classic example of premature micro-optimization. If you think something is slow, then measure it. If it’s a performance hotspot then, and only then, do something about it.

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

Sidebar

Related Questions

I have an Object that is being marshalled to XML using JAXB. One element
I have a service that needs to generate xml. Currently I am using jaxb
I have always been using jaxb for parsing XML files into java object. This
Here is what I have so far to marshall my POJO using JAXB :
I have a XML format that I want to marshal using JAXB and it
I have a Maven 2 RESTful application using Jersey/JAXB. I generate the JAXB beans
I am using JAXB to unmarshal an XML file into an object tree. The
I have several hand-written Java classes in a REST Server that uses JAXB to
We are using JAXB Annotations on our model objects that we return from our
I have a problem with my JAXB. I have a method with @XmlAnyAttribute (on

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.