wood burning stoves*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to check dynamic code downloading ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How to check dynamic code downloading ..." Watch "How to check dynamic code downloading ..." New topic
Author

How to check dynamic code downloading ...

Liviu Carausu
Ranch Hand

Joined: Oct 07, 2004
Posts: 157
Hi !
Is there there any way to check that dynamic stubs downloading does not happen ?
I know that I must provide in the runme.jar the stubs obtained by compiling my remote classes
using the rmic compiler.
But still, how can I be sure that no dynamic code downloading occurs ? Is there any way of checking
the classes which are loaded ?
Thanks,
Liviu

Oracle Certified Master Java SE6 Developer(SCJD),
OCE JEE 6 JSP and Servlets Developer.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2247
    
    7

I see you are using RMI for the server. The instructions mentioned a bunch of restrictions for RMI solutions. One of these is "no security managers". If you didn't use a security manager to start/load your RMI server, the server can't do:
* dynamic class downloading
* can not use the java.rmi.Activatable class (connect on demand)


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Hi Liviu,

one easy way for testing would be to take care that there is NO SecurityManager in place! Without SecurityManager RMI still should work fine but automatic class downloading is not allowed without a SecurityManager!

Besides, since Java 5 it's no longer necessary to use rmic to explicitly compile stubs/skeletons! This is done dynamically. Of course only if you can use Java >= 5.

Marco
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

K. Tsang / Marco,

Be aware that if you do not use rmic to explicitly create stubs then they will be created on the server dynamically when required, then the stub classes will be downloaded to the client. When we wrote the last version of the SCJD book, we asked Sun about this, and they stated that stubs must be created or you would run foul of the "no dynamic downloading" rule.

Of course since then people have passed without explicitly creating stubs so this appears to be another case where it just depends on whether the assessor - if you are lucky they won't notice the lack of stubs.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2258
    
    3

Howdy, y'all.

Just to give you all a position, I am of the people that my good buddy Andrew mentioned, that passed without explicitly creating stubs. Theoretically, it is correct; if they are not created explicitly, then they will be created dynamically on the server and downloaded to the client. But when I was developing the project, I was pretty sure I wouldn't have any problem if I didn't generate the stubs explicitly, so I chose not to do it. Also, in my essay exam, I wrote that I didn't generate any stub because I had used Java 6, and this wasn't necessary anymore.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Hi there,

sorry for the confusion with rmic and stub/skeleton generation etc. This was meant only as a general advice and not in respect of any particular exam question! Of course it should be said that automatic downloading of stubs and skeletons won't work either when class downloading is not possible...

Marco
Liviu Carausu
Ranch Hand

Joined: Oct 07, 2004
Posts: 157
Marco Ehrentreich wrote:Hi Liviu,

one easy way for testing would be to take care that there is NO SecurityManager in place! Without SecurityManager RMI still should work fine but automatic class downloading is not allowed without a SecurityManager!

Besides, since Java 5 it's no longer necessary to use rmic to explicitly compile stubs/skeletons! This is done dynamically. Of course only if you can use Java >= 5.

Marco


Hi,
Is by default any SecurityManager installed with jdk1.6 ? It looks like automatic class downloading happens by default with jdk 1.6.
I will provide anyway the stubs but I cannot check if the stubs that I provided are really loaded. Is looks like I have to live with this.
I will try anyway to profile my application heap with some tool to see which classes are loaded and when.
Thanks,
Liviu
Liviu Carausu
Ranch Hand

Joined: Oct 07, 2004
Posts: 157
Hi,
I have found the option for displaying the loaded classe, in case that somebody needs it to check if the stubs are loaded:
java -verbose:class
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5153
    
  12

Hi Liviu,

Tried the verbose-option like your suggested.

a) with use of rmic:
* when you start the server application you will see somewhere between hundreds of loaded class notifications:
[Loaded xyz_Stub from file:/.../runme.jar]
[Loaded xyz_Skel from file:/.../runme.jar]

* when you start a networked client application, you'll see
[Loaded xyz_Stub from file:/.../runme.jar]

b) without use of rmic: you won't see any of the above lines.


Do you have a similar output/result ?

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Liviu Carausu
Ranch Hand

Joined: Oct 07, 2004
Posts: 157
Hi Roel,

I have a similar output/result and this what I expected, only that I want to have it checked from my list ....
I must confess that I'm a bit surprised to see the xyz_Stub output also at server but I think that is important
that the stubs are loaded from the runme.jar.

Greetings,
Liviu
 
 
subject: How to check dynamic code downloading ...
 
Similar Threads
java.rmi.ServerException: java .rmi.UnmarshallException
RMI conformance
RMI problem
RMIC required?
Confused about RMI