Community
Participate
Working Groups
Build Identifier: 20111026 nightly build Generated Java code got error when the external type can not be instantiated Reproducible: Always Steps to Reproduce: 1. Download the attached EDT EGL project, import to your workspace 2. Make sure there is no EGL compile error and see the "Attribute" External type in EGL file "common.LDAPExternalTypes.egl". This was modified based on project in RBD. 3. See the file "common.UserObject.java" in generatedJava, there are some Java compile error for "Attribute" pointing out it can not be instantiated. 4. The doesn't occurred in RBD, you may get comparable project in RBD by Help => Samples => EGL => Rich UI access to LDAP
Created attachment 206043 [details] LdapRuiServices in EDT
A similar problem in same project. In generatedJava -> common -> LDAPLib.java line 34. "InitialLdapContext ctx = new InitialLdapContext();" got error unhandled exception. Which was declared as "null" in RBD. These two problem blocked some of the Green Thread testing, so I will reset severity to major.
Created attachment 206191 [details] The updated project, you may use this instead the old one
The Attributes external type represents an interface. An interface is not instantiatable, so the egl variable declaration should have a ?. A best practice when creating an external type that represents a Java Interface is to have a private constructor. externalType Attributes type JavaObject { ExternalName = "Attributes", PackageName = "javax.naming.directory" } private constructor(); function getAttribute( attrId String in ) returns( Attribute ) { ExternalName = "get" }; function getAll() returns ( NamingEnumeration ); function getIds() returns ( NamingEnumeration ); function size() returns ( int ); end This forces the variable declaration to require a ?. attrs Attributes?;
If you want InitialLdapContext to be initialized to null, then you need to define it as nullable. ie ctx InitialLdapContext?;
Joe, thanks so much. The best practice you suggested that adding "private constructor();" solved the problem. And it will bring out a compile error to notify user to add a '?' in EGL. Closed this bug.