Go Back   ZeroC Forums > Bug Reports

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 12-02-2003
alexander alexander is offline
Registered User
 
 
Join Date: Nov 2003
Posts: 22
slice2java

i'm not sure if it's a bug and not a feature.
slice2java generates code with wrong class names in case of using external ice-modules and using --package option. I need that option to explictly specify package name as I want to have the following directory/class hierarhy:
test/
server/
client/
common/

where package test.server consists of server implementation, test.client - client implementation and test.common - slice2java generated stuff shared by both client and server. i know that if i use "module test.common" in test.ice i get what i want but i think it's a wrong way to mix declaration and implementation things.

$ slice2java --package test.common test.ice

------------------ test.ice ------------------
#include <Ice/BuiltinSequences.ice>

interface Test {
void testByteSeq(Ice::ByteSeq seq);
};

------------------ test/common/_TestDisp.java ------------------
...
public static IceInternal.DispatchStatus
___testByteSeq(Test __obj, IceInternal.Incoming __in, Ice.Current __current)
...
byte[] seq;
seq = test.common.Ice.ByteSeqHelper.read(__is);
...

------------------ test/common/_TestDelM.java ------------------
...
public void
testByteSeq(byte[] seq, java.util.Map __context)
...
test.common.Ice.ByteSeqHelper.write(__os, seq);
...

------------------
Notice wrong type in both files test.common.Ice.ByteSeqHelper instead of Ice.ByteSeqHelper
Reply With Quote
  #2 (permalink)  
Old 12-02-2003
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 962
Hi,

You're right, currently the translator applies the package prefix to all types. Unfortunately, this is a tricky issue. If instead we only applied the prefix to types defined in the current file (and not to types in #include'd files), then there is a similar risk of generating incorrect code, since some of those files may have been generated using a (potentially different) package prefix.

The 'module workaround' you mentioned is one possible (although not very attractive) solution. You could also try to avoid including external Slice files, but that may not be possible for you.

In any event, this is something that needs to be fixed. We'll discuss this and come up with a solution.

Thanks for bringing this to our attention.

- Mark
Reply With Quote
  #3 (permalink)  
Old 12-15-2003
alexander alexander is offline
Registered User
 
 
Join Date: Nov 2003
Posts: 22
I see the problem with module - package mapping. And I can not see any rational way to fix it while it is possible to override package name at the time of generating code so there is no information about package names in ice sources.
IMHO, one solution is to:
1) remove comman line option to redefine package name (optional, could be kept for compatibility)
2) add somthing like the following to the ice syntax:

["java:<package_name>"] module <module_name> {
}

Thanks for your work
Alexander
Reply With Quote
  #4 (permalink)  
Old 12-16-2003
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 962
Hi,

Yes, the best solution is to have the package information in the Slice file. We considered using the existing metadata facility for specifying the package. The problem, however, is that you would have to repeat the metadata for every top-level definition in the file, and it introduces some perplexing issues. We solved it a slightly different way.

In the next release, Slice will support "global" metadata, which is metadata that can only appear once in a file, must appear before any definitions, is not affected by and has no effect on included files, and applies to all of the definitions in the file. For example:

Code:
[["java:package:com.zeroc"]]
module M {
    // ...
};
Thanks again,
- Mark
Reply With Quote
  #5 (permalink)  
Old 12-16-2003
alexander alexander is offline
Registered User
 
 
Join Date: Nov 2003
Posts: 22
Hmm... Does "global" mean that all top level definitions in the ice file share package name from such metadata? What about following collision:

module m1 {
interface I {};
};

module m2 {
interface I {};
};

However, it makes sense if such metadata used as "prefix" so the following ice definition

[["java:package:test"]]

module m1 {
interface I {
...
};
};

module m2 {
interface I {
...
};
};

produces test.m1.I and test.m2.I without any namespace confilicts
Reply With Quote
  #6 (permalink)  
Old 12-16-2003
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 962
Right, the global metadata defines a package prefix for all of the definitions in the file.

- Mark
Reply With Quote
  #7 (permalink)  
Old 12-16-2003
alexander alexander is offline
Registered User
 
 
Join Date: Nov 2003
Posts: 22
Ok, thanks for your answer.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
slice2java ChenQingQing Help Center 4 09-25-2006 03:20 AM
Where is slice2java dashie Help Center 7 09-04-2006 06:21 AM
run slice2java for WinXP torrecam Help Center 1 02-21-2005 10:33 AM
slice2java command anitha Help Center 3 10-14-2004 09:35 PM
Patch for slice2java, v1.5.1 michi Patches 0 08-19-2004 05:53 PM


All times are GMT -4. The time now is 10:40 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.