castor

Support for Java5 Enum

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.9.6
  • Fix Version/s: 1.1.2
  • Component/s: XML
  • Labels:
    None
  • Environment:
    Operating System: Windows 2000
    Platform: PC
  • Bugzilla Id:
    1854
  • Number of attachments :
    2

Description

I need to support Java5 Enum without defining a mapping.
I tried to do this with Descriptors Handlers and it never worked out.

After a lots of struggle I decided to treat it as a primitive and that was very
easy todo than.

I will upload the patch.diff file for CVS. Please integrate this as I need it
very much.
Or if you do not like the approach implement the java5 enum support in any way
you like.

The approach is very simply. There are 2 isPrimitive methods
(Introspector,MarshalFramework).
I intruduced the following check for enum:
type.getSuperclass().getName().equals("java.lang.Enum")

On the marshalling point for primitives I do the same check again and if it is
an enum, I call the 'name' method.

On the Unmarshalling point I do the same as your EnumFieldHandler, I call the
valueOf method.

  1. castor_patch.diff
    13/Jan/05 11:07 PM
    5 kB
    Michael Kopp
  2. patch.c991.20070526.txt
    27/May/07 3:57 PM
    3 kB
    Werner Guttmann

Issue Links

Activity

Hide
Michael Kopp added a comment -

Created an attachment (id=856)
proposed patch

The patch is based on the .9.6 cvs version

Show
Michael Kopp added a comment - Created an attachment (id=856) proposed patch The patch is based on the .9.6 cvs version
Hide
Keith Visco added a comment -

Michael,

Thanks for your contribution. I think support for Java 5 Enums is a good thing,
but keep in mind we cannot break JDK 1.4 or JDK 1.3 compatibility. Too many big
companies won't jump on the Java 5 bandwagon for a while.

I haven't looked at your patch yet so this may be a moot point I'm trying to
make, but however we do it we'll need to make sure that we add the support for
the Java 5 Enum (and any other Java 5 specific feature) without forcing our
users to upgrade to Java 5.

--Keith

Show
Keith Visco added a comment - Michael, Thanks for your contribution. I think support for Java 5 Enums is a good thing, but keep in mind we cannot break JDK 1.4 or JDK 1.3 compatibility. Too many big companies won't jump on the Java 5 bandwagon for a while. I haven't looked at your patch yet so this may be a moot point I'm trying to make, but however we do it we'll need to make sure that we add the support for the Java 5 Enum (and any other Java 5 specific feature) without forcing our users to upgrade to Java 5. --Keith
Hide
Michael Kopp added a comment -

I made the patch in a way to be 1.4 compatible. Meaning I compiled castor with
java 1.4.2. The two calls to the enum are done via reflection.

Show
Michael Kopp added a comment - I made the patch in a way to be 1.4 compatible. Meaning I compiled castor with java 1.4.2. The two calls to the enum are done via reflection.
Hide
Keith Visco added a comment -

Well, after looking at the patch I guess my point was moot after all. I see you
nicely wrapped everything inside checks with:

type.getSuperclass().getName().equals("java.lang.Enum")

So you can ignore my comments about maintaining backward compatibility.

We may want to optimize this check somehow, but for now I think that will work.
We'll probably add this after 0.9.6 final goes out since this is an enhancement
and only critical bug fixes are slated for 0.9.6 at this point.

Show
Keith Visco added a comment - Well, after looking at the patch I guess my point was moot after all. I see you nicely wrapped everything inside checks with: type.getSuperclass().getName().equals("java.lang.Enum") So you can ignore my comments about maintaining backward compatibility. We may want to optimize this check somehow, but for now I think that will work. We'll probably add this after 0.9.6 final goes out since this is an enhancement and only critical bug fixes are slated for 0.9.6 at this point.
Hide
Keith Visco added a comment -

> I made the patch in a way to be 1.4 compatible. Meaning I compiled castor with
> java 1.4.2. The two calls to the enum are done via reflection.

Yep, I noticed that after I posted my initial comments.

Thanks for taking the care in making sure it was backward compatible.

Show
Keith Visco added a comment - > I made the patch in a way to be 1.4 compatible. Meaning I compiled castor with > java 1.4.2. The two calls to the enum are done via reflection. Yep, I noticed that after I posted my initial comments. Thanks for taking the care in making sure it was backward compatible.
Hide
Keith Visco added a comment -

Marking for 0.9.7

Show
Keith Visco added a comment - Marking for 0.9.7
Hide
Michael Kopp added a comment -

Thanks.

I will have to make due with my customized version until then.
Any Ideas of the timeframe for 0.9.7. Only roughly of corse.

Show
Michael Kopp added a comment - Thanks. I will have to make due with my customized version until then. Any Ideas of the timeframe for 0.9.7. Only roughly of corse.
Hide
Keith Visco added a comment -

I'm not really sure of a timeframe for 0.9.7 as we all (the current committers)
need to get together and discuss that, but all we really have to do is wait a
week or two for 0.9.6 final to be released and then we'll branch the CVS. Once
the branch is done, we can start checking in code for 0.9.7. So if you don't
mind using the CVS version, we can check the patch in probably within a couple
weeks.

Show
Keith Visco added a comment - I'm not really sure of a timeframe for 0.9.7 as we all (the current committers) need to get together and discuss that, but all we really have to do is wait a week or two for 0.9.6 final to be released and then we'll branch the CVS. Once the branch is done, we can start checking in code for 0.9.7. So if you don't mind using the CVS version, we can check the patch in probably within a couple weeks.
Hide
Michael Kopp added a comment -

That is ok with me. I only need an official version in half a year from now.

Show
Michael Kopp added a comment - That is ok with me. I only need an official version in half a year from now.
Hide
Keith Visco added a comment -

Ok, that's good!

P.S. Be careful when you reply, your browser seems to be defaulting the Target
Milestone back to 0.9.6 each time you reply.

--Keith

Show
Keith Visco added a comment - Ok, that's good! P.S. Be careful when you reply, your browser seems to be defaulting the Target Milestone back to 0.9.6 each time you reply. --Keith
Hide
Michael Kopp added a comment -

sorry

Show
Michael Kopp added a comment - sorry
Hide
Keith Visco added a comment -

No problem, just wanted to make you aware of it. It happens alot, especially
with browsers that save form information.

Show
Keith Visco added a comment - No problem, just wanted to make you aware of it. It happens alot, especially with browsers that save form information.
Hide
Michael Kopp added a comment -

As 0.9.6 is out I guess development for 0.9.7 is underway.
Can this patch be applied now to the new branch?

mike

Show
Michael Kopp added a comment - As 0.9.6 is out I guess development for 0.9.7 is underway. Can this patch be applied now to the new branch? mike
Hide
Martin Fuchs added a comment -

While this is not directly related to this enhancement, I put it here since
it's a quite tiny thing: In class TxSynchronizableImpl there is used a local
variable called "enum" in function committed(). This should be renamed to
e.g. "en", to be compatible to Java5. You might consider to include this in the
patch.

Show
Martin Fuchs added a comment - While this is not directly related to this enhancement, I put it here since it's a quite tiny thing: In class TxSynchronizableImpl there is used a local variable called "enum" in function committed(). This should be renamed to e.g. "en", to be compatible to Java5. You might consider to include this in the patch.
Hide
Ralf Joachim added a comment -

We'll take care of Java5 enums with castor-1221

Show
Ralf Joachim added a comment - We'll take care of Java5 enums with castor-1221
Hide
Werner Guttmann added a comment -

Rather than creating a new issue, I made up my mind to reopen this one.

Show
Werner Guttmann added a comment - Rather than creating a new issue, I made up my mind to reopen this one.
Hide
Werner Guttmann added a comment -

Original patch redone against current SVN trunk, and cleaned up (as parts of this patch have been committed already as part of CASTOR-1221).

Show
Werner Guttmann added a comment - Original patch redone against current SVN trunk, and cleaned up (as parts of this patch have been committed already as part of CASTOR-1221).

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: