Read only archive ; use https://github.com/JacORB/JacORB/issues for new issues

Bug 554

Summary: The "ir" command does not complete at the module "org.jacorb.ir.InterfaceDef.loadContents()"
Product: JacORB Reporter: Sotohiro Terashima <stera>
Component: Interface RepositoryAssignee: Gerald Brose <gerald.brose>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 2.2.1   
Hardware: PC   
OS: Windows NT   
Attachments: Patch of InterfaceDef.java
Patch of EnumDef.java
New Patch of InterfaceDef.java
New Patch of EnumDef.java

Description Sotohiro Terashima 2004-12-28 23:03:04 CET
Dear friends,

despite problems with JacORB 2.2.1, I was finally able to run my browser example
for JacORB.
All interesting in downloading and using the browser with JacORB please go to my
web page http://republika.pl/maom_onet/browser/.

The page also lists problems I had with JacORB. 
I believe most of them are bugs, as the same example runs successfully (and ran
in the past) with a few other Java ORBs.

Best regards,

Marek
##########################################################################################
I tested this browser on JacORB2.2.1.
But there was problems related to InterfaceRepository. 
The "ir" command does not complete at the module
"org.jacorb.ir.InterfaceDef.loadContents()".

I made following modification,then "ir" command completes.

278                        Class cl =
279                            loader.loadClass(
280//                                   ( full_name.replace('.', fileSeparator) +
281                                   ( full_name.replace('/', fileSeparator) +
282                                     "Package" + fileSeparator +
283                                     classes[j].substring( 0,
classes[j].indexOf(".class"))
284//                                     ).replace( fileSeparator, '/') );
285                                     ).replace( fileSeparator, '.') );

But one "EnumType" error exists still.

[28-12-2004 05:15:31:406] jacorb.ir:ERROR: Caught Exception
java.lang.IllegalArgumentException: cannot find class:
MainModule.TestModule.TestInterface.EnumType
	at org.jacorb.ir.RepositoryID.toRepositoryID(Unknown Source)
	at org.jacorb.ir.RepositoryID.toRepositoryID(Unknown Source)
	at org.jacorb.ir.EnumDef.<init>(Unknown Source)
	at org.jacorb.ir.Contained.createContained(Unknown Source)
	at org.jacorb.ir.InterfaceDef.loadContents(Unknown Source)
	at org.jacorb.ir.Container.loadContents(Unknown Source)
	at org.jacorb.ir.ModuleDef.loadContents(Unknown Source)
	at org.jacorb.ir.Container.loadContents(Unknown Source)
	at org.jacorb.ir.ModuleDef.loadContents(Unknown Source)
	at org.jacorb.ir.Container.loadContents(Unknown Source)
	at org.jacorb.ir.RepositoryImpl.loadContents(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.jacorb.ir.IRServer.main(Unknown Source)
Comment 1 Sotohiro Terashima 2005-01-14 14:43:35 CET
Error of "EnumType" is resolved by following modification.

org.jacorb.ir.EnumDef

54//            if( path.endsWith("Package"))
55//            {
56//                id( RepositoryID.toRepositoryID( path.substring( 0,
path.lastIndexOf("Package")) + "." + name, loader));
577//            }
58//            else 
59//            {
60//                id( RepositoryID.toRepositoryID( path + "." + name, loader));
61//            }
62                id( RepositoryID.toRepositoryID( path + "." + name, loader));
Comment 2 Sotohiro Terashima 2005-03-15 04:43:56 CET
Created attachment 119 [details]
Patch of InterfaceDef.java
Comment 3 Sotohiro Terashima 2005-03-15 04:46:09 CET
Created attachment 120 [details]
Patch of EnumDef.java
Comment 4 Sotohiro Terashima 2005-03-16 14:26:34 CET
Created attachment 141 [details]
New Patch of InterfaceDef.java
Comment 5 Sotohiro Terashima 2005-03-16 14:27:18 CET
Created attachment 142 [details]
New Patch of EnumDef.java
Comment 6 André Spiegel 2005-05-26 09:58:05 CEST
Gerald, could you have a look at this?  I'm really not qualified to judge this
patch.  The diffs apply cleanly to current CVS, but at least one of the two
patches (the one for EnumDef) simply comments out an alternative from the code,
which I imagine must have been there for a reason initially.

I guess the person who wrote the code is the best to judge whether these changes
are ok or not.
Comment 7 Gerald Brose 2005-05-31 22:11:29 CEST
Guys, can you provide a test case please that shows the problem and also 
that the patch solves it? Could you perhaps provide an IDL file that,
when compiled using "idl -ir" results in the problems?

Thanks, Gerald.
Comment 8 Sotohiro Terashima 2005-06-01 07:39:10 CEST
Mr. Gerald,Please look at top of this thread!

There are informations about this.
The problems are found when I tried Mao's browser on JacORB2.2.1.

Sotohiro Terashima.
Comment 9 Gerald Brose 2005-06-01 08:44:19 CEST
I did see that but was hoping you could provide a *simple and isolated* test 
case rather than an external application.
Comment 10 André Spiegel 2005-06-01 11:01:09 CEST
Sotohiro, the problem is you are making changes without explaining why these
changes are necessary.  It is not enough to say that you need them to run MAO's
CORBA Browser.  The problem is that although the Browser might run with those
changes, some other code might break.  We cannot judge this, because we don't
understand the reasoning for your changes.

Take the patch for InterfaceDef, for example.  From what I understand, the code
used to make a replacement of '.' -> fileSeparator -> '.'  With your change, it
replaces '/' -> fileSeparator -> '.'.  But you don't give us any explanation why
this is necessary, and, more importantly, why you think that this change doesn't
break any other code.

The same applies to the change to EnumDef.  You simply remove an alternative
from the code, but you don't tell us why.  We have no idea why this change is
necessary, and we have no idea why we should be certain that your change doesn't
break any other code that is working right now.

We cannot simply install a change that you send to us.  We need to understand
why it is necessary.  You probably did a lot of thinking and reasoning to arrive
at your changes.  If you don't tell us about this thinking and reasoning, we
have to do all of this again in order to understand the patch.  It would take us
at least the same time that it took you to do it, so your patch helps us almost
nothing.

Please provide explanations, otherwise we can't install your changes.
Comment 11 Sotohiro Terashima 2005-06-02 10:04:06 CEST
> The problem is that although the Browser might run with those
> changes, some other code might break.  We cannot judge this, because we don't
> understand the reasoning for your changes.

########################################################################################
<<Patch to InterfaceDef.java around line number 278>>
This patch displays the reason of URLClassLoader Fault.

String S_Before = ( full_name.replace('.', fileSeparator) +
					"Package" + fileSeparator +
					classes[j].substring( 0, classes[j].indexOf(".class"))
					).replace( fileSeparator, '/');
String S_After = ( full_name.replace('/', fileSeparator) +
					"Package" + fileSeparator +
					classes[j].substring( 0, classes[j].indexOf(".class"))
					).replace( fileSeparator, '.');
					System.out.println("S_Before = " + S_Before + '\n');
					System.out.println("S_After = " + S_After + '\n');

########################################################################################
<<The result of this Patch>>
This shows the String of Classname is baddly separated by '/' instead of '.'.

S_Before = MainModule/SimpleModule/SimpleInterfacePackage/ValueNotSet

S_After = MainModule.SimpleModule.SimpleInterfacePackage.ValueNotSet

[02-06-2005 14:12:51:016] jacorb.ir:ERROR: Caught exception
java.lang.NoClassDefFoundError: Illegal name:
MainModule/SimpleModule/SimpleInterfacePackage/ValueNotSet
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at java.net.URLClassLoader.defineClass(Unknown Source)
	at java.net.URLClassLoader.access$100(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at org.jacorb.ir.InterfaceDef.loadContents(Unknown Source)
	at org.jacorb.ir.Container.loadContents(Unknown Source)
	at org.jacorb.ir.ModuleDef.loadContents(Unknown Source)
	at org.jacorb.ir.Container.loadContents(Unknown Source)
	at org.jacorb.ir.ModuleDef.loadContents(Unknown Source)
	at org.jacorb.ir.Container.loadContents(Unknown Source)
	at org.jacorb.ir.RepositoryImpl.loadContents(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.jacorb.ir.IRServer.main(Unknown Source)
#####################################################################################################
<<Patch to EnumDef.java around line number 54>>
This patch displays the reason of RepositoryID Fault.

String S_Before = path.substring( 0, path.lastIndexOf("Package")) + "." + name;
String S_After = path + "." + name;
					System.out.println("N_Before = " + S_Before + '\n');
					System.out.println("N_After = " + S_After + '\n');
#####################################################################################################
<<The result of this Patch>>
This shows the String of Classname is lack of String 'Package'.

N_Before = MainModule.TestModule.TestInterface.EnumType

N_After = MainModule.TestModule.TestInterfacePackage.EnumType

java.lang.IllegalArgumentException: cannot find class:
MainModule.TestModule.TestInterface.EnumType
	at org.jacorb.ir.RepositoryID.toRepositoryID(Unknown Source)
	at org.jacorb.ir.RepositoryID.toRepositoryID(Unknown Source)
	at org.jacorb.ir.EnumDef.<init>(Unknown Source)
	at org.jacorb.ir.Contained.createContained(Unknown Source)
	at org.jacorb.ir.InterfaceDef.loadContents(Unknown Source)
	at org.jacorb.ir.Container.loadContents(Unknown Source)
	at org.jacorb.ir.ModuleDef.loadContents(Unknown Source)
	at org.jacorb.ir.Container.loadContents(Unknown Source)
	at org.jacorb.ir.ModuleDef.loadContents(Unknown Source)
	at org.jacorb.ir.Container.loadContents(Unknown Source)
	at org.jacorb.ir.RepositoryImpl.loadContents(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.jacorb.ir.IRServer.main(Unknown Source)
Comment 12 Sotohiro Terashima 2005-06-09 15:19:45 CEST
>Guys, can you provide a test case please that shows the problem and also 
>that the patch solves it? Could you perhaps provide an IDL file that,
>when compiled using "idl -ir" results in the problems?

Hi Mr. Gerald, here is a good case from your book 
"Advanced Techniques for Building Distributed Applications, 3rd Edition" chapter8.

My patch solves the same problem.

#################################################################################
module chapter8 {
module roomBooking {
module idlgen {

    interface Meeting {
    
        readonly attribute string purpose;
        readonly attribute string participants;

        oneway void destroy();
    };
    
    interface MeetingFactory {
    
        Meeting createMeeting( in string purpose, in string participants);
    };
    
    interface Room {
    
        enum Slot { am9, am10, am11, pm12, pm1, pm2, pm3, pm4 };

        const short MaxSlots = 8;
    
        typedef Meeting Meetings[ MaxSlots ];
    
        exception NoMeetingInThisSlot {};
        exception SlotAlreadyTaken {};
    
        readonly attribute string name;
    
        Meetings view ();
    
        void book( in Slot a_slot, in Meeting  a_meeting )
            raises(SlotAlreadyTaken);
    
        void cancelBooking( in Slot  a_slot )
            raises(NoMeetingInThisSlot);
    };
}; }; };

Comment 13 Sotohiro Terashima 2005-06-10 17:45:08 CEST
>Guys, can you provide a test case please that shows the problem and also 
>that the patch solves it? Could you perhaps provide an IDL file that,
>when compiled using "idl -ir" results in the problems?

Hi Mr. Gerald, here is more simple case from BUG_Report:
[jacorb-developer] Interface Repository: How do I set it up correctly?
Alexander Szep szep at ict.tuwien.ac.at
Fri Nov 9 17:26:55 CET 2001.

I added enum to this idl.
##############################################

module aa
{
	interface b
	{
	struct foo{string name;};
	foo C();
	enum Slot { am9, am10, am11, pm12, pm1, pm2, pm3, pm4 };
	};
};

####################################################

My patch solves the same both problems.