PM77224: After UML-to-Java transformation, final field arrays are initialized to a default value

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • After UML-to-Java transformation, final field arrays are
    initialized to a default value
    
    In IBM Rational Software Architect, if you have a class in the
    UML model with a final field as an array of 'chars', the
    resulting field will be assigned to 'null' and you will not be
    able to re-assign a value in the constructor.
    
    The following steps reproduce the problem:
    
    1. Create a Java project and UML model
    2. Add the Java Transformation profile to the model
    3. Add a class, Class1, to the model
    4. Add an attribute, Attrib1, and operation, Oper1, to Class1
    5. Apply the 'JavaArray' stereotype to Attrib1
    6. Set Attrib1's Properties ? Advanced ? Lower Value to (0)
    7. Set Attrib1's Properties ? Advanced ? Upper Value to (*)
    8. Set Attrib1's Properties ? General ? Type to 'char'
    9. Add an 'in' parameter, Param1, to Oper1
    10. Set Param1's Properties ? General ? Type to 'String'
    11. Add a UML-to-Java transformation configuration
    12. Run the transformation configuration and examine the
    resulting Java code
    
    Expected Result: Attrib1 is not initialized and appears as:
    
    [?BEGIN CODE?]
    private final char[] Attrib1;
    [?/END CODE?]
    
    Actual Result: Attrib1 is initialized to 'null' and appears as:
    
    [?BEGIN CODE?]
    private final char[] Attrib1 = null;
    [?/END CODE?]
    
    As a result, if you then try to assign Attrib1 to a value within
    the constructor as follows:
    
    [?BEGIN CODE?]
    public void Oper1(String Param1) {
      // begin-user-code
      // TODO Auto-generated method stub
      Attrib1 = Param1.toCharArray();
      // end-user-code
     }
    [?/END CODE?]
    
    you will get the error message 'The final field Class1.Attrib1
    cannot be assigned' in the code.
    
    The workaround is to edit the code manually after each
    UML-to-Java transformation so that the final field array is not
    set to a default value.
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    If you have a class in the UML model with a final field as
    an array, the resulting field will be assigned to "null" and
    you will not be able to re-assign a value in the
    constructor.?
    

Problem conclusion

  • ?The fix ensures that final fields are not assigned to null
    buy transformation. Provided a test fix to customer.
    

Temporary fix

Comments

APAR Information

  • APAR number

    PM77224

  • Reported component name

    RATL SW ARCHITE

  • Reported component ID

    5725A3000

  • Reported release

    804

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-11-16

  • Closed date

    2012-12-15

  • Last modified date

    2012-12-15

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    RATL SW ARCHITE

  • Fixed component ID

    5725A3000

Applicable component levels

  • R804 PSN

       UP



Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

Rational Software Architect

Software version:

8.0.4

Reference #:

PM77224

Modified date:

2012-12-15

Translate my page

Machine Translation

Content navigation