United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4730878 : PortableRemoteObject.narrow(...) should not cast result to java.rmi.Remote

Details
Type:
Bug
Submit Date:
2002-08-13
Status:
Closed
Updated Date:
2003-01-07
Project Name:
JDK
Resolved Date:
2004-12-10
Component:
other-libs
OS:
solaris_2.6
Sub-Component:
corba:orb
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:
1.3.1 (07)

Related Reports
Backport:
Backport:
Backport:

Sub Tasks

Description
com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(...) casts the returned result to the java.rmi.Remote interface.

This doesn't work in all cases. The incorrect code (see the two lines below) is inside com.sun.corba.se.internal.util.Utility.loadStub(...). The narrow method calls this loadStub method to create a stub.        

 // Create a stub instance and set the delegate...
 result = (Remote) resultClass.newInstance();

This behavior is contradiciting the spec of javax.rmi.PortableRemoteObject.narrow(...): "Checks to ensure that an object of a remote or abstract interface type can be cast to a desired type"

Since the abstract interfaces do not implement Remote, this code will break for customers using abstract interfaces in their application. This code results in ClassCastException like the following one:

java.lang.ClassCastException: Bank._Account_Stub
	at com.sun.corba.se.internal.util.Utility.loadStub(Utility.java:754)
	at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:287)
	at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
	at Bank._AccountManager_Stub.create(_AccountManager_Stub.java:109)
	at ClientApplet.action(ClientApplet.java:91)
	at java.awt.Component.handleEvent(Unknown Source)
	at java.awt.Component.postEvent(Unknown Source)
	at java.awt.Component.postEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)


This code fails for customer Borland. Borland believes that the result should be cast to javax.rmi.CORBA.Stub (spec defined stub base) (loadStub's return type should be modified too).


                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
1.3.1_07
1.4.0_04
1.4.1_02
mantis

FIXED IN:
1.3.1_07
1.4.0_04
1.4.1_02
mantis

INTEGRATED IN:
1.3.1_07
1.4.0_04
1.4.1_02
mantis
mantis-b08


                                     
2004-06-14
EVALUATION

Will fix it for 1.4.2 since it is too late for 1.4.1 and also, it may go in 1.3.1 and 1.4.0 patches.

                                     
2004-06-11



Hardware and Software, Engineered to Work Together