Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362145 - Generated Java code got error when the external type can not be instantiated
Summary: Generated Java code got error when the external type can not be instantiated
Status: CLOSED INVALID
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-26 23:11 EDT by Xin Wu CLA
Modified: 2017-02-23 14:16 EST (History)
3 users (show)

See Also:


Attachments
LdapRuiServices in EDT (104.98 KB, application/x-zip-compressed)
2011-10-26 23:14 EDT, Xin Wu CLA
no flags Details
The updated project, you may use this instead the old one (106.38 KB, application/x-zip-compressed)
2011-10-31 03:53 EDT, Xin Wu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xin Wu CLA 2011-10-26 23:11:32 EDT
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
Comment 1 Xin Wu CLA 2011-10-26 23:14:22 EDT
Created attachment 206043 [details]
LdapRuiServices in EDT
Comment 2 Xin Wu CLA 2011-10-31 03:03:38 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.
Comment 3 Xin Wu CLA 2011-10-31 03:53:45 EDT
Created attachment 206191 [details]
The updated project, you may use this instead the old one
Comment 4 Joseph Vincens CLA 2011-11-01 13:49:55 EDT
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?;
Comment 5 Joseph Vincens CLA 2011-11-01 13:51:28 EDT
If you want InitialLdapContext to be initialized to null, then you need to define it as nullable. ie
ctx InitialLdapContext?;
Comment 6 Xin Wu CLA 2011-11-01 23:16:03 EDT
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.