users@jaxb.java.net

Generated classes cannot be abstract?

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Mon, 13 Sep 2004 12:45:57 +0200

Hi.

It seems like generated classes cannot be abstract.

When I try to generate an abstract class:

final JDefinedClass modelClass = mutePackage._class(JMod.PUBLIC |
JMod.ABSTRACT, classContext.ref.name()+"Model");

I get an exception:

java.lang.IllegalArgumentException: Illegal modifiers for class: public
abstract
        at com.sun.codemodel.JMods.check(JMods.java:47)
        at com.sun.codemodel.JMods.forClass(JMods.java:69)
...

In JMods:

     private static int CLASS
        = (JMod.PUBLIC | JMod.PRIVATE | JMod.PROTECTED
           | JMod.STATIC | JMod.FINAL);

     private static void check(int mods, int legal, String what) {
        if ((mods & ~legal) != 0)
            throw new IllegalArgumentException("Illegal modifiers for "
                                               + what + ": "
                                               + new JMods(mods).toString());
     }


Only PUBLIC, PRIVATE, PROTECTED, STATIC, FINAL modifier are allowed.
I think classes should be allowed to be ABSTRACT as well.


Bye.
/lexi

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net