Initialization order inconsistency with override

Initialisation order is inconsistent depending on whether a variable is overridden or not.
Two questions -
1. Is this supposed to be the case, or is it a bug?
2. If it is supposed to be the case, why did Sun decide to make it work like that?
For example, try the following code:
package javafxapplicationtest;
class Super {
    public-read var overriddenVar = "zero";
class A extends Super {
    public-read var b = B {}
    public-read override var overriddenVar = b.value;
    public-read var newVar = b.value;
class B {
    public var value = "one"
var a = A {};
println("b {a.b}");
println("b.value {a.b.value}");
println("a.overriddenVar {a.overriddenVar}");
println("a.newVar {a.newVar}");It produces:
b javafxapplicationtest.Main$B@175093f1
b.value one
a.overriddenVar
a.newVar oneNote first that a.overriddenVar and a.newVar get different values. Note also that a.overriddenVar is neither the value from the superclass nor the naively expected) value from the assignment.
I suspect this is an initialisation order issue -- the override causing b to be assigned when newVar is set, but not when overriddenVar is set. However it is stunningly unintuitive, as it breaks the natural "happens before" expectation of each line happening before the next line within the same context.
As well as being anti-intuitive, it is also hair-pullingly irritating. How many use cases are there where you want the overridden variable assignment to deliberately try to "catch the null" and get in there before the variable it is referencing gets initialised/assigned even though it is written afterwards?
For a concrete case, consider the code on [my blog post|http://wbillingsley.blogspot.com/2010/03/javafx-initialisation-craziness.html]: You have a custom control and want to wire mouse events through to your custom skin's Behavior. The events aren't wired because onMousePressed is an overridden variable.

This is hair-pulling irritating. I just spent hours trying to figure out why the following wouldn't work until I came across your post:
public class MyStage extends Stage {
    def myTextBox: TextBox = TextBox {
        text: "Test"
    override var scene = Scene {
        width: 1024
        height: 768
        content: [
            myTextBox
}It looks like the answer is that overridden members are initialized before other members of the same class. Specifically, the overridden scene member is initialized before myTextBox. I too would love to know why it works this way, since it seems backwards. It would be nice if the compiler at least told you it was going to ignore your code, instead of just doing it silently.
I suppose the solution could be something like this, but I'd love to hear of cleaner alternatives:
public class MyStage extends Stage {
    def myTextBox: TextBox = TextBox {
        text: "Test"
    def localScene = Scene {
        width: 1024
        height: 768
        content: [
            myTextBox
    init {
        scene = localScene;
}<sarc>
Or I suppose I could create my UI in a single giant FX script file, like a lot of the examples out there.
Hey, at least it's using declarative syntax so it's cool, right?
</sarc>

Similar Messages

  • Error at sales order: Inconsistent characteristic value assignment

    Hi SAPians
    There is a problem in variant configuration. I have configurable materials at sales order level with BOMs and super BOMs. When I am executing the scenario, not able to process further after selecting characteristic values for a configurable material. The error saying " Inconsistent  characteristic value assignment". I checked all the relevant master data, every thing is okay. But I am not able to proceed further. Can any one provide some valuable inputs for this.
    Raksha.

    Hi
    Did u create variant table (CU61) if not plz and try to make it by tick mark of Decision table..
    u can check assignmebt consitance thru CU60 ..if there again blank plz maintain it manually..
    basically wt happened during creation of Characteristics and assignment of value in value tab .. there is indicator ..which influence assignment consistance..
    hope u may get clue.
    correct me if i went wrong..
    thanks
    mk

  • How to ensure multiple nested classes static readonly initialization orders

    Hello,
    I am emulating the Java Enumeration in a first class class, with static readonly field initialization.
    In an effort to further categorize some instances, I embed them in nested classes. Something like this.
    class A : Enumeration
    public static class CatB
    public static readonly A FirstInstance = new B();
    public static readonly A SecondInstance = new B();
    public static class CatC
    public static readonly A ThirdInstance = new C();
    public static readonly A FourthInstance = new C();
    class B : A
    class C : A
    So far so good.
    One strain of Enumeration has built-in Ordinals, so I initialize them in the static ctor, or I make an effort to.
    static A()
    var values = GetValues().ToList();
    var ordinal = 0;
    values.ForEach(v => v.Ordinal = ++ordinal);
    Also, in places, so far so good.
    However, in a main method, I am referencing one of the enumerated instances, so calls to my GetValues() is returning nulls for that nested class. The other nested class instances are just fine, they return just fine.
    I could post more, but I think this illustrates the idea.
    I am suspicious that a strange static initialization order is jumbled up, as evidenced by nested static ctor debug statements I put in. I get one print and not the other.
    When I switch up which instance I reference in my main, I get the opposite behavior, more or less confirming my suspicions.
    So... Question is, what's the best way to potentially work around this issue? Hopefully without abandoning the Enumeration concern altogether, but that thought is a possibility as well. Or at least do so differently.
    Thank you...

    It is probably necessary to show GetValues() at least. I am getting the correct nested types, so that much we can at least assume.
    protected static IEnumerable<TDerived> GetValues()
    var declaringTypes = GetDeclaringTypes(typeof (TDerived)).ToArray();
    foreach (var declaringType in declaringTypes.Reverse())
    var fis = declaringType.GetFields(PublicStaticDeclaredOnly);
    var values = fis.Select(fi => fi.GetValue(null)).ToArray();
    foreach (var value in values.OfType<TDerived>())
    yield return value;
    Okay, here a bit of explanation.
    Enumeration is declared generically, with TDerived as the derived type. In this case, A.
    GetDeclaringTypes is operating okay. I get types for A, B, and C.
    The fis to values is breaking down, however. When I reference any of the CatB's, I get nulls for those instances. Conversely, same for CatC's when I reference any of those.

  • Initialize a global with a global from another file

    hi,
    I know that initialization order for global variables across compilation units is not defined, but if I have
    file1.cpp
      int x0 = 33, x1 = 55;
      extern int y0, y1;
      static int a[] = { y0, y1 };
      void print_a( void ) { printf( "\na[0] = %d\na[1] = %d", a[0], a[1] ); }
      extern void print_b( void );
      main()
        print_a();
        print_b();
    and file2.cpp
      int y0 = 77, y1 = 99;
      extern int x0, x1;
      static int b[] = { x0, x1 };
      void print_b( void ) { printf( "\nb[0] = %d\nb[1] = %d", b[0], b[1] ); }
    I notice that values are displayed correctly and consequently, initialized in the order I need. So what's the secret, coincidence, am I lucky? Does it make any difference if file2.cpp is part of a static library?
    Thanks

    @ Igor Tandetnik: Yes, I chose an example with circular dependency just to show that it was not the situation that, by luck, the "other" file was was initialized first. Yes, I would like a solution for such circular dependency, but I hope that I will
    find, at least, a solution for the case when such circular dependency does not exist. What I want to achieve? As the title says, I want a solution to be able to initialize globals with globals from another file, a solution as general and fault proof and convenient
    as possible.
    @ Wyck: I thought about something like that, problem is that in case of large arrays there is a lot to type. Another solution (it saves a little typing) I saw was something like
    // common_header.h
    #define LIST_A  y0, y1
    #define LIST_B  x0, x1
    // file1.cpp
    #include "common_header.h"
    Number x0(33), x1(55);
    static Number a[] = { LIST_A };  // just to give correct size
    // file2.cpp
    #include "common_header.h"
    Number y0(77), y1(99);
    static Number b[] = { LIST_B }; // just to give correct size
    // init.cpp
    extern Number LIST_A, LIST_B;
    void init()
    {  Number a_[] = { LIST_A };   Number b_[] = { LIST_B }; // stack usage
       for( int i = 0; i <_countof( a_ ); i++ )  a[ i ] = a_[ i ];
       for( int i = 0; i <_countof( b_ ); i++ )  b[ i ] = b_[ i ];
    This still has the problem of using much stack in case of large arrays and if array members are more complex structures (might also contain string literals), there is a bit more difficult.
    Bellow is a solution I came up with using macros but which I don't really like because is a bit cumbersome. I'm looking for something better/more elegant/safer or simply I want to see what other solutions people see here.
    // file1.cpp -------------------------------------------
    #define MEMBER_LIST( Usage ) \
    Usage( x1 ) \
    Usage( x2 )
    #define IMPORT( ext_member ) extern Number ext_member;
    #define COUNT( member ) 1 +
    #define LOAD( member_val ) a[ i++ ] = member_val;
    Number y1 = 77, y2 = 99;
    MEMBER_LIST( IMPORT )
    static Number a[ MEMBER_LIST( COUNT ) 0 ];
    static void InitGlobals_a( void ) { uint8 i = 0; MEMBER_LIST( LOAD ) }
    extern void InitGlobals_b( void );
    int _tmain(int argc, _TCHAR* argv[])
    { InitGlobals_a();  InitGlobals_b();
    return 0;
    // file2.cpp -------------------------------------------
    #define MEMBER_LIST( Usage ) \
    Usage( y1 ) \
    Usage( y2 )
    #define IMPORT( ext_member ) extern Number ext_member;
    #define COUNT( member ) 1 +
    #define LOAD( member_val ) b[ i++ ] = member_val;
    Number x1 = 33, x2 = 55;
    MEMBER_LIST( IMPORT )
    static Number b[ MEMBER_LIST( COUNT ) 0 ];
    void InitGlobals_b( void ) { uint8 i = 0;  MEMBER_LIST( LOAD ) }
    Of course, something like
    #define MEMBER_LIST( Usage ) Usage( x1 ) Usage( x2 )
    could be further simplified using other macros so you can simple use
    #define MEMBER_LIST x1, x2
    but those additional macros will add up to the complexity.

  • Error during Initial Provisioning/Modify: Inconsistency with address

    Hi all
    During Initial Provisioning (and also after any modif) of some users I get the following errors:
    E:Failed storing DDIC
    E:Exception from Mod operation:Inconsistency with address
    I:MX_PERSON has valid company address assignment.
    I:The entry with MSKEY "69802" has MSKEYVALUE "COMPANY:SAP_IDM_DEFAULT".
    E:Failed storing SAP*
    E:Exception from Mod operation:Inconsistency with address
    I:MX_PERSON has valid company address assignment.
    I:The entry with MSKEY "69801" has MSKEYVALUE "COMPANY:SAP_IDM_DEFAULT".
    E:Failed storing SAPCPIC
    E:Exception from Mod operation:Inconsistency with address
    I:MX_PERSON has valid company address assignment.
    I:The entry with MSKEY "69802" has MSKEYVALUE "COMPANY:SAP_IDM_DEFAULT".
    Surprisingly they're all "special users"; standard users are provisioned without errors (not related to the company address).
    Unfortunately it's not mentioned in the logs which system has these inconsistencies, because mostly provisioning works well (for these users).
    Questions:
    1. Does anybody know how I can resolve or what combination of values lead to this error?
    2. Where can I add a Debug-Line to see which system(s) fail?
    Any help appreciated
    BR
    Michael

    I solved this.
    First I added an Initialization script to the UpdateABAPUser-Pass which told me the repository and prints it as warning ot the job log.
    Then I took a look at these ABAP-Systems using SU01 and realized that SAP*, DDIC and SAPCPIC don't have the mandatory "Lastname" set, so SU01 says "Inconsistency with address" (DE: "Schiefstand bei Adresse").
    After I set this once on ABAP-side the UpdateABAPUser-Task ran fine.
    But still I would have expected that IdM sets this attribute as long as it is set on IdM-side, especially since it is mandatory in the destination system. At least it could provide a more informative error message.
    Thanks for any help.
    BR
    Michael

  • [svn:osmf:] 15220: Fix static initialization order in OSMFPlayer, so that the Log doesn't create TraceLoggers and DebugLoggers.

    Revision: 15220
    Revision: 15220
    Author:   [email protected]
    Date:     2010-04-05 10:29:52 -0700 (Mon, 05 Apr 2010)
    Log Message:
    Fix static initialization order in OSMFPlayer, so that the Log doesn't create TraceLoggers and DebugLoggers.
    Modified Paths:
        osmf/trunk/apps/samples/framework/OSMFPlayer/src/OSMFPlayer.as

    shak wrote:
    I've followed the first method with the mpd daemon and everything worked fine .
    THanks for all your help everyone !
    The add of MPD : ALL to hosts.allow seems to solved it .
    Thanks again!
    Nice.
    Please mark threads as [SOLVED] when they are. You can do so by editing the opening post.

  • SMD error: PPMS Modelling is inconsistent with SMSY. Check PPMS Keys

    Hi,
    In extractors configured - WORKLOAD ANALYSIS (Introscope DATE) - BI Java, i have an inconsistency for Enterprise Portal:
    ERROR: Consistency Check: PPMS Modelling is inconsistent with SMSY. Check PPMS Keys.
    I can not find the problem. Can you help me?
    Best regards,
    Diego.

    Hello Diego,
    In regards to the error you are getting:
    "PPMS Modelling is inconsistent with SMSY. Check PPMS Keys."
    There is a daily consistency check against SMSY.  In case that the PPMS information in SMSY changed, we flag the relevant
    extractor in order to prevent collecting of false data. Please delete the inconsistent extractors for system <select your managed SID> in the EFWK AdminUI (Managing System -> Inconsistent Extractors) and rerun the managed system setup for system <select your managed SID>.
    This will resolve your issue.
    Thanks,
    Mark

  • Purchase order report with basic price and Excise duty values

    Hi All,
    Is there any standard report in SAP to get the Purchase order basic price / qty and its Excise duty values ? Since we are including Excise duties for non - codified items (w/o material master and with cost center 'K') Purchase order and the ed values are added to the cost and the requirement is to see the split up (Basic priceEdEcs+Hcs)for these Purchase orders for the vendors. If there is no std report then please let me know how to link Purchase order table with this Condition value table in query to get the desired report.
    Thanks in advance
    Benny

    Hi,
    there is no standert report to fullfill this requierment
    you have to create this report with the help of abaer
    for that which tax code you are using its importnat thing
    for po table EKPO
    1. A524 (Normal supply point / Material) it will return condition record number for condition type.
    2. KONP (Conditions (Item)) .
    3. J_1IMTCHID (Combination of Material Number and Chapter ID).
    4. J_1IEXCTAX (Tax calc. - Excise tax rates
    5 get the IR no. from RBKP and RSEG, and get the relevant FI doc no. and goto BSET table
    for IR number  to get from table apply logic for doc type RE ,you will get fi number nad in refernce field you will get invoice number + fiscal year
    Map this by refernig on po for which grn and invoice happen
    Regards
    Kailas Ugale

  • Payment order clearing with EBS in SAP

    Hi All,
    I am little confused with Payment order clearing with EBS. Actually the process is as below.
    1. We create an invoice for Vendor - FB60 / MIRO
    2. We make the payment through F110, which creates a payment order but this will not post the payment document. Here, the payment order will be generated for payment ref.
    We should clear that Invoice by uploading the EBS.
    I have created a posting rule as below
    Posting rule Z092
    Posting Area 1
    Debit side
    Posting key 25
    Acc Symbol (Debit) - Blank
    Credit side
    Posting key 50
    Acc Symbol (Credit) - Main Bank Account
    Document type - KZ
    Posting type - 1
    Assigned Ext. Trans. Type to posting rule as below
    Ext. Trans. Type 702    +   Posting rule Z092    Interpretation Alog - 29
    The below is the error i am getting while uploading the EBS stmt in FF_5
    I am getting the error saying "Error: (F5 104) Vendor * is not defined in company code XXXX".
    The Accounting entry should be
    Dr  Vendor   A/C
    Cr  Main Bank A/C

    Hi Raju ,
    The Problem seems to be that the payment order number is extended with your company code number due to which the system is not recognizing your payment order. Give one more try by just entering the payment order number and deleting the co code and year after that, just like below.
    88,0000002157
    88,/06590719801706 0000002157
    88,0000002157
    Thanks,
    Suresh

  • Standard  report(for open PO order items) with estimated Delivery dates

    hi friends
    i would like to know if there is any standard  report(for open PO order items) with estimated Delivery dates on it.
    thanks
    alahari

    ME2M (by material)
    ME2L (by vendor)
    ME2N (by number)
    Use selection parameter WE101 for open GR
    and scope of list EINT (scheduling lines)

  • I want to run an open order report with no goods receipt

    I'm looking to run an open order report with no confirmations(i.e.the order must have no status like LA,Z4,Z5,Z6)and no goods receipt.
    ME80FN is still giving me orders that have no confirmations but closed.
    I tried using a logical database but no luck.
    What can i use to achieve this open order report?

    Hi,
    You can write a small report for this requirement:
    Just select all the PO's from EKKO and EKPO table into an internal table(ITAB) with the given where condition.
    Write a select statement for the MSEG for all entries in ITAB into an seperate internal Table(ITABM).(nothing but all GR's entries)
    Compare Both internal tables and delete all entries which are present in second Int table ITABM from the first.
    That's all.
    The remaining entries are nothing but the OPEN PO's without any Goods Receipt.
    Regards,
    Anji

  • How to trace purchase order number with respect to Purchase requestion numb

    Hi friends,
    Can u please help me how to Trace purchase order number with respect to purchase Requetuion  number. Is there any standard report  available in R/3

    Hi Vamsi,
    Thats what!!!
    Goto SE16 - EBAN - Give PR number in the iput screen.
    In the output screen you will have to do field selection from Menu - Settings - formatlist - choose fields.
    There you choose Purchase Order.
    So the output will display for you POs for the PR that you entered.
    Regards,
    Vishal

  • Do we have standard report to show sale order stock with amount?

    Do we have standard report to show sale order stock with amount?
    I try to use MB5B and MBBS but they don't show value.
    MB5B show only qty
    MBBS no any report.
    Please kindly help.
    Thank you very much.

    Okay Thank you very much for your suggestion.
    I think I have to create a new ZProgram. T_T

  • Read Sales Order Price with Pricing Date (PRSDT)

    Hello ABAP Gurus,
    I have once requirements and is, I need to extract sales order prices with a given Pricing Date (PRSDT).
    Could you please tell me if these is Function Module or BAPI that I can use?
    Regards,
    Murali

    Maintain a condition record for Rs.10/- with a validity date (only as an example) as 1st March'14 to 15th March'14.  Another condition record for Rs.15/- with validity date as 16th March'14 to 31st March'14.
    Now create a sale order for 500 nos. with one line item and change the pricing date as 15th March'14.  Similarly, create another line item for the same material with 500 nos. and here, change the pricing date as 16th March'14 at line item level.  By doing so, system would fetch the pricing in billing accordingly.
    I told as per my knowledge System will bring old price only for reserved stock if you want to apply new price for reserved stock just 411 e return the stock from reservation and now create sales order
    i hope this right
    Your understanding is incorrect.  System will never validate pricing based on age of the stocked material but based on validity period what you maintain in condition record.
    G. Lakshmipathi

  • FM to get sales order details with billing document .

    hi ,
    is there any standard FM or BAPI to get the sales order details with input as billing document ?
    i have the billing document number now i need to get the sales order number and its details ..
    is that possible ..
    i very well know how to get it by using query, i need standard FM.
    Points will be awarded for sure , if it helps .
    Thanks and regards
    JK

    Here is the list of BAPIs
    BAPI_QUOTATION_GETDETAILBOS
    BAPI_INQUIRY_GETDETAILBOS
    BAPI_SALESORDER_GETDETAILBOS
    SALES ORDER->
    BAPISDORDER_GETDETAILEDLIST Sales Order: List of All Order Data
    BAPI_ORDER_CHANGE_STATUS_GET Change status for order
    BAPI_SALESDOCU_CREATEFROMDATA Creating a Sales Document
    BAPI_SALESORDER_CHANGE Sales Order: Change Sales Order
    BAPI_SALESORDER_CREATEFROMDAT1 Sales Order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDAT2 Sales Order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDATA Create sales order, no more maintenance
    BAPI_SALESORDER_GETLIST Sales order: List of all orders for customer
    BAPI_SALESORDER_GETSTATUS Sales order: Display status
    BAPI_SALESORDER_SIMULATE Sales Order: Simulate Sales Order

Maybe you are looking for