Archived
Ice-3.6.2 slice2java parsing bug
Hello ZeroC -
I have come across the following slice2java bug. But first things first, my environment:
Linux: Red Hat Enterprise Linux Server release 6.3 (Santiago) with kernel 2.6.32-279.el6.x86_64
Ice: 3.6.2 locally built
slice2java: 3.6.2 locally built
C++ toolchain: gcc6.1.0
What happens is that lines in the ice definition files that have a trailing comment seem to be considered a comment in their entirety. This causes:
structsorclassesmember variables to disappear silentlyenumvalues to disappear silently- member functions of
interfacesto disappear silently syntax errorswhen comments are appended to opening or closing scopes (modules,enums,structsorclasses)
I have attached Here is the test file I used to illustrate the bug:SliceBug.ice:
#pragma once
module test_module {
struct TestStruct {
long member;
long disappearing_member; // This comment will make this line disappear
};
}; // This comment generates a syntax error
This is what happens when I run slice2java against that Ice file:
[11:14:49 epic@XXX:~/tmp/slice2java_test] $ slice2java -Iice_def -Igcc6.1.0/x86_64/Ice-3.6.2/slice --underscore --tie --stream --output-dir=ice_lib ice_def/SliceBug.ice /home/epic/tmp/slice2java_test/ice_def/SliceBug.ice:9: syntax error
If I remove the comment that generates the syntax error, slice2java completes. It generates ice_lib/test_module/TestStruct.java, but the code is incomplete. It is missing the long disappearing_member:
[11:16:18 epic@XXX:~/tmp/slice2java_test]
$ cat ice_lib/test_module/TestStruct.java
// **********************************************************************
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
//
// Ice version 3.6.2
//
// <auto-generated>
//
// Generated from file `SliceBug.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//
package test_module;
public class TestStruct implements java.lang.Cloneable, java.io.Serializable
{
public long member;
public TestStruct()
{
}
public TestStruct(long member)
{
this.member = member;
}
[...]
If I remove the comment trailing long disappearing_member;, then slice2java finally generates the proper java file:
[11:37:27 epic@XXX:~/tmp/slice2java_test]
$ cat ice_lib/test_module/TestStruct.java
// **********************************************************************
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
//
// Ice version 3.6.2
//
// <auto-generated>
//
// Generated from file `SliceBug.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//
package test_module;
public class TestStruct implements java.lang.Cloneable, java.io.Serializable
{
public long member;
public long disappearing_member;
public TestStruct()
{
}
public TestStruct(long member, long disappearing_member)
{
this.member = member;
this.disappearing_member = disappearing_member;
}
[...]
Feel free to contact me if you need further details.
Emmanuel
Comments
-
It could be related to that indeed. I was using the box's libmcpp. I am going to build mcpp using your fork. I will let you know.
Thanks for the quick answer!
0 -
Using the ZeroC mcpp fork fixed it. Thanks again
0