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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:36:14+00:00 2026-05-30T04:36:14+00:00

My question concerns writing JAXB plugins, in particular JAXB codemodel. What is the role

  • 0

My question concerns writing JAXB plugins, in particular JAXB codemodel.

What is the role of ClassOutline (and it’s companions) and JClass (and companions) and CClass (and companions)? When looking at the list of classes in corresponding packages it is not clear what is chicken and what is egg.

My interpretation is that CClass (CPropertyInfo, CEnumConstant, …) are created by XJC at first draft parsing of XSD. Then some magic happens and this model is transformed into JClass (JFieldVar, JEnumConstant, …) and during this transformation customizations are applied. Afterwards plugins are invoked. ClassOutline is used as a bridge between these two models. Altogether looks very complicated.

With these parallel models I believe that the same information can be derived in several ways. For example, class field type:

  • JClass#fields() → JFieldVar#type → JType
  • CClassInfo#getProperties() → CPropertyInfo#baseType → JType

I am looking for verbose explanation of the lifecycle of above mentioned models. Thanks.

  • 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-30T04:36:16+00:00Added an answer on May 30, 2026 at 4:36 am

    Oh, oh, someone is interested in XJC internals. I might be of some help since I’ve probably developed more JAXB plugins than anyone else (see JAXB2 Basics for instance)

    Ok, let’s start. In XJC the schema compiler does approximately following

    • Parses the schema
    • Creates the model of the schema (CClass, CPropertyInfo etc.)
    • Creates the outline (ClassOutline, FieldOutline etc.)
    • Renders the code model (JClass, JDefinedClass, JMethod etc.)
    • Writes the physical code (ex.Java files on the disk)

    Let’s start with the last two.

    Java files don’t need explanation, I hope.

    Code model is also a relativesly easy thing. It is an API which can be used to construct Java code programmatically. You could just use string concatination instead, but it’s much more error-prone. With CodeModel you’re almost guaranteed to get at least grammatically correct Java code. So I hope this part is also clear. (By the way, I like CodeModel very much. I recently wrote JavaScript Code Model based on ideas from the CodeModel.)

    Let’s now look at the “model” and the “outline”.
    Model is the result of parsing the incoming schema. It models the constructs of the incoming schema, mainly in terms of “classes” which corresponds to complex types and “properties” which corresponds to elements, attributes and values (ex. when you have a complex type with simple content).

    The model should be understand as a logical modelling construct close to XML and schema. As such, it just describes types and properties that they have. It’s surely much more complex that how I’m describing it, there’s all sorts of exceptions and caveats – starting from wilcard types (xsd:any), substitution groups, enums, built-in types and so on.

    Quite interestingly, a sibling of Model is RuntimeTypeInfoSetImpl which is used by JAXB in the runtime. So it’s also a type of model – which is however not parsed from the XML Schema but rather from JAXB annotations in classes. The concept is the same. Both Model and RuntimeTypeInfoSetImpl implement the TypeInfoSet interface which is a super-construct. Check interfaces like ClassInfo and PropertyInfo – they have implementation both for compile-time (CClassInfo and CPropertyInfo in XJC) and run-time (RuntimeClassInfoImpl etc. for JAXB RI).

    Ok, so when XJC parsed and analysed the schema, you’ve got the Model. This Model can’t produce the code yet. There are, indeed, different strategies of producing the code. You can generate just annotated classes or you can generate interface/implementing class pair like in JAXB 1. The whole code generation thing isn’t actually the task of the model. Moreover, there is a number of aspects that are relevant to the physical nature of the Java code, but aren’t really relevant for the model. For instance, you have to group classes into packages. This is driven by the packing system of Java, not by the properties of the model itself.

    And this is where outlines come into play. You can see outlines as step between the schema model and the code model. You can view outlines as factories for code model elements responsible for organization of the code and generation of JDefinedClasses from CClassInfos.

    So you’re right, it is indeed very complicated. I am not a Sun/Oracle employee, I did not design it (I know the person who did it, though and respect him very much).
    I can guess a couple of reasons for certain design decisions, for instance:

    • Use the same interfaces for compile-time and run-time models
    • Allow different strategies of code generation
    • Allow plugins to manipulate the created model

    I agree that this design is very complicated, but it has its reasons. One proof for that is that it was actually possible to build a mapping generator for XML-to-JavaScript mappings – basically on the same models. I just had to replace the code generation leaving schema analysis intact. (See Jsonix for that.)

    Ok, hopefully I shed some light on why things in XJC are how they are. Good luck with these APIs, they’re not straghtforward. Feel free to check existing open-source code, there’s a lot of examples available.

    ps. Really always wanted to write this. 🙂

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

Sidebar

Related Questions

My question concerns c# and how to access Static members ... Well I don't
My question concerns Google Web Toolkit (GWT). I'm about to begin development for a
My question concerns markup that surrounds some of the default phone number labels in
In fact, my question concerns an algorithm. I need to be able to attach
I face a very serious situation. By writing this question I hope that really
a quick, simple question from me about for-loops. Situation I'm currently writing some high-performance
This is more a conceptual question. Here is my current predicament; I am writing
I am aware of this question , but I believe my concerns are very
I'm looking into writing a simple synchronization ability into my app and one of
My question concerns deleting already written chars in the console. Is there a way

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.