Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

JET FAQ What is JMerge?

Revision as of 15:48, 22 July 2010 by Codingkriggs.gmail.com (Talk | contribs) (Corrected typos and improved the wording.)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Question

What is JMerge?

Answer

JMerge is a technology developed by the Eclipse Modeling Framework (EMF) so that code generators that produce Java code can allow for user modification of that code, while still permitting the code generator to be re-executed.

Using JMerge creates a contract between the Code Generator and the Consumer. The actual contract depends on which JMerge rules are used. Here is a description of the contract for the JMerge rules provided with EMF.

  • On code generation execution/re-execution
    1. The Code Generator shall only update Java elements with an intact @generated tag.
    2. The Code Generator may remove Java elements with an intact @generated tag if those elements no longer exist in the input to the code generator. The Consumer must be aware that such removal can result in compilation errors in the Consumer's code.
  • While editing generated Java code
    1. The Consumer may add new Java elements without worry that the Code Generator will overwrite them. The Consumer must be aware that a subsequent change in the Code Generator's input may cause the Code Generator to fail to write a Java element with the same signature as the new element. JMerge provides no feedback that such a failure has occured.
    2. The Consumer may modify generated Java elements (and ensure that the code generator will not revert or modify them) by removing or defacing the @generated javadoc tag on the element. Defacing is a good practice, as it clearly indicates the Consumer's intent to modify generated code. Common ways of defacing the @generated tag are to change it to '@generated not' or '@!generated'.

See Also


Back to the M2T-JET-FAQ

Copyright © Eclipse Foundation, Inc. All Rights Reserved.