• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger


Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would happen if you narrow something that doesnt need to be narrowed ?

(ie. calling create() / findByPrimaryKey(...) )
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Ryan,

I don't think you can narrow something that is not itself remote. The API states that PortableRemoteObject.narrow:

Checks to ensure that an object of a remote or abstract interface type can be cast to a desired type

It states that you would get a ClassCastException if narrowFrom cannot be cast to narrowTo. If narrowFrom (i.e. your object that doesn't need to be narrowed) is not a Remote interface, I am guessing you would get a ClassCastException. I'm not quite sure what they mean by an abstract interface type...aren't all interfaces abstract? If that's the case, then perhaps you can narrow to anything as long as it implements the interface you are using to do the narrow?

You could verify this for certain by either trying it yourself, or cracking open the code for PortableRemoteObject and seeing what it really does.

[ August 13, 2004: Message edited by: Jason Mowat ]
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic