• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to check dynamic code downloading ...

 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic