Debian Bug report logs - #707298
libcglib-java: code changes break libmockito-java

version graph

Package: libcglib-java; Maintainer for libcglib-java is Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>; Source for libcglib-java is src:cglib (PTS, buildd, popcon).

Reported by: Stefan Denker <Stefan+debian@dn-kr.de>

Date: Wed, 8 May 2013 21:24:01 UTC

Severity: important

Tags: patch

Found in version cglib/2.2.2+dfsg-5

Forwarded to https://sourceforge.net/p/cglib/bugs/43/

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>:
Bug#707298; Package libcglib-java. (Wed, 08 May 2013 21:24:06 GMT) (full text, mbox, link).


Acknowledgement sent to Stefan Denker <Stefan+debian@dn-kr.de>:
New Bug report received and forwarded. Copy sent to Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>. (Wed, 08 May 2013 21:24:06 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Stefan Denker <Stefan+debian@dn-kr.de>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: libcglib-java: code changes break libmockito-java
Date: Wed, 8 May 2013 23:20:58 +0200
[Message part 1 (text/plain, inline)]
Package: libcglib-java
Version: 2.2.2+dfsg-5
Severity: important
Tags: patch

Dear Maintainer,

The current version of libcglib in debian breaks the libmockito-java
package. I've put together a test class (With code taken from
http://docs.mockito.googlecode.com/hg/latest/org/mockito/Mockito.html#13
)

|List list = new LinkedList();
|List spy = spy(list);
|
|// using the spy calls real methods
|spy.add("one");
|spy.add("two");

Trying to run this yields : 

|java.lang.RuntimeException: Unable to set MockitoNamingPolicy on cglib generator which creates FastClasses
|at org.mockito.internal.creation.cglib.CGLIBHacker.setMockitoNamingPolicy(CGLIBHacker.java:29)
|at org.mockito.internal.creation.MethodInterceptorFilter.intercept(MethodInterceptorFilter.java:42)
|at $java.util.LinkedList$$EnhancerByMockitoWithCGLIB$$440d9615.add(<generated>)
|at testSpy.spying(testSpy.java:17)
|Caused by: java.lang.NullPointerException
|at org.mockito.internal.creation.cglib.CGLIBHacker.setMockitoNamingPolicy(CGLIBHacker.java:23)

Downgrading libcglib to 2.2+dfsg-2 (squeeze) fixes this. 

Browsing the changes in cglib, I traced this down to the
MethodProxy.java class, particularly this change: 
http://cglib.cvs.sourceforge.net/viewvc/cglib/cglib/src/proxy/net/sf/cglib/proxy/MethodProxy.java?r1=1.14&r2=1.15

I believe the change was accidental, so the attached patch restores the
old behaviour. Applying it to libcglib-java makes my test run. 

This is just a workaround, but it is the minimal change to get Mockito
working again in Debian. 

-- System Information:
Debian Release: 7.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libcglib-java depends on:
ii  libasm3-java  3.3.2-1

libcglib-java recommends no packages.

libcglib-java suggests no packages.

-- no debconf information

-- 
Wer A sagt, der muss nicht B sagen. Er kann auch erkennen, dass A falsch war.
Bertolt Brecht
[dont_set_createinfo_to_null.patch (text/x-diff, attachment)]
[testSpy.java (text/x-java, attachment)]
[signature.asc (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>:
Bug#707298; Package libcglib-java. (Fri, 17 May 2013 22:33:09 GMT) (full text, mbox, link).


Acknowledgement sent to Damien Raude-Morvan <drazzib@drazzib.com>:
Extra info received and forwarded to list. Copy sent to Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>. (Fri, 17 May 2013 22:33:09 GMT) (full text, mbox, link).


Message #10 received at 707298@bugs.debian.org (full text, mbox, reply):

From: Damien Raude-Morvan <drazzib@drazzib.com>
To: Stefan Denker <Stefan+debian@dn-kr.de>, 707298@bugs.debian.org
Subject: Re: Bug#707298: libcglib-java: code changes break libmockito-java
Date: Sat, 18 May 2013 00:32:00 +0200
[Message part 1 (text/plain, inline)]
Hi Stefan,

2013/5/8 Stefan Denker <Stefan+debian@dn-kr.de>

> Dear Maintainer,
>
> The current version of libcglib in debian breaks the libmockito-java
> package. I've put together a test class (With code taken from
> http://docs.mockito.googlecode.com/hg/latest/org/mockito/Mockito.html#13
> )
>
> |List list = new LinkedList();
> |List spy = spy(list);
> |
> |// using the spy calls real methods
> |spy.add("one");
> |spy.add("two");
>
> Trying to run this yields :
>
> |java.lang.RuntimeException: Unable to set MockitoNamingPolicy on cglib
> generator which creates FastClasses
> |at
> org.mockito.internal.creation.cglib.CGLIBHacker.setMockitoNamingPolicy(CGLIBHacker.java:29)
> |at
> org.mockito.internal.creation.MethodInterceptorFilter.intercept(MethodInterceptorFilter.java:42)
> |at
> $java.util.LinkedList$$EnhancerByMockitoWithCGLIB$$440d9615.add(<generated>)
> |at testSpy.spying(testSpy.java:17)
> |Caused by: java.lang.NullPointerException
> |at
> org.mockito.internal.creation.cglib.CGLIBHacker.setMockitoNamingPolicy(CGLIBHacker.java:23)
>
> Downgrading libcglib to 2.2+dfsg-2 (squeeze) fixes this.
>
> Browsing the changes in cglib, I traced this down to the
> MethodProxy.java class, particularly this change:
>
> http://cglib.cvs.sourceforge.net/viewvc/cglib/cglib/src/proxy/net/sf/cglib/proxy/MethodProxy.java?r1=1.14&r2=1.15
>
> I believe the change was accidental, so the attached patch restores the
> old behaviour. Applying it to libcglib-java makes my test run.
>
> This is just a workaround, but it is the minimal change to get Mockito
> working again in Debian.
>

Thanks for your analysis of this issue and your provided workaround.
I'm a bit reluctant to apply your patch as-is because, in fact, upstream
added "createInfo = null;" to fix
http://sourceforge.net/p/cglib/bugs/28/

I'll check with them how to fix this properly...

Regards,
-- 
Damien
[Message part 2 (text/html, inline)]

Set Bug forwarded-to-address to 'https://sourceforge.net/p/cglib/bugs/43/'. Request was from Damien Raude-Morvan <drazzib@debian.org> to control@bugs.debian.org. (Fri, 17 May 2013 22:45:09 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>:
Bug#707298; Package libcglib-java. (Sat, 18 May 2013 13:57:06 GMT) (full text, mbox, link).


Acknowledgement sent to Stefan Denker <Stefan+debian@dn-kr.de>:
Extra info received and forwarded to list. Copy sent to Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>. (Sat, 18 May 2013 13:57:06 GMT) (full text, mbox, link).


Message #17 received at 707298@bugs.debian.org (full text, mbox, reply):

From: Stefan Denker <Stefan+debian@dn-kr.de>
To: Damien Raude-Morvan <drazzib@drazzib.com>
Cc: 707298@bugs.debian.org
Subject: Re: Bug#707298: libcglib-java: code changes break libmockito-java
Date: Sat, 18 May 2013 15:54:21 +0200
[Message part 1 (text/plain, inline)]
diff of cglib software

-- 
[Keith has just fallen down a hole]
"Here's the top of a ladder. Why didn't you use it?"
"I was unable to on account of falling past"
[Malicia & Keith] (Terry Prathcett, Amazing Maurice)
[afbac9e6a1bfb10432fa42aa1add60f906e407df.patch (text/x-diff, attachment)]
[signature.asc (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>:
Bug#707298; Package libcglib-java. (Sat, 18 May 2013 14:21:04 GMT) (full text, mbox, link).


Acknowledgement sent to Stefan Denker <Stefan+debian@dn-kr.de>:
Extra info received and forwarded to list. Copy sent to Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>. (Sat, 18 May 2013 14:21:04 GMT) (full text, mbox, link).


Message #22 received at 707298@bugs.debian.org (full text, mbox, reply):

From: Stefan Denker <Stefan+debian@dn-kr.de>
To: Damien Raude-Morvan <drazzib@drazzib.com>
Cc: 707298@bugs.debian.org
Subject: Re: Bug#707298: libcglib-java: code changes break libmockito-java
Date: Sat, 18 May 2013 15:47:32 +0200
[Message part 1 (text/plain, inline)]
Hi Damien, 

On Sat, May 18, 2013 at 12:32:00AM +0200, Damien Raude-Morvan wrote:
> Thanks for your analysis of this issue and your provided workaround.
> I'm a bit reluctant to apply your patch as-is because, in fact, upstream
> added "createInfo = null;" to fix
> http://sourceforge.net/p/cglib/bugs/28/

I've seen this Bugreport as well, but I don't believe setting createInfo
to null fixes this bug, they need to run static Initializers as
suggested in the Bugreport.

Anyway, I extracted the changes made for fixing the mentioned bug. I
believe the real fix is made in net.sf.cglib.core.ReflectUtils and the
changes in MethodProxy are merely accidental. I am attaching the changes
made.

Lastly, createInfo is not accessed after init() is run, according to my
analysis. So not setting it to null just uses a little more heap than
necessary. 

> I'll check with them how to fix this properly...

They're probably going to tell you to fix mockito. Well, I would tell
you. See lines 19-32 on 
https://github.com/mockito/mockito/blob/master/src/org/mockito/internal/creation/cglib/MockitoNamingPolicy.java

Mockito is accessing a private member variable via reflection and
failing loudly if it cannot. 

My first priority is fixing mockito in Debian, including wheezy. But
fixing mockito is more complicated, as far as I see. 

So, my plan of action is as follows: 
 1. Get a cglib with my patch accepted for the next pointrelease
 2. After 1., revert the patch and issue a bug report against mockito. 
 3. Fix the issue in mockito, probably pushing the patch upstream.

Geez, I wish i could assign this bug to both cglib and mockito.

Greetings

Stefan

-- 
"A troll. Stupid but hard to fool. I'm afraid i shall have to try the truth"
"Vy vill zat vork?"
"He's a Policeman The truth usually confuses them. They don't often hear it."
(William and Otto)                                 [Terry Pratchett, The truth]
[signature.asc (application/pgp-signature, inline)]

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Sun Aug 27 02:35:50 2023; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.