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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:11:23+00:00 2026-06-18T12:11:23+00:00

Here is a sample jaxb class that I defined from scratch. When I try

  • 0

Here is a sample jaxb class that I defined from scratch. When I try generating schema for this class using JAXB, it guesses correctly that the itemType of the list as “int”

Doesn’t JVM throw away generics at runtime? By doing that the container type of List is lost at runtime but still, jaxb knows the itemType is Integer. I am very curious as to how this is accomplished by the jaxb framework. Any ideas?

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "int-list")
public class IntegerList{
    @XmlValue
    private List<Integer> values;

    public List<Integer> getValues() {
        return values;
    }

    public void setValues(List<Integer> values) {
        this.values = values;
    }
}

Corresponding schema generated using JAXBContext.generateSchema:

  <xs:simpleType name="int-list">
    <xs:list itemType="xs:int"/>
  </xs:simpleType>
  • 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-18T12:11:23+00:00Added an answer on June 18, 2026 at 12:11 pm

    Doesn’t JVM throw away generics at runtime?

    Yes, with respect to actual bytecode (well, it’s the compiler that throws them away). But the generic type information of classes and certain variables can still be gleaned at runtime by using reflection. For example:

    Field field = IntegerList.class.getDeclaredField("values");
    Type fieldType = field.getGenericType();
    Type typeArg = ((ParameterizedType)fieldType).getActualTypeArguments()[0];
    System.out.println(typeArg); //class java.lang.Integer
    

    Just a guess, but JAXB is likely doing something similar and then mapping Integer.class to int.class.

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

Sidebar

Related Questions

I' have simple question about JAXB. Here is the sample code: //setter that has
As described here http://www.ddj.com/cpp/184401688 I do not have time to write this from scratch.
I have some html code that look like this sample here : <html> <body>
Here's sample model classes, which being use with Entity Framework Code First: public class
Here is sample data <table class=sparql border=1> <tr> <th>abstract</th></tr> <tr> <td> Cologne is Germany&#39;s
Here is the sample code that I ran on Visual Studio 2010: #include <iostream>
Here is my sample query: SELECT userid,count(*) FROM hits GROUP BY userid My table
I am trying to unmarshall a XML document created from jersey JAXB annotated class.
Here is sample code that throws a Servlet Exception as invalid expression error. data
Here is sample query SELECT name, sum(SELECT id FROM mytable WHERE cond='1' and cond2='2')

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.