Code compiles only when static methods are defined in a certain order

CC: Sun C++ 5.9 SunOS_i386 Patch 124864-10 fails to compile the code below with
"/tmp/notagain.cc", line 9: Error: static X::decode<X::T>() already had a body defined.
"/tmp/notagain.cc", line 13: Error: Cannot use int* to initialize double*.
struct X
    static int* decode(int Val);
    static int* decode();
    template<typename T> static T* decode() { return new T; }
int* X::decode(int t) { return new int(t); }
int* X::decode() { return new int; }
int main() {
        int* pi = X::decode();
        double* pd = X::decode<double>();
        return 0;
}It actually manages to compile it if the struct X is defined slightly differently:
struct X
    static int* decode(int Val);
    template<typename T> static T* decode() { return new T; }
    static int* decode();
int* X::decode(int t) { return new int(t); }
int* X::decode() { return new int; }
int main() {
        int* pi = X::decode();
        double* pd = X::decode<double>();
        return 0;
}None of this happens with g++ or Intel C++.

Thanks for filing the bug report. It has been assigned CR 6935439, and should be visible at [http://bugs.sun.com] in a day or two.

Similar Messages

  • Callback function may be NULL only when database handles are read-only

    Hi,
    I am getting some errors when trying to run my java code that will try to open a few cursors and join them to fetch the data.
    ath .:/usr/src/db-4.7.25.NC/java/src:/usr/local/BerkeleyDB.4.7/lib/db.jar bdbtest
    MyDbs: Callback function may be NULL only when database handles are read-only
    Error on inventory secondary cursor:
    java.lang.IllegalArgumentException: Invalid argument: Callback function may be NULL only when database handles are read-only
    What does that error mean? How can I resolve it? I am following the sample program and I can't find anything related.
    Here is my code.
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Database;
    import com.sleepycat.db.SecondaryDatabase;
    import com.sleepycat.db.DatabaseConfig;
    import com.sleepycat.db.DatabaseType;
    import java.io.FileNotFoundException;
    import com.sleepycat.db.DatabaseEntry;
    import com.sleepycat.db.SecondaryCursor;
    import com.sleepycat.db.Cursor;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.LockMode;
    import com.sleepycat.db.OperationStatus;
    import com.sleepycat.db.SecondaryCursor;
    import com.sleepycat.db.SecondaryConfig;
    import com.sleepycat.bind.EntryBinding;
    import com.sleepycat.bind.serial.SerialBinding;
    import com.sleepycat.bind.tuple.TupleBinding;
    import com.sleepycat.db.Cursor;
    import com.sleepycat.db.DatabaseEntry;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.LockMode;
    import com.sleepycat.db.OperationStatus;
    import com.sleepycat.db.SecondaryCursor;
    public class bdbtest {
    public static void main(String args[]) {
    SecondaryDatabase myDatabase = null;
         Database primDB = null;
         Cursor cursor = null;
    try {
    // Open the database. Create it if it does not already exist.
    DatabaseConfig dbConfig = new DatabaseConfig();
         dbConfig.setErrorStream(System.err);
    dbConfig.setErrorPrefix("MyDbs");
         dbConfig.setType(DatabaseType.BTREE);
    dbConfig.setAllowCreate(true);
         SecondaryConfig mySecConfig = new SecondaryConfig();
         mySecConfig.setErrorStream(System.err);
    mySecConfig.setErrorPrefix("MyDbs");
         mySecConfig.setType(DatabaseType.BTREE);
    mySecConfig.setAllowCreate(true);
         primDB = new Database("/tmp/bdb_ca_db.db",
    "bdb_ca_db",
    dbConfig);
    dbConfig.setAllowCreate(true);
    myDatabase = new SecondaryDatabase("/tmp/bdb_ca_sdb.db",
    "ca_sdb_res_alias",
    primDB,
    mySecConfig);
         String res ="in-1";
         SecondaryCursor secCursor = null;
         DatabaseEntry searchKey =
    new DatabaseEntry(res.getBytes("UTF-8"));
         DatabaseEntry foundKey = new DatabaseEntry();
    DatabaseEntry foundData = new DatabaseEntry();
         secCursor =
    myDatabase.openSecondaryCursor(null, config);
    // Search for the secondary database entry.
    OperationStatus retVal =
    secCursor.getSearchKey(searchKey, foundKey,
    foundData, LockMode.DEFAULT);
         if (retVal == OperationStatus.SUCCESS){
              System.out.println("succ");
         }else {
              System.out.println("fail");
    while (retVal == OperationStatus.SUCCESS) {
    String keyString = new String(foundKey.getData(), "UTF-8");
    String dataString = new String(foundData.getData(), "UTF-8");
    System.out.println("Key | Data : " + keyString + " | " +
    dataString + "");
    secCursor.getNextDup(searchKey, foundKey,foundData, LockMode.DEFAULT);
         } catch (Exception e) {
    System.err.println("Error on inventory secondary cursor:");
    System.err.println(e.toString());
    e.printStackTrace();
         finally {
    // Make sure to close the cursor
              try {
              cursor.close();
              }catch (com.sleepycat.db.DatabaseException e) {
    System.out.println("All done.");
    }

    Hi,
    The error is because either the primary database or the secondary database is configured as read only and the callback to create the secondary keys is null. A quick glance of the code, it appears as if you did not set up the secondary database correctly. In the Getting Started Guide for JAVA API chap 10, we have detailed information on what needs to be done as well as a code example. Please refer to http://www.oracle.com/technology/documentation/berkeley-db/db/gsg/JAVA/index.html and look for Chap 10.
    regards,
    Mike Brey, Oracle Berkeley DB

  • In my library, under the Artist column only...items are not listed in alpha order.  How can I get that to happen?

    In my library, under the Artist column only...items are not listed in alpha order.  How can I get that to happen?

    Same deal as your other thread but with Artist/Sort Artist:
    https://discussions.apple.com/message/25561674#25561674
    For more info. on how iTunes organizes things see Grouping tracks into albums.
    tt2

  • Static method are not overriden ?

    Hi,
    as I try to understand java in depth, I come back with this simple question:
    public class hiddenVar1 {
    boolean aVariable=true;
    public static void main (String [] args) {
    System.out.println("Hello");
    public class hiddenVar2 extends hiddenVar1 {
    boolean aVariable;
    public hiddenVar2() {
    aMethod();
    void aMethod() {
    aVariable = false;
    System.out.println(aVariable);
    System.out.println(super.aVariable);
    public static void main (String [] args) {
    new hiddenVar2();
    hiddenVar1.main(new String[2]);
    The result is :
    false
    true
    Hello
    Conclusion:
    the main static method of hiddenVar1 as not been overrided by the main static method in hiddenVar2.
    So inheritance does not apply for static method ?
    Any explanation ?
    Thank's.
    John

    Firstly i think there should not be two public classes in only one file it gives compile time error.
    Secondly the output is correct.
    Static methods cannot be overriden because it will get initialize when u create instance of the class so u r calling
    -- new hiddenVar2();
    so it calls the constructor in that respective method is called.
    And the second line is calling the super class so it calls the main method of that class and prints "hello"
    hiddenVar1.main(new String[2]);

  • Email notification to end-user only when both resources are provisioned

    Hello Gurus,
    My client has a requirement where the end-user needs to be sent an email notification as soon as his account gets created in OID and EBS.
    So the next time when the user logs in; he should be able to access both his accounts. But the email should be sent only when the 2 accounts are succesfully created.
    How can we do that by means of process tasks and adapters?
    Can anybody give an idea about how can we provide this functionality in the best way OOTB or custom way (code snippet) ?
    Thanks,
    - JHB.

    Hi
    If you are using OOTB connectors for OID and EBS then this requirement can be achieved by using OIM API.
    On successful response of 'Create user' in OID or EBS call a custom adapter and check for the provisioned status of other RO i.e. on completion of Create User task of OID, check for prov status of EBS and send the mail accordingly.
    If the user is not provisioned to the other resource, then do not send the mail. Otherwise if the user is already provisioned to the other resource, send the mail to the user. This approach is based on the assumption that there is no link between the provisioning to OID and provisioning to EBS.
    Correct me if I missed something.
    Hope this helps.

  • Initializer block not called when static method called

    public class Initializer {
         Initializer(){
              System.out.println("Constructor called");
                   System.out.println("CLASS INITIALIZED");
         static void method(){
              System.out.println("Static method called");
         public static void main(String[] args) {
              Initializer.method();
    From the JLS
    A class or interface type T will be initialized immediately before the first occurrence of any one of the following:
    T is a class and an instance of T is created.
    T is a class and a static method declared by T is invoked.
    [b]
    But when i call the static method , if the class is initialized shouldnt the initializer block be called, it is not called, why.

    Perhaps running something like this will add a little more colour?:
    public class Initializer {
        static {
            System.out.println("First static initializer");
            System.out.println("First instance initializer");
        Initializer() {
            System.out.println("Constructor");
        static {
            System.out.println("Second static initializer");
            System.out.println("Second instance initializer");
        static void staticMethod() {
            System.out.println("staticMethod");
        void instanceMethod() {
            System.out.println("instanceMethod");
        public static void main(String[] args) {
            System.out.println("main");
            staticMethod();
            new Initializer().instanceMethod();
    }

  • Ghost clip appears in canvas only when other clips are placed in its place

    Gd afternoon, this may sound crazy but here we go. the space on the timeline is blank, and when the sequence is played the blank section shows nothing but black screen. however when i drop any clip in the empty space on the timeline an old clip I changed the speed of shows over whatever clip i just dropped in the empty spot. Again, when the spot is empty nothing shows, only when a different clip is placed in that spot does the "ghost" clip appear over the new clip and the space that the ghost clip holds shows a blue rendered line for the speed that was changed.
    How do I get rid of this ghost clip?

    +thanks, i tried to delete the rendered clip but no help+
    No, what is required when the problem reaches the stage you described is to delete ALL of the render files for that sequence. One way to do that is to go to Tools > Render Manager and navigate to the problem sequence and clicking in the Remove column for that sequence. Then click OK.
    That will delete all of the render files for the sequence. Then you re-render. This sometimes works, as I said.

  • Problems with Compiled files when Adobe Jetforms are used

    Hi,
    I am taking outputs of Customer Facing Documents from SAP R/3 using Jetform Output Designer Version 5.4.0.130.
    The printer I am using is HP LaserJet 5100 Series. From the information I gathered this uses PCL 6. Therefore I compiled the file with the presentment target HP Laserjet 5000/5000N(PCL6)-[hp5000x]. When I use the PDF viewer as the default it gives me perfect alignment of the various fields. However when I take a printout everything is disturbed.
    Can you please suggest, what is the best approach to take.
    Thanks in advance.
    Regards,
    Paul

    There is a difference in resolution between PDF print and PCL print. E.g. PDF is default 1000 dpi, which is fine for screen view, yet most printers are 300 dpi or 600 dpi.
    If you make a copy of the PDF.ICS to apv_PDF.ICS. You can change the resolution by opening the file with a text editor like Notepad. Set the value to match your printer. Choose your custom PDF printer driver in Output Designer and recompile the form.
    You'll find it in the \Config directory where your designer is installed. ..\JetForm\Output Designer\Config

  • Data records in an IDoc getting erased, when conversion rules are defined

    Hello ,
    We are sending IDocs of message type GLMAST & COELEM from a system(version 4.7) to another system (version 4.6B).
    The segment data in the IDocs are changed using the user exit enhancement KKCD0001. The function exits used are EXIT_SAPFKCIM_001 and EXIT_SAPFKCIM_002.
    If there is no conversion rule defined in the receiver system, for the segments, the IDocs are posted correctly in the receiving system.  But if we define conversion rules , then the data records for all the segments for which conversion rule is defined are getting erased, and an error occurs during processing of IDocs
    Please let me know what can be the the reason behind this issue..And how to solve this..
    Thanks in advance,
    Afsar

    Issue solved

  • Add counter only when duplicate segments are present in mapping

    Hi Gurus,
    I have a FILE to FILE scenario, and the source file is as this:
    aaa aaa aaa
    bbb bbb bbb
    ccc ccc ccc
    ccc ccc ccc
    ddd ddd ddd
    and the structure will be as:
    <Row>
    field1> aaa
    field2> aaa
    field3> aaa
    </Row>
    <Row>
    field1> bbb
    field2> bbb
    field3> bbb
    </Row>
    etc
    In the target structure, I need to have the same elements, but there is one more field which is a counter field that need to be increased for each repetitive line and then reset back to 1 for a non-unique one.
    So regarding the source structure, the target one should be as this:
    <Row>
    field1> aaa
    field2> aaa
    field3> aaa
    counter> 1
    </Row>
    <Row>
    field1> bbb
    field2> bbb
    field3> bbb
    counter> 1
    </Row>
    <Row>
    field1> ccc
    field2> ccc
    field3> ccc
    counter> 1
    </Row>
    <Row>
    field1> ccc
    field2> ccc
    field3> ccc
    counter> 2
    </Row>
    <Row>
    field1> ddd
    field2> ddd
    field3> ddd
    counter> 1
    </Row>
    etc
    I am asumming that I need to do this using UDF and local variables, but what I don't know is how can I compare the actual Row data with the previous one so I can increase the counter (or reset it).
    Any idea on what can I do here?

    Hi,
      You can try the below logic to get the counter incremented according to the row. For all fields its simple one to one mapping except counter.
       Row----Row
       field1---field1
       field2---field2 etc
    for counter concat field1,field2,field3 with empty delimiter ...
    concatinationof3fields--removecontext-sort-splitbyvaluechange-UDF-splitbyeachValue--counter
    **execution type of UDF is Allvalues of a context.
    public void UDF(String[] var1, ResultList result, Container container) throws StreamTransformationException{
              ArrayList aList =  new ArrayList();
         int counter = 1;
         int cnt = 1;
         for(int i=0; i<var1.length; i++){
                  if(aList.contains(var1<i>)){
              cnt++;
              result.addValue(cnt);
                                 else{
              aList.add(var1<i>);
              result.addValue(counter);
    Regards
    Priyanka

  • I am getting Error code 100 only when trying to purchase Logic Pro from the App Store. Why?

    I have done all the regular trouble shooting, can download a free app just fine. I have more than enough money available for the purchase, but Logic Pro is giving me the error 100, and saying to contact I Tunes Support. I have, but don't really want to wait to start working on the projects I need to finish if there is a quick fix out there. Please help if anyone knows what's up? Thanks!

    it keeps crashing my mac out and restarting
    The Logic Pro app is crashing?
    Try deleting the app using this free utility >  Uninstall your apps easily. MacUpdate.com
    That will remove all the associated files not just the app itself.
    Then re download the app.
    How to re download apps from the Mac App Store:
    Open the App Store. From the menu bar click Store > Sign In
    Click Purchases from the top of the App Store window.
    Select which apps you want to re download. Then right or control click where you see Installed  then click Install.
    Make sure and use the same Apple ID used for the original purchase.

  • How to add actions only when the stage playhead passes a label/certain time?

    I have an animation that is 2 seconds long. On the 1 sec mark there is sym.stop(); and a label called 'in'. At the 2 sec mark there is another sym.stop();
    So what I want to happen is for the animation to play up until 'in', then on mouseenter for the stage have sym.play();, and on mouseleave sym.playReverse();. This will make it so that only the second half of the animation will get played on mouseenter/leave.
    My problem is that the mouseenter/leave also gets applied to the first half of the animation, not allowing the second half to animate if the user mouses over during the first half. I know this requires an if statement but I don't know how to write it. So it would be something like this: if the playhead reaches 'in', apply mouseenter/leave actions.

    yes, I am. By the way I've found the solution. Someone might find this usefull.
    In design.xml having
    <component name="ExtendedTextInput" namespace="mynamespace" category="beta" displayName="ExtendedTextInput"/>
    use this
    <component name="ExtendedTextInput" namespace="mynamespace" category="beta" displayName="ExtendedTextInput">
            <defaultAttribute name="text" value="ExtendedTextInput"/>
        </component>
    so when adding this component to design view, it will have text setted to value ('ExtendedTextInput' in this case).

  • Issue warning message when duplicate material are enter on a purchase order

    Hi All,
    Is there any possibility  to give a message in   me21n if we enter a material which in already maintained as one line item  to create PO. To issue messages in sales order there is an exit. I tried with the badi ME_PROCESS_PO_CUST. I was struck here. Please suggest me good idea how to do this.Thanks to all.
    In Sales order i resolved in this way.
    LOOP AT xvbap
       WHERE matnr EQ vbap-matnr
             AND posnr NE vbap-posnr
             AND kwmeng NE 0.
       MESSAGE  'Material is already on the order' type 'I'.
    ENDLOOP.
    ENDFORM.
    Regars,
    Madhu.

    closed.

  • Re: No late binding for static methods

    Only the sale class has a showAdvertisement() method.
    When the compiler compiles that class it decides at compile time which exact method is called for each static method call (that's the big difference to non-static method calls: the exact method to be called is only decided at runtime in those cases).
    There's only one method showAdvertisement() and that is called in both cases in your code. Since that single method always calls the same static announcement() method, you will see the result you posted.

    JoachimSauer wrote:
    When the compiler compiles that class it decides at compile time which exact method is called for each static method call (that's the big difference to non-static method calls: the exact method to be called is only decided at runtime in those cases).I thought static methods were bound at classload-time. Demo:
    public class A {
        public static void f() {
            System.out.println("A.f");
    public class B extends A  {
        public static void f() {
            System.out.println("B.f");
    public class C  {
        public static void main(String[] args) {
            B.f();
    }If you run the above code, "A.f" is printed, as you would expect -- there is only one static method f defined.
    But if you uncomment the code in class B and recompile only it (not C!), then run C, you will get the output "B.f".
    If you run javap -c C you will see:
    public static void main(java.lang.String[]);
      Code:
       0:   invokestatic    #2; //Method B.f:()V
       3:   returnSo the byte code isn't binding the call to A.f at compile time. The choice is made at classload-time. That is why there are similar restrictions on hiding static methods as for overriding instance methods: [http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.8.3]

  • What 's the advantage of static method.

    I think if a method is declared as static, the program should allocate some spaces for the method when the program start. However, I found many static method in an erp open source project. What make me confused is that it will cost many spaces.
    Perhaps they want to lose some spaces for speed???
    Can somebody answer my question.thanks!

    > I think if a method is declared as static, the
    program should allocate some spaces for the method
    when the program start. However, I found many static
    method in an erp open source project. What make me
    confused is that it will cost many spaces.
    Perhaps they want to lose some spaces for speed???
    Can somebody answer my question.thanks!
    To be sincere, I've never thought about performance cost when static methods are used. I decide to create and use them mainly whether I have the "feeling" that it will provide me benefits, in terms of designing. Yes, it's like a feeling. I am not able to explain you why or how I have this feeling, I'm not native in English language, so choosing the appropriate words to explain my ideas sometimes is hard to me. Besides. I admit that I am a little bit lazy in this moment, I don't want to search through some dictionary...;-).
    I think the more you develop your abilities and skills in java programming, the more you can feel, you can have this "feeling", and naturally you figure out in which situations using static methods is a better choice.

Maybe you are looking for