commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Inger, Matthew" <>
Subject RE: [Math] common-math and bloated 3rd party libraries
Date Mon, 17 Nov 2003 17:56:49 GMT
Not really a runtime dependency.  You would merely use
a class loader which would have BCEL instrument your code.
Your code would have have no clue about anything that's
being done to it, and you could easily write your code
generically enough to plug in an arbitrary classloader.
Here's a main program which replaces the classloader,
and calls another main program.  Think of it as a wrapper

    public static void main(String[] args)
        throws Exception
        // This is where you would construct your class loader
        // Done generically enough, you could specify a classloader
        // on the command line, and construct it here using reflection.
        ClassLoader myClassLoader =

        final int realClassNameIndex = 0;
        String realClassName = args[realClassNameIndex];
        int realArgsLength = args.length - realClassNameIndex - 1;
        String realClassArgs [] = new String[realArgsLength];
        System.arraycopy(args, realClassNameIndex + 1,
                         realClassArgs, 0,

        Class clazz = myClassLoader.loadClass(realClassName);
        Method m = clazz.getDeclaredMethod("main",
                new Class[] { args.getClass() });

        m.invoke(null, new Object[] { realClassArgs });

-----Original Message-----
From: Tomasz Pik []
Sent: Monday, November 17, 2003 12:03 PM
To: Jakarta Commons Developers List
Subject: Re: [Math] common-math and bloated 3rd party libraries

Mark R. Diggory wrote:

> I know there were a means to setup logging for debugging without 
> actually having to bury your code in logging lines... I've actually seen 
> packages like BCEL used to transform the classes in such a way as to 
> "inject" logging lines into bytecode, its a pretty slick idea, but also 
> has the overhead of learning how to use BCEL to manipulate the bytecode 
> base without screwing with the actual algorithm behavior.

But it introduces another runtime dependency...


> -Mark

To unsubscribe, e-mail:
For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message