| Summary: | EGL code has try-block on AnyException but generated Java has unhandled exception | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Kathy Carroll <carrollk> |
| Component: | EDT | Assignee: | Project Inbox <edt.javagen-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jeffdouglas, mheitz |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
The root of this problem is that IOException has not yet been defined in EGL. This needs to be added to the EGL source files that are generated into the IR logic. Actually, the problem is that an onException block catching AnyException needs to be generated differently than other onException blocks. I'm familiar with this because RBD had to deal with this problem too.
We have to generate a catch for all Exceptions. If we catch something that's not one of our exceptions, create an AnyException to represent it.
EGL
---
onException (exp AnyException)
// ...body of the onException block...
end
Generated Java
--------------
catch ( Exception ezeTemp1 )
{
exp AnyException;
if ( ezeTemp1 instanceof AnyException )
exp = (AnyException)ezeTemp1;
else
exp = ...some code to make an AnyException from ezeTemp1...
// ...code for the body of the onException block...
}
I made the changes in TryStatementTemplate. verified Closing this defect. |
Generated Java is getting the error message: Unhandled exception type IOException EGL code: ============ ExternalType File type JavaObject {packageName = "java.io"} constructor (pathname String In); function getAbsolutePath() returns (String); function createNewFile() returns (boolean); function mkdirs() returns (boolean); function exists() returns (boolean); end ExternalType FileWriter type JavaObject { packageName = "java.io"} constructor (file File In); constructor (filename String In); function write(str String In); // function close_() {javaName ="close"}; //354044 The javaName annotation for external JavaObject functions is missing end ExternalType IOException type JavaObject { packageName = "java.io"} end ================ handler CreateResultFile function createFile(fileDirectory String in, fullFileName String in, fileContent String in) myfile File = new File(fileDirectory); //if(!etrFile.exists()) createdDirs boolean = myfile.mkdirs(); if(createdDirs) sysLib.writeStdOut("directories created"); end //end outWriter FileWriter; try syslib.writeStdOut (myfile.getAbsolutePath()); outWriter = new FileWriter(fullFileName); outWriter.write(fileContent); // outWriter.close_(); // onException (ioExp IOException) // syslib.writeStdOut("IOException occrred!"); onException (exp AnyException) syslib.writeStdOut("oops can't get to it"); syslib.writeStdOut("Exception occurred!"); end end end Generated JAVA FileWriter outWriter = null; try { SysLib.writeStdout(myfile.getAbsolutePath()); outWriter = new FileWriter(fullFileName); outWriter.write(fileContent); } catch (AnyException exp) { String eze$Temp3 = Constants.EMPTY_STRING; eze$Temp3 = "oops can't get to it"; SysLib.writeStdout(eze$Temp3); String eze$Temp4 = Constants.EMPTY_STRING; eze$Temp4 = "Exception occurred!"; SysLib.writeStdout(eze$Temp4); } No java compile error in RBD for this example