commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Inger, Matthew" <in...@Synygy.com>
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
script.

    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 =
                Thread.currentThread().getContextClassLoader();

        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,
                         realArgsLength);

        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 [mailto:pikus@ais.pl]
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.

AspectJ?
But it introduces another runtime dependency...

Tomek

> -Mark




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org

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