axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Jellinghaus <>
Subject Re: Yesterday's chat log (07/24/01)
Date Wed, 25 Jul 2001 19:35:48 GMT
At 06:31 PM 7/25/2001 +0100, Pratik Patel wrote:
>As far as I know, there is *no* way to do anything with a 
>class/interface that doesn't exist at compile time. I'd love for you to 
>prove me wrong :) as this would make what I'm trying to do with Apache 
>SOAP a bit easier.

The trick is ugly as sin.  It is just using Class.forName and standard
reflection to call methods on a class that is not explicitly imported.  Of
course you get no type checking, and the class must be on your classpath at
runtime, and you must be in a situation that supports runtime class
loading.  So you had better get it right!

For instance, this (abridged) code from Axis's

Class SSLSocketFactoryClass = Class.forName("");
Class SSLSocketClass = Class.forName("");
Method createSocketMethod = SSLSocketFactoryClass.getMethod("createSocket"
    new Class[] {String.class, Integer.TYPE});
Object sslSocket = null;
if (tunnelHost == null || tunnelHost.equals("")) {
    // direct SSL connection
    sslSocket = createSocketMethod .invoke(factory,
        new Object[] {host, new Integer(port)});

Here, the code can make use of, without the
compiler compiling that class.


View raw message