users@jaxb.java.net

"JAXB creates uncompilable ObjectFactory.java" OR "handling huge XML schema"

From: Valentine Mayamsin <yavalek_at_gmail.com>
Date: Wed, 20 Apr 2011 10:01:58 -0700

By request, I start discussing the bug:
http://java.net/jira/browse/JAXB-830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=307246#action_307246

I tried to compile huge schema, there are ~13MB of XSD files. It compiles
into java files fine, but I when I try to compile these files, javac crashes
with the following error:

$ javac -d bin/ src/x0/xmlapi1/*
ObjectFactory.java:32: too many constants
public class ObjectFactory {
^
1 error

$ wc ObjectFactory.java
287163 1028666 15104373 ObjectFactory.java

I tried to hack javac to increase the limits. It compiles fine, but java VM
by itself doesn't recognizes this file. Obviously, hacking JVM is not a good
idea.

Martin Grebac <http://java.net/jira/secure/ViewProfile.jspa?name=snajper>
suggested
to customize generation of such large schema to different packages, but looks
like it's impossible to split the schema into different packages without
modifications since it is provided by 3d party vendor. According to the
documentation (http://jaxb.java.net/guide/Customizing_Java_packages.html):

"Note that this customization is per namespace. That is, even if your schema
is split into multiple schema documents, you cannot put them into different
packages if they are all in the same namespace."
Here is a sample ObjectFactory class: http://pastebin.com/81Kn0UQs

So, is there any way to split this ObjectFactory into several
classes/packages or any other ideas?

Thank you!