Home Bug Reports

Java global package metadata and builtin datatypes

mefostermefoster Member Mary Ellen FosterOrganization: Heriot-Watt University, EdinburghProject: ECHOES learning environment ✭✭✭
It seems that specifying "java:package:whatever" in a .ice file has a different effect than specifying it on the slice2java command line, at least when the built-in datatypes like ::Ice::StringSeq are used.

Here's a sample file:


#include <Ice/BuiltinSequences.ice>

module jast {
    module listener {
        interface SpeechRecognitionListener {
            void recognizedTurn (string top, ::Ice::StringSeq alternatives);


If I run slice2java on this as it is (with the appropriate -I argument to find Ice/StringSeq), I get generated Java that refers to Ice.StringSeqHelper. However, if I delete the metadata line in the ice file and specify instead '--meta "java:package:de.tum.in"', the generated file refers (incorrectly) to de.tum.in.Ice.StringSeqHelper. Here's a diff of the generated code from the two cases.
--- test/de/tum/in/jast/listener/_SpeechRecognitionListenerDelM.java    2007-05-
11 15:39:06.000000000 +0100
+++ test2/de/tum/in/jast/listener/_SpeechRecognitionListenerDelM.java   2007-05-
11 15:39:29.000000000 +0100
@@ -24,7 +24,7 @@
                 IceInternal.BasicStream __os = __og.os();
-                de.tum.in.Ice.StringSeqHelper.write(__os, alternatives);
+                Ice.StringSeqHelper.write(__os, alternatives);
             catch(Ice.LocalException __ex)
diff -ur test/de/tum/in/jast/listener/_SpeechRecognitionListenerDisp.java test2/
--- test/de/tum/in/jast/listener/_SpeechRecognitionListenerDisp.java    2007-05-
11 15:39:06.000000000 +0100
+++ test2/de/tum/in/jast/listener/_SpeechRecognitionListenerDisp.java   2007-05-
11 15:39:29.000000000 +0100
@@ -82,7 +82,7 @@
         String top;
         top = __is.readString();
         String[] alternatives;
-        alternatives = de.tum.in.Ice.StringSeqHelper.read(__is);
+        alternatives = Ice.StringSeqHelper.read(__is);
         __obj.recognizedTurn(top, alternatives, __current);
         return IceInternal.DispatchStatus.DispatchOK;

Is this the intended effect? I'd rather use one metadata directive on the command line rather than one per file ...



  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    You are seeing the expected behavior. From the manual:

    Using this option is equivalent to defining the global metadata META in each named Slice file, as well as in any file included by a named Slice file.

    As you've discovered, the package metadata typically cannot be defined with the --meta option because it is applied to included files as well.

    The package metadata really is meant to be defined explicitly in each Slice file. Without it, the translator would not be able to compose the correct fully-scoped names for types in included files.

    Take care,
    - Mark
Sign In or Register to comment.