[2081] in java-interest

home help back first fref pref prev next nref lref last post

Re: Dynamic Loading of Classes

daemon@ATHENA.MIT.EDU (Mike Christiansen)
Sat Sep 23 00:50:04 1995

To: Gregory Alan Bolcer <gbolcer@liege.ICS.UCI.EDU>
From: mikec@metronet.com (Mike Christiansen)
Date: Fri, 22 Sep 1995 21:20:14 LOCAL
Cc: java-interest@java.sun.com

In article  Gregory Alan Bolcer <gbolcer@liege.ICS.UCI.EDU> writes:

>    I've programmed myself into a corner, and I am seeking advice
>on the following problem.  I have a Java unix process that is
>maintaining a dynamically changeable object model (categories) 
>built on top of Java.  The methods to these categories can be 
>dynamically changed at runtime and are implemented as Java classes
>within a file directory.  

Sounds cool however, Java is not a dynamic language in the sense that 
Smalltalk is a dynamic language. This works it self back to the request for 
perform: capabilities ala Smalltalk. The reason for no perform: (as it was 
explained to me) is that it opens a big security hole. For example, a Nasty 
Old Java App (NOJA) could evoke the method "MySystem.sendUglyMailToMyBoss" if 
a class with such an interface exists. I guess that the NOJA could scan the 
class which it finds on a given workstation and try things at random causing 
all sorts of havoc. 

HEY ANYONE AT SUN, AM I RIGHT?

>To execute a handler, the process receives a String representation 
>of a) the Java class name, b) the name of the method, c) the 
>signature of the method, and d) the parameters to the method.  I've 
>been through the manual pages, looked at the examples, and played 
>around with classLoader, defineClass, ObjectScope, forName, etc. but
>I am having problems with, 

>1) I'm not sure how to convert
>the Class I get into the type I need loaded, and 2) how
>to access the methods of this newly loaded type so that
>I can execute it.   What would be the best approach to
>executing the following:   "ClassName"."MessageName"(...);
>Any advice would be appreciated.

I understand that the statement: 'new "className"; ' returns an Object 
instance that you can cast into any class. However the cast is burned into the 
source (compiled source) and so is static and can be checked by the compiler. 
It seems that this is only useful if the you cast the object instance into a 
subclass of "className". Now you can evoke overridden methods defined by 
"className" and get subclass-specific behaviors.

Again, am I correct?

Hoped this was correct and that it helped.
Mike

>Greg

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Mike Christiansen
mikec@metronet.com

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post