Bug 159327 - Java source generation cannot be retried if template-based source could be compiled
Summary: Java source generation cannot be retried if template-based source could be co...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: VE (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: VE Bugzilla inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-29 13:47 EDT by Kaspar von Gunten CLA
Modified: 2011-06-13 11:37 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kaspar von Gunten CLA 2006-09-29 13:47:29 EDT
The following code change is recommended in TemplateObjectEmiter.getObject():

before:
...
Object o = fObjectEmitter.generateObjectFromExisting(cl,pm) ;
if (o == null) {
    // Now compile the JET template and get the Java source   
    fObjectEmitter.setSrc(getObjectSource(pm).toCharArray()) ;
    o = fObjectEmitter.generateObject(classPath,cl,pm) ;
}

after:
Object o = fObjectEmitter.generateObjectFromExisting(cl,pm) ;
if (o == null) {
    // Now compile the JET template and get the Java source   
    fObjectEmitter.setSrc(getObjectSource(pm).toCharArray()) ;
    try
    {
      o = fObjectEmitter.generateObject(classPath,cl,pm) ;
    }
    catch (TemplatesException ex)
    {
      // reset src to null to allow runtime changes on template 
      // and retrial after exception, without having to restart the app
      fObjectEmitter.setSrc(null);
      throw ex;
    }
}

If the creation of the code of a template-based custom widget fails for reasons of a buggy template, then retrial of compilation (after fixing the template) fails due to a TemplatesException: "Can not overide existing source" (originating at org.eclipse.ve.internal.java.vce.templates.JavaObjectEmiter). 

Setting of the template code on the emitter is disallowed the second time. But since the emitter didn't succeed in compiling the template, this should not be the case.