#1 Adds dynamic class-loading/unloading and a Thread Pool


This code is based on the Code of version 2.06.

I modified JavaBridgeClassLoader (only very slightly),
modified JavaBridgeClassLoader (significantly, it's now
derived from DynamicClassLoader) and added 2 new
classes: DynamicClassLoader (which adds dynamic
class loading/unloading) and BridgeThread (which adds
a simple Thread pool implementation).

A thread pool seemed neccessary, since it is

1.) Generally a good idea
2.) Every Thread gets it's own Classloader, and
Classloader instantiation is much more expensive than
calling DynamicClassLoader.clear() and re-using it.

To disable the ThreadPool, simply set
BridgeThread.poolSize to 0

The DynamicClassLoader uses advanced caching and
lazy evaluation methods to keep it's resource usage as
low as possible, while still allowing modification-tracking
of Jar-Files and Class Re-Loading.


- Testing - I have made a few tests and it worked well,
but who knows.

- This implementation adds the System Jar files by
default to the delayed list of Classloaders. I don't
consider that a beautiful solution, but it was quick.


  • Kai Londenberg

    Kai Londenberg - 2005-06-20

    Archive containing the modified source files (to create a real patch, diff to V2.06) and a modified JavaBridge.jar (drop-in replacement for a V2.06 installation)

  • Kai Londenberg

    Kai Londenberg - 2005-06-22

    Logged In: YES

    Now, this is the latest patch based on the CVS Code

    It features all of the above, but also has a jikes-based java
    build system which allows on-the-fly-compilation and loading
    of java classes.

    It also features the old *and* new classloaders, it's possible
    to configure which one to use.

    To install and use:

    - Simply replace JavaBridge.jar with the new version found in
    this archive.

    - Restart your Webserver and/or JVM running the Bridge

    - Edit the newly created PHPJavaBridge.ini in your PHP
    Library path, so that instead of "classloader=Classic" it reads

    Restart JVM and Webserver again. Here you go ..

    The jikes example allows on-the-fly adaptive compilation of
    java source-trees. Together with dynamic classloading, this
    means we have all the advantages of Java, PHP and JSP
    together. (I have included the Linux jikes binary as well. To
    use this under Windows, you'd need a Windows binary of the
    jikes Compiler)

    After installation, I recommend to take a look at the jikes
    example to get an idea of how it works ..

  • Kai Londenberg

    Kai Londenberg - 2005-06-22

    Logged In: YES

    The last patch file contained some old code. This one is
    cleaned up and should be used instead

  • Kai Londenberg

    Kai Londenberg - 2005-06-22

    Archive containing the modified source files (to create a real patch, diff to CVS) and a modified JavaBridge.jar (drop-in replacement for a V2.06 and 2.07preinstallation)

  • Nobody/Anonymous

    Logged In: NO


    I have looked at your patch yesterday evening, so I cannot
    comment about the new patch.

    Your classloader looks good, just commit it as is. (In the
    code yesterday the linked list was always empty, and two
    synchronized were missing, but that doesn't matter).

    I am not so sure about the thread pool, but feel free to
    commit it, too.

    I don't like how it inherits from the thread class. I think a
    thread pool is just an entity which manages threads. These
    threads simply delegate to the user's worker routines. In
    other words, a thread pool would have a Delegate inheriting
    from Thread which continues to consume the worker
    routines. The synchronization can be done in two routines,
    the one that pulls the workers off the list and the one which
    pushes the worker routines and decides whether or not a new
    thread must be created.

    I have attached a ThreadPool.java which shows how I think it
    should look like (not testet, though).

  • Jost Bökemeier

    Jost Bökemeier - 2005-06-22

    Logged In: YES

    I forgot to attach the file.

  • Nobody/Anonymous

    Logged In: NO

    It seems that it is impossible to attach files to tickets owned
    by others, so I've created a new patch. :)

  • Kai Londenberg

    Kai Londenberg - 2005-06-23
    • status: open --> open-accepted
  • Kai Londenberg

    Kai Londenberg - 2005-06-23
    • status: open-accepted --> closed-accepted

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks