Re: [aspectwerkz-dev] Sort of a bug in AspectWerkzPreProcessor.java

Alexandre Vasseur <[email protected]> Wed, 8 Dec 2004 14:22:24 +0100
Newsgroups gmane.comp.java.aspectwerkz.devel
Message-ID <[email protected]>
Hi

I will fix it in RC2. Just be aware that this means that someone is
trying to define a on the fly generated class (f.e. a proxy) with a
"null" name.
This has been deprecated (see javadoc for ClassLoader . defineClass)
but was used perhaps 6 month ago in some (old) cglib verrsion f.e.

I ll let you know when fixed (though I won't have a good test case for it)

Alex


On Tue, 07 Dec 2004 13:31:50 +0100, Niklas Therning <[email protected]> wrote:
> Hi,
> 
> I've just started using AspectWerkz and I find it very useful! I'm using
> it in a cocoon-based webapp. My problem is that on each http request I
> get the following (several times) on the console:
> 
> AspectWerkz - WARN - Error pre-processing class null in
> Thread[Thread-15,5,main]
> java.lang.NullPointerException
>         at
> org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor.preProcess(AspectWerkzPreProcessor.java:131)
>         at
> org.codehaus.aspectwerkz.hook.impl.ClassPreProcessorHelper.defineClass0Pre(ClassPreProcessorHelper.java:107)
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:448)
>         at
> org.apache.xalan.xsltc.trax.TemplatesImpl$TransletClassLoader.defineClass(TemplatesImpl.java:125)
>         at
> org.apache.xalan.xsltc.trax.TemplatesImpl.defineTransletClasses(TemplatesImpl.java:296)
>         at
> org.apache.xalan.xsltc.trax.TemplatesImpl.getTransletInstance(TemplatesImpl.java:333)
>         at
> org.apache.xalan.xsltc.trax.TemplatesImpl.newTransformer(TemplatesImpl.java:366)
> ...
> 
> The NPE is thrown on this line:
> 
> final String className = name.replace('/', '.');
> 
> I think it should rather be
> 
> final String className = name != null ? name.replace('/', '.') : null;
> 
> As I understand it the filter() method, which is called right after the
> line above, will filter out classes with a null name anyway.
> 
> I guess it's not really a bug since
> ClassPreProcessorHelper.defineClass0Pre() uses the original byte-array
> if an exception is thrown within AspectWerkzPreProcessor.preProcess().
> The problem is that since this gets written directly to stderr there's
> no way for me to suppress these error messages and it's rely annoying
> and could even introduce a performance penalty in my application.
> 
> Regards,
> Niklas Therning
> 
>