Generating base classes

I've seen it hinted that generating the base class of an annotated class is possible--which insinuates there are multiple passes where the initial "extend FooGenerated" would fail with a class not found, then the processor sees Foo, generates "FooGenerated", and then the compiler retries compiling Foo with the now-present FooGenerated.
I can't get this to work--I'm not trying base classes, just a "Blah" dummy class.
Here is my annotation processor:
http://github.com/stephenh/bindgen/tree/master/src/main/org/exigencecorp/bindgen/Bindgen.java
And an example class with my annotation that references my dummy "Blah" class:
http://github.com/stephenh/bindgen/tree/master/src/example/org/exigencecorp/bindgen/example/Employee.java
But compiling this (with "ant jar compile-example") gives:
http://gist.github.com/42294
Blah.java shows up in "bin/example" (the output path of the ant javac task), but no Blah.class, nor any other .class files, which is kind of weird.
The build.xml is pretty simple, I think:
http://github.com/stephenh/bindgen/tree/master/build.xml
Is there something I'm missing to get this "users classes depending on generated classes" behavior to work?
Thanks.

Nevermind, this works if "FooGenerated" is in the same package as "Foo". I was trying to start with small steps and so started with the root package. I was too focused on the annotation processing details to overlook the obvious "this wouldn't even work in regular Java".

Similar Messages

  • Base classes generated by annotation processing

    I'm currently trying to figure out how to best reference code generated by annotation processors from non-generated code (and vice versa). One thing that seems to work is to generate source code for a base class of a hand-written class. If the base class needs to call methods in the hand-written class, it's possible to generate suitable abstract methods. Generated code can be put into separate methods.
    However, during the first round, the generated classes do not exist yet, and javac prints error messages. The compilation eventually succeeds. Is there some way to suppress those error messages? ECJ is worse in this regard, it doesn't produce class files in this case. Is this an ECJ bug, or is this approach to code generation simply not supported (and works with javac just by accident)?

    Is there some kind of meta-specification for JSR 269 that explains the design goals? Not really, only what is here http://jcp.org/en/jsr/detail?id=269
    With such a document, it might also be easier to figure out how processors are supposed to work.JSR 269 is designed to permit solutions to various complex scenarios rather than provide solutions. Those scenarios and their intended solution are not often obvious from the API specs.
    You might like to take a look at https://hickory.dev.java.net/ where I have a project to supply some tooling to assist annotation processor authors, and a wiki to document things. Allocating time to this is not easy, but the 3 packages in the API there are pretty robust. The test cases in source code for those have plenty of examples of some of the more complex design goals, such as the ability to write an annotation processor which works correctly in an incremental compile scenario, when the generated file derives from more than one source file, not all of which may be included in an incremental compile.
    Other than that, if you have any particular questions, just ask in this forum, and Joe (JSR 269 spec lead) or myself should be able to answer them for you.
    Bruce
    Edited by: brucechapman on Feb 4, 2008 1:35 PM

  • AS3: How to create one base class for classes loaded in multiple swfs?

    Our application have 3 different modules and all use
    fscommand and ExternalInterface alot. Now the problem is we are
    combining all those modules, but they all will reside in different
    swfs. Is there any way that they extend to same base class and its
    static members have only one instance accessible by all
    three?

    Hi,
    You can achieve this via Workshop 9.2 by using the exported Ant script for your project as follows:
    -Ensure that all Jars needed to resolve com.bea.p13n.property.EntityPropertyManager (this particular class is found in weblogic92/common/p13n/lib/p13n_ejb.jar) and all referenced classes are added to the Java build path for your WebLogic EJB project (Properties->Java Build Path->Libraries)
    -Export the "Workshop Ant Script" for your WebLogic EJB project (File->Export->Workshop Ant Script); this will generate a "build.xml" Ant script under your project root directory.
    -Edit this default build script as follows: in the call to the "ejbgen" task within the "build" target, add the attribute: propertyFile="ejbgen.properties"
    -Create a file "ejbgen.properties" under the root of your WebLogic EJB project and add the following entry:
    YourSessionBeanClassName.remote.baseClass=com.bea.p13n.property.EntityPropertyManager
    -Add a "<path refid="java.classpath"/>" within the "<classpath>" for the "java" task element that calls "weblogic.ejbc" (this will ensure that the p13n classes are resolved by EJBC)
    Follow the instructions for executing the Ant build script found here: http://edocs.bea.com/workshop/docs92/ws_platform/ideuserguide/conUseCustomAntBuild.html
    For more information on the EJBGen property file support, see: http://e-docs.bea.com/wls/docs92/ejb/EJBGen_reference.html

  • Warning :: Derived class hides the base class virtual function

    We are porting from CC5.3 to CC5.8 compiler with Sun Studio one compiler. After plenty of hurdles we are in the final stage of removing the warning messages... Amoung the plenty the following one is very common and in different files. Why am I getting this error in 5.8 and not in 5.3 compiler....
    Warning: derived_Object::markRead Hides the virtual function base_Object::markRead(ut_SourceCodeLocation&) const in a virtual base
    From this it is easily understandable that the base class mark read was hidden by derived class markRead... when we drive and override the derived class function.... It is all over the place....
    Thank you,
    Saravanan Kannan
    //public: using xx_Object :: markRead;
    virtual void markRead() const;

    The Sun C++ FAQ discusses the warning message:
    http://developers.sun.com/prodtech/cc/documentation/ss11/mr/READMEs/c++_faq.html#Coding1
    Notice that warnings are not necessarily errors. But I applaud your desire to fix the code so that it generates no warnings. I wish more of our customers could be persuaded to do the same. :-)
    C++ 5.3 issues this warning, by the way. Example:
    struct B { virtual int foo(int); };
    struct D : B { virtual int foo(double); }; // line 2
    D d;
    line 2: Warning: D::foo hides the virtual function B::foo(int).
    If for your particular code you do not see a warning with C++ 5.3, it would be due to a bug in C++ 5.3 that was later fixed.

  • How to specify a base class for Remote Interface in Workshop 9.2? -- URGENT

    Hi,
    I am trying to create a UUP EJB in WebLogic 9.2 workshop. I am using @FileGeneration to create my home & remote interfaces. And the generated remote interface is extending javax.ejb.EJBObject;I want my remote interface to extend com.bea.p13n.property.EntityPropertyManager which in turn implements javax.ejb.EJBObject. Can someone tell how i can do it in Workshop?.
    I came across Predefined Variable: remote.baseClass and as per docume
    ntation..."If specified, the value of this variable will be used as the base class for all generated remote classes. Where i should specify it?. @FileGeneration does nt have any option for it. Any help is grtly appreciated.
    Following are my code snippets:
    IMPL Class
    @FileGeneration(remoteClass = Constants.Bool.TRUE,remoteHome = Constants.Bool.TRUE, localClass = Constants.Bool.FALSE, localHome = Constants.Bool.FALSE,remoteClassName = "MyEntityPropertyManager",remoteHomeName = "MyEntityPropertyManagerHome")
    public class MyEntityPropertyManagerImpl extends GenericSessionBean implements
              SessionBean {
    //code
    }

    This question was posted to both the bea.workshop.developer.general and weblogic.developer.interest.workshop (I had replied to the later on 10/19); after seeing an identical question today on this list want to include a reference to that reply here:
    http://forums.bea.com/bea/message.jspa?messageID=600044925&tstart=0
    -Rob

  • Force JAXB  to use custom base class on a per complexType basis?

    I know I can <superClass="Blah"> in <globalBindings> to make all classes use "Blah" as a super class. Is there a way to get a complexType to use its own user defined base class?
    I'd like the JAXB compiler to generate the following classes for the schema below:
    What I'd like JAXB compiler to create:
    class A extends MyUserDefinedAbstractA{}...
    class B extends MyUserDefinedAbstractB{};For my own base classes:
    abstract class MyUserDefinedAbstractA {}
    abstract class MyUserDefinedAbstractB {}Based on the following schema:
    <complexType name="A"> .... </complexType>
    <complexType name="B"> .... </complexType>What is the alternative if I can't do the above? I'd like the generated classes to more than just hold data. I'd like them to have methods that can operate on the data as well.
    Regards,
    Monty
    Edited by: CuriousJorj on Jul 9, 2008 6:33 AM
    Edited by: CuriousJorj on Jul 9, 2008 6:35 AM

    There are some Safari extensions that can block JavaScript by domain, but you'll have to search for them.

  • Generating NodeFactory Classes

    Hi,
    I've successfully used the NodeFactory mechanism to generate my
    own (hand crafted) XMLElement sub-classes when parsing an XML
    string. What I'd also like to do is to create an XMLDocument
    explicitly within my code (ie. creating the XMLElement classes
    and stitching them together into an in memory XMLDocument) using
    the same NodeFactory generated sub-classes.
    This is to accomodate a generic method of mine that takes an in-
    memory XMLDocument, and I want to run this either from a parsed
    XML string or from an in-memory XMLDocument that some other code
    has created.
    I can build up an in memory XMLDocument using the regular
    XMLDocument.createElement method but this only creates the base
    XMLElement classes, not my NodeFactory sub-classes. Is there any
    way I can get the XMLDocument.createElement method to create my
    NodeFactory sub-classes instead?
    Yours,
    Dave
    null

    Dave Barton (guest) wrote:
    : Oracle XML Team wrote:
    : : Dave Barton (guest) wrote:
    : : : Hi,
    : : : I've successfully used the NodeFactory mechanism to
    generate
    : : my
    : : : own (hand crafted) XMLElement sub-classes when parsing an
    : XML
    : : : string. What I'd also like to do is to create an
    XMLDocument
    : : : explicitly within my code (ie. creating the XMLElement
    : classes
    : : : and stitching them together into an in memory XMLDocument)
    : : using
    : : : the same NodeFactory generated sub-classes.
    : : : This is to accomodate a generic method of mine that takes
    an
    : : in-
    : : : memory XMLDocument, and I want to run this either from a
    : : parsed
    : : : XML string or from an in-memory XMLDocument that some
    other
    : : code
    : : : has created.
    : : : I can build up an in memory XMLDocument using the regular
    : : : XMLDocument.createElement method but this only creates the
    : : base
    : : : XMLElement classes, not my NodeFactory sub-classes. Is
    there
    : : any
    : : : way I can get the XMLDocument.createElement method to
    create
    : : my
    : : : NodeFactory sub-classes instead?
    : : : Yours,
    : : : Dave
    : : Currently, we do not support generating NodeFactory
    classes.
    : : This has been recommended to our development team.
    : : How important is this method to you?
    : : Are any other Forum members interested?
    : : Oracle XML Team
    : : http://technet.oracle.com
    : : Oracle Technology Network
    : Thanks for the response. I can get around it by creating an
    XML
    : string and then parsing it, but this is obviously an extra
    : performance hit that I could do without. I'd vote for being
    able
    : to create NodeFactory classes.
    : The other thing in this area that struck me as being a "nice
    to
    : have" would be to get the Class Generator tool to generate
    : NodeFactory compatible classes (ie. inherit from XMLElement
    and
    : perhaps generate methods that abstract away the attributes and
    : elements, so if there was an attribute called "text" a method
    : called "get_text" would be created which returns a string by
    : getting the attribute using the base class "getAttribute"
    method
    : with the "text" attribute name). I'm currently doing this
    stuff
    : by hand.
    : Dave
    We have had that along with a document abstraction as a Class
    Generator enhancement request which we are considering for a
    future release.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • Using base classes for common attributes

    Can TopLink handle use of non-mapped abstract base classes? There are a number of fields that are common to each and every one of my domain objects which, following good OO design principals, are moved up to a common superclass. So I have:
    public abstract class AbstractDomainObject
    private Integer id;
    private Date dateCreated;
    private Integer creatorId;
    private Date dateModified;
    private Integer modifierId;
    // ... appropriate attribute accessors
    Then a concrete class which gets mappped in Workbench:
    public class Address
    extends AbstractDomainObject
    ... specific attributes
    I tried mapping all the specific attributes explicitly defined in the Address class and then using "Map Inherited Fields > To SuperClass" in Workbench. However, when attempting to test my mappings in the SessionConsole, only the attributes explicitly defined on Address are present in the SELECT clause.
    Can what I am trying be done? If so, how?

    Steve,
    What you are trying to do is very common and the process you described is exactly how map the class. I will summarize a couple of points for mapping this scenario.
    1. You only need to import Address in and map it. If AbstractDomainObject is imported into the Mapping Workbench make sure that it is disabled. The abstract class is only required on the project's CLASSPATH.
    2. You should not enable inheritance for the Address class. Inheritance is for situations where the abstract base class has its own independent table. I am assuming that your Address class has its own table that contains fields for all of the attributes it needs along with those of the abstract base class.
    Assuming these conditions are met then TopLink will work fine with you Address class just as if it had all of the inherited attributes directly.
    If you are still having trouble take a look through your generated project (XML or Java) to ensure that mappings exist in Address for All attributes. If the project looks good then I am at a loss. Customers have been using this pattern of use for over 5 years with TopLink and Java inheritance.
    Cheers,
    Doug

  • JAXB problem generating java classes

    I'm doing some integration and have received a schema from the vendor the other day. When I try to generate java classes with the jaxb compiler I get this output
    parsing a schema...
    [ERROR] Property "Value" is already defined.
      line 14 of jar:file:/C:/win32app/Java/jdk6/lib/tools.jar!/com/sun/xml/internal/xsom/impl/parser/datatypes.xsd
    [ERROR] The following location is relevant to the above error
      line 384 of file:/C:/code/sca-ecr.xsd
    Failed to parse a schema.
        <xsd:complexType name="options">
            <xsd:sequence>
                <xsd:element name="option" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:simpleContent>
                            <xsd:extension base="xsd:string">
    (Line 384)                  <xsd:attribute name="value" type="xsd:string"/>
                            </xsd:extension>
                        </xsd:simpleContent>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>So, googling about this I came across these to articles that almost describes my problem.
    http://weblogs.java.net/blog/kohsuke/archive/2005/05/compiling_mathm_1.html
    https://jaxb.dev.java.net/guide/Dealing_with_errors.htmlAdding the this code did not help. Downloading JAXB 2.1.4 did not help, adding the -extension parameter still same result.
            <xsd:annotation>
              <xsd:appinfo>           
                <jaxb:property name="someAttribute" />
              </xsd:appinfo>
            </xsd:annotation>      Why is jaxb failing ? Could it be that and attribute is not allowed to be called "value" ?
    Any answers will do
    regards abq

    Well, after hours of digging I found a solution which actually was right in front of me the whole time.
    This is how I edited the schema.
        <xsd:complexType name="options">
            <xsd:sequence>
                <xsd:element name="option" maxOccurs="unbounded" >
                    <xsd:complexType>
                        <xsd:simpleContent>
                            <xsd:extension base="xsd:string">
                               <xsd:attribute name="value" type="xsd:string" >
                                  <xsd:annotation><xsd:appinfo>
                                    <jaxb:property name="realValue" />
                                  </xsd:appinfo></xsd:annotation>
                                 </xsd:attribute>
                            </xsd:extension>
                        </xsd:simpleContent>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>Before, I placed the <xsd:annotation> tag efter the first line but inside the <xsd:attribute> made much better if you would like it to work.
    When marshling an @XmlRoot object will produce valid xml code. So even though that the server have a different xml schema, they will be able to talk to each other.
    abq

  • Serial UID in base class or interface is sufficient

    Let's say i have 3 classes extending from a base class. Is it okay if the base class has serial UID defined as anyways those 3 other classes are extending from it. Or is it compulsory to define serial UID in every class?
    Same applies for interface.

    Defining static serial uid in baseclass doesn't means that it will be also a serial UID for derived class. You should explicitly define serialVersionUID in the derived class too.
    serial UID is not needed as such since its value is generated at runtime for each class that implements serialzable. But it is highly recommended as value generated at runtime can be different on different compilers.

  • JAXB 1 : generating simpleTypes classes

    Sorry, I posted an uncompleted message.
    Hello, I'm new to JAXB technology.
    Since I'm working with j2sdk 1.4 I c'ant use JAXB 2, so I'm using JAXB 1.0.6.
    When I call the xjc ant task, my java classes are generated... buy simple types do not generate any java class.
    Let's say I have the following xsd:
    <xs:complexType name="EXAMPLE">
    <xs:sequence>
    <xs:element name="market-type" type="po:market-type"/>
    </xs:sequence>
    </xs:complexType>
    <xs:simpleType name="MARKET-TYPE">
    <xs:restriction base = "xs:string">
    <xs:enumeration value = "PRIM"/>
    <xs:enumeration value = "SECOND"/>
    </xs:restriction>
    </xs:simpleType> After xjc compilation I have a EXAMPLE Java class, but its element "market-type" is a String and not a MARKET-TYPE as I expected.
    Is it normal? Can I customize the output in order to generate java classes for simpleTypes?

    The base data type of the simpleType MARKET-TYPE is xsd:string.

  • Error when generating Java Classes from XSD

    I'm getting the following error when using oragc to generate Java classes from a schema:
    Error: Schema Class Generator failed to generate classes. oracle.xml.parser.schema.XSDException: Invalid facet 'pattern' in element 'simpleType'
    Any thoughts?
    Here's the part where it is getting the error:
    +111 <!-- Timestamp Type - Timezone portion is required and fractional seconds are prohibited -->
    +112 <xsd:simpleType name="TimestampType">
    +113 <xsd:annotation>
    +114 <xsd:documentation>Base type for a date and time stamp</xsd:documentation>
    +115 </xsd:annotation>
    +116 <xsd:restriction base="xsd:dateTime">
    +117 <xsd:pattern value="[1-9][0-9]{3}\-.+T[^\.]+(Z|[\+\-].+)" />
    +118 </xsd:restriction>
    +119 </xsd:simpleType>

    I would recommend using JAXB instead of the Oracle class generator. This will give a standards based object-to-XML platform.
    Oracle provides two JAXB implementations: one in the TopLink product, and the other in the XDK.
    For an example of using TopLink JAXB see:
    http://www.oracle.com/technology/products/ias/toplink/technical/tips/jaxb/index.htm
    TopLink also provides the ability to map existing Java objects to an existing XML Schema, for an example of this see:
    http://www.oracle.com/technology/products/ias/toplink/technical/tips/ox/index.htm
    -Blaise

  • Symbols + Base-Class Workflow

    I frequently create a lot of Library Symbols, export for Actionscript, letting Flash auto-generate the Class & extending a custom base-class in order to give them all custom functionality w/out having to create a Class for each, and/or without having to create a FactoryClass for instantiating X number of ClassObjects for each Symbol to be added to.
    It's really fast for prototyping, and with this workflow I've only hit a few obstacles.  Those are:
    1 - If the Symbol has children you cannot give the children instance-names, else the compiler gives an error related to automatically declaring stage instances.  Two workarounds for this are that you can uncheck automatically declare stage instances, and do it manually in your base-class.  or you can avoid using instance-names, and use getChildAt().
    2 - If the Symbol is a MovieClip, the timeline doesn't inherit the base-classes imports.  I don't have a workaround for this.
    My question is, are these limitations that could be addressed by Adobe's Flash team, or are they limitations that are unavoidable without altering the workflow?

    Vote for this idea at ideas.adobe.com Flash Professional: http://tinyurl.com/2bxew2x
    Problem Description:
    Using the Library to export Symbols for Actionscript hits a severe wall when Symbols use auto-generated classes + base-classes.  Child instances are declared as their auto-generated class type instead of their base-class.  The result is that you cannot create 2 Library Symbols with auto-generated classes which inherit from a user-defined base-class which have named child instances with auto-generated classes & a user-defined base-class.
    Steps to Reproduce:
    1.     Create 2 Library Symbols, export for Actionscript with base-class "Character" which extends Sprite. Let Flash auto-generate Class names "Character1" & "Character2".
    2.     Create 2 more Library Symbols, export for Actionscript with base-class "Head" which extends Sprite. Let Flash auto-generate Class names "Character1Head" & "Character2Head".
    3.     Place an instance of Character1 on the stage, and give it a child instance of "Character1Head" named "head".
    4.     Place an instance of Character2 on the stage, and give it a child instance of "Character2Head" named "head".
    5.     Test Movie or Publish
    Actual Result:
    Warning: All instances named 'head' will be automatically declared as "Character1Head" in symbols that use "Character" as their base class. In symbols that are linked to user-defined base classes, instances with the same name must be of the same type.
    Expected Result:
    Flash should declare all instances named "head" as their base-class type "Head" when using auto-generated Classes.  Save this workflow!!!

  • Class override, how to create the child class and then the base class

    I started to write a program for a smart DMM, the problem is every version of the DMM the company change the communication commend.
    My idea is to write a child class for every DMM version and every SubVI of the child will override the base class SubVI.
    My problem is, i want first to create one child class and after i will see every thing is work,  start to create the base class. that way i will see if am thinking the right way.
    My question is
    How can i create a child class and then create the base class and configure the SubVi of the child class to be Override of the base class?
    I tried to search in the property of the class but i didn't see nothing.
    Thanks
    Solved!
    Go to Solution.

    This can be done and I've done it on occasion.
    You simply create the base class with the dynamic dispatch methods you require (connector panes need to be identical to thos of the child class).
    Then set the inheritance of the class to inherit from this base class.  If your method is defined as a dynamic dispatch method in the parent, you'll most likely now have some errors (unless your child method was already DD in which case you might just be OK already).
    To change the inheritance of a class, right-click the properties of the class in your project and select properties.  I believe the ineritance tree is at the lower end of the properties.  Click on the "change inheritance" (or something similar) to choose the class from which you now wish to inherit.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • How to generate a class automatically in JDev

    Suppose from OS side, I create a new empty Java file in the src directory of a project in JDev. Then in JDev, I click on the "refresh"/reload button for that project. Now I see the new java file. Double click it to open it; it is blank. In this case, how can I generate a class using the file name as the class name, and a default constructor or even a main method etc.?
    Is there any convenient way of doing this, rather than going to the usual route, which is File menu, then new, java file, from that UI to give a class name, choose to include a main method etc..
    Thank you.

    Duncan Mills blogged about how to build your own templates http://blogs.oracle.com/groundside/entry/adventures_in_adf_logging_part1
    Not exactly your case, but you should get the idea.
    Timo

Maybe you are looking for